diff options
author | David Sommerseth <dazo@users.sourceforge.net> | 2009-01-10 00:49:59 +0100 |
---|---|---|
committer | David Sommerseth <dazo@users.sourceforge.net> | 2009-01-10 00:49:59 +0100 |
commit | d5c7a4c72731cc36e0e8cf4fd3a6a0811344a4d8 (patch) | |
tree | 8a9c24f5e99acf06bab383f1c798bb0a174317a5 /common/eurephiadb_session_common.c | |
parent | be9c9cab62dbfe03ff6b2a44b9eefc27e8afd0b4 (diff) | |
download | eurephia-d5c7a4c72731cc36e0e8cf4fd3a6a0811344a4d8.tar.gz eurephia-d5c7a4c72731cc36e0e8cf4fd3a6a0811344a4d8.tar.xz eurephia-d5c7a4c72731cc36e0e8cf4fd3a6a0811344a4d8.zip |
Moved eDBsessionGetRandString(...) to a more global and independent eurephia_randstring(...) function
Diffstat (limited to 'common/eurephiadb_session_common.c')
-rw-r--r-- | common/eurephiadb_session_common.c | 27 |
1 files changed, 1 insertions, 26 deletions
diff --git a/common/eurephiadb_session_common.c b/common/eurephiadb_session_common.c index 9e51702..76cd1c0 100644 --- a/common/eurephiadb_session_common.c +++ b/common/eurephiadb_session_common.c @@ -1,6 +1,6 @@ /* eurephiadb_session_common.c -- Common function for handling sessions * - * GPLv2 - Copyright (C) 2008 David Sommerseth <dazo@users.sourceforge.net> + * GPLv2 - Copyright (C) 2008, 2009 David Sommerseth <dazo@users.sourceforge.net> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -22,7 +22,6 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> -#include <openssl/rand.h> #include <eurephia_nullsafe.h> #include <eurephia_context.h> @@ -95,30 +94,6 @@ int eDBset_session_value(eurephiaCTX *ctx, eurephiaSESSION *session, const char } -// Generate some random data and return a string. -static int rand_init = 0; -int eDBsessionGetRandString(eurephiaCTX *ctx, char *rndstr, int len) { - int attempts = 0; - do { - if( !rand_init ) { - if( !RAND_load_file("/dev/urandom", 64) ) { - eurephia_log(ctx, LOG_FATAL, 0, "Could not load random data from /dev/urandom"); - return 0; - } - rand_init = 1; - } - - if( RAND_pseudo_bytes((unsigned char *) rndstr, len) ) { - return 1; - } - sleep(1); - rand_init = 0; - } while( attempts++ < 11 ); - eurephia_log(ctx, LOG_FATAL, 0, "RAND_pseudo_bytes() could not generate enough random data"); - return 0; -} - - // Free up the memory used by a session structure void eDBfree_session_func(eurephiaCTX *ctx, eurephiaSESSION *session) { if( session == NULL ) { |