From: David Sommerseth Date: Thu, 18 Nov 2010 21:17:58 +0000 (+0100) Subject: Merge branch 'feat_misc' into beta2.2 X-Git-Tag: v2.2-beta4~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=529df9922d85574828d95020eebcd228ba3a8164;p=thirdparty%2Fopenvpn.git Merge branch 'feat_misc' into beta2.2 Conflicts: acinclude.m4 config-win32.h configure.ac misc.c thread.c thread.h - These conflicts was mainly due to feat_misc getting old and mostly caused by the pthread clean-up patches in feat_misc Signed-off-by: David Sommerseth --- 529df9922d85574828d95020eebcd228ba3a8164 diff --cc misc.c index 94e9efe89,815c057cf..4067d85ab --- a/misc.c +++ b/misc.c @@@ -26,10 -26,8 +26,9 @@@ #include "buffer.h" #include "misc.h" +#include "base64.h" #include "tun.h" #include "error.h" - #include "thread.h" #include "otime.h" #include "plugin.h" #include "options.h" @@@ -1172,53 -1151,19 +1151,51 @@@ create_temp_file (const char *directory { static unsigned int counter; struct buffer fname = alloc_buf_gc (256, gc); + int fd; + const char *retfname = NULL; + unsigned int attempts = 0; - ++counter; - - { - uint8_t rndbytes[16]; - const char *rndstr; - - prng_bytes (rndbytes, sizeof (rndbytes)); - rndstr = format_hex_ex (rndbytes, sizeof (rndbytes), 40, 0, NULL, gc); - buf_printf (&fname, PACKAGE "_%s_%s.tmp", prefix, rndstr); - } + do + { + uint8_t rndbytes[16]; + const char *rndstr; + + ++attempts; - mutex_lock_static (L_CREATE_TEMP); + ++counter; - mutex_unlock_static (L_CREATE_TEMP); + + prng_bytes (rndbytes, sizeof rndbytes); + rndstr = format_hex_ex (rndbytes, sizeof rndbytes, 40, 0, NULL, gc); + buf_printf (&fname, PACKAGE "_%s_%s.tmp", prefix, rndstr); + + retfname = gen_path (directory, BSTR (&fname), gc); + if (!retfname) + { + msg (M_FATAL, "Failed to create temporary filename and path"); + return NULL; + } + + /* Atomically create the file. Errors out if the file already + exists. */ + fd = open (retfname, O_CREAT | O_EXCL | O_WRONLY, S_IRUSR | S_IWUSR); + if (fd != -1) + { + close (fd); + return retfname; + } + else if (fd == -1 && errno != EEXIST) + { + /* Something else went wrong, no need to retry. */ + struct gc_arena gcerr = gc_new (); + msg (M_FATAL, "Could not create temporary file '%s': %s", + retfname, strerror_ts (errno, &gcerr)); + gc_free (&gcerr); + return NULL; + } + } + while (attempts < 6); - return gen_path (directory, BSTR (&fname), gc); + msg (M_FATAL, "Failed to create temporary file after %i attempts", attempts); + return NULL; } /* diff --cc multi.c index 57310f6d3,4cd7468d6..22c0a3f93 --- a/multi.c +++ b/multi.c @@@ -721,10 -720,10 +720,10 @@@ multi_print_status (struct multi_contex /* * Status file version 1 */ - status_printf (so, PACKAGE_NAME " CLIENT LIST"); + status_printf (so, "OpenVPN CLIENT LIST"); status_printf (so, "Updated,%s", time_string (0, 0, false, &gc_top)); status_printf (so, "Common Name,Real Address,Bytes Received,Bytes Sent,Connected Since"); - hash_iterator_init (m->hash, &hi, true); + hash_iterator_init (m->hash, &hi); while ((he = hash_iterator_next (&hi))) { struct gc_arena gc = gc_new (); diff --cc options.c index 3aa68200e,d0cec7dc6..524c78178 --- a/options.c +++ b/options.c @@@ -73,14 -69,8 +73,11 @@@ const char title_string[] #ifdef PRODUCT_TAP_DEBUG " [TAPDBG]" #endif - #ifdef USE_PTHREAD - " [PTHREAD]" - #endif #ifdef ENABLE_PKCS11 " [PKCS11]" +#endif +#ifdef ENABLE_EUREPHIA + " [eurephia]" #endif " built on " __DATE__ ; diff --cc syshead.h index 6479b2057,3b8ab89eb..d75f88193 --- a/syshead.h +++ b/syshead.h @@@ -535,28 -531,12 +535,10 @@@ socket_defined (const socket_descriptor #endif /* - * Don't compile the struct buffer_list code unless something needs it + * Compile the struct buffer_list code */ -#if defined(ENABLE_MANAGEMENT) || defined(ENABLE_PF) #define ENABLE_BUFFER_LIST -#endif - /* - * Do we have pthread capability? - */ - #ifdef USE_PTHREAD - #if defined(USE_CRYPTO) && defined(USE_SSL) && P2MP - #include - #else - #undef USE_PTHREAD - #endif - #endif - - /* - * Pthread support is currently experimental (and quite unfinished). - */ - #if 1 /* JYFIXME -- if defined, disable pthread */ - #undef USE_PTHREAD - #endif - /* * Should we include OCC (options consistency check) code? */