![]() |
|
|||
0001 /** 0002 * @brief Cryptokey by hostname 0003 * 0004 * @file cryptohost.c 0005 */ 0006 /* ----------------------------------------------------------------------------- 0007 * Enduro/X Middleware Platform for Distributed Transaction Processing 0008 * Copyright (C) 2009-2016, ATR Baltic, Ltd. All Rights Reserved. 0009 * Copyright (C) 2017-2023, Mavimax, Ltd. All Rights Reserved. 0010 * This software is released under one of the following licenses: 0011 * AGPL (with Java and Go exceptions) or Mavimax's license for commercial use. 0012 * See LICENSE file for full text. 0013 * ----------------------------------------------------------------------------- 0014 * AGPL license: 0015 * 0016 * This program is free software; you can redistribute it and/or modify it under 0017 * the terms of the GNU Affero General Public License, version 3 as published 0018 * by the Free Software Foundation; 0019 * 0020 * This program is distributed in the hope that it will be useful, but WITHOUT ANY 0021 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 0022 * PARTICULAR PURPOSE. See the GNU Affero General Public License, version 3 0023 * for more details. 0024 * 0025 * You should have received a copy of the GNU Affero General Public License along 0026 * with this program; if not, write to the Free Software Foundation, Inc., 0027 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 0028 * 0029 * ----------------------------------------------------------------------------- 0030 * A commercial use license is available from Mavimax, Ltd 0031 * contact@mavimax.com 0032 * ----------------------------------------------------------------------------- 0033 */ 0034 #include <string.h> 0035 #include <stdio.h> 0036 #include <stdlib.h> 0037 0038 #include <ndrstandard.h> 0039 #include <ndebug.h> 0040 #include <nstdutil.h> 0041 #include <expluginbase.h> 0042 #include <sys_unix.h> 0043 0044 /*---------------------------Externs------------------------------------*/ 0045 /*---------------------------Macros-------------------------------------*/ 0046 /*---------------------------Enums--------------------------------------*/ 0047 /*---------------------------Typedefs-----------------------------------*/ 0048 /*---------------------------Globals------------------------------------*/ 0049 /*---------------------------Statics------------------------------------*/ 0050 exprivate char M_hostname[PATH_MAX]; 0051 exprivate int M_hostname_first = EXTRUE; 0052 /*---------------------------Prototypes---------------------------------*/ 0053 0054 /** 0055 * Initialize the plugin 0056 * @param provider_name plugin name/provider string 0057 * @param provider_name_bufsz provider string buffer size 0058 * @return FAIL (in case of error) or OR'ed function flags 0059 */ 0060 expublic long ndrx_plugin_init(char *provider_name, int provider_name_bufsz) 0061 { 0062 snprintf(provider_name, provider_name_bufsz, "Enduro/X Crypthost"); 0063 0064 NDRX_LOG_EARLY(log_info, "Cryptohost plugin init..."); 0065 0066 /* we provide encryption key function */ 0067 return NDRX_PLUGIN_FUNC_ENCKEY; 0068 } 0069 0070 /** 0071 * Get the encryption key 0072 * @param keybuf 0073 * @param keybuf_bufsz 0074 * @return EXSUCCEED/EXFAIL 0075 */ 0076 expublic int ndrx_plugin_crypto_getkey(char *keybuf, int keybuf_bufsz) 0077 { 0078 int ret = EXSUCCEED; 0079 0080 /* No problem if we run from mutliple threads.. 0081 * the hostname is save anyway so bytes in mem should be put in the same order 0082 */ 0083 if (M_hostname_first) 0084 { 0085 if (EXSUCCEED!=ndrx_sys_get_hostname(M_hostname, sizeof(M_hostname))) 0086 { 0087 NDRX_LOG_EARLY(log_error, "Failed to get hostname!"); 0088 EXFAIL_OUT(ret); 0089 } 0090 0091 M_hostname_first = EXFALSE; 0092 } 0093 0094 NDRX_STRCPY_SAFE_DST(keybuf, M_hostname, keybuf_bufsz); 0095 0096 out: 0097 return ret; 0098 } 0099 /* vim: set ts=4 sw=4 et smartindent: */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |