tmpnam is not good on win32 platforms. I was changing it in mod_authn_mysql, and figured i could help fix mod_auth_digest while i was at it. --- mod_auth_digest.c Tue Feb 18 22:25:50 2003 +++ mod_auth_digest.c.new Tue Feb 18 22:36:31 2003 @@ -119,6 +119,7 @@ #include "apr_shm.h" #include "apr_rmm.h" #include "ap_provider.h" +#include "apr_file_io.h" /* for apr_file_mktemp */ #include "mod_auth.h" @@ -222,8 +223,8 @@ static apr_time_t *otn_counter; /* one-time-nonce counter */ static apr_global_mutex_t *client_lock = NULL; static apr_global_mutex_t *opaque_lock = NULL; -static char client_lock_name[L_tmpnam]; -static char opaque_lock_name[L_tmpnam]; +static char *client_lock_name; +static char *opaque_lock_name; #define DEF_SHMEM_SIZE 1000L /* ~ 12 entries */ #define DEF_NUM_BUCKETS 15L @@ -304,10 +305,17 @@ { unsigned long idx; apr_status_t sts; + apr_file_t *tmpfile; + char *shm_create_name; - /* set up client list */ + sts = apr_file_mktemp(&tmpfile, shm_create_name, 0, ctx); + if (sts != APR_SUCCESS) { + log_error_and_cleanup("failed to allocate temp file for shared memory segments", sts, s); + return; + } - sts = apr_shm_create(&client_shm, shmem_size, tmpnam(NULL), ctx); + /* set up client list */ + sts = apr_shm_create(&client_shm, shmem_size, shm_create_name, ctx); if (sts != APR_SUCCESS) { log_error_and_cleanup("failed to create shared memory segments", sts, s); return; @@ -326,9 +334,12 @@ client_list->tbl_len = num_buckets; client_list->num_entries = 0; - tmpnam(client_lock_name); - /* FIXME: get the client_lock_name from a directive so we're portable - * to non-process-inheriting operating systems, like Win32. */ + sts = apr_file_mktemp(&tmpfile, client_lock_name, 0, ctx); + if (sts != APR_SUCCESS) { + log_error_and_cleanup("failed to allocate temp file for client locking", sts, s); + return; + } + sts = apr_global_mutex_create(&client_lock, client_lock_name, APR_LOCK_DEFAULT, ctx); if (sts != APR_SUCCESS) { @@ -346,9 +357,11 @@ } *opaque_cntr = 1UL; - tmpnam(opaque_lock_name); - /* FIXME: get the opaque_lock_name from a directive so we're portable - * to non-process-inheriting operating systems, like Win32. */ + sts = apr_file_mktemp(&tmpfile, opaque_lock_name, 0, ctx); + if(sts != APR_SUCCESS) { + log_error_and_cleanup("failed to allocate temp file for global locking", sts, s); + return; + } sts = apr_global_mutex_create(&opaque_lock, opaque_lock_name, APR_LOCK_DEFAULT, ctx); if (sts != APR_SUCCESS) {
I'm going through the bug db to make sure patches are findable. Please see http://httpd.apache.org/dev/patches.html
Note that the logic from your patch, which I copied below, is usually going to segfault. Also, the associated feature of mod_auth_digest is disabled via "#define APR_HAS_SHARED_MEMORY 0" until other problems are resolved. For now I'm marking the PR as invalid, but feel free to re-open if you can correct this issue (see doc for apr_file_mktemp()) and submit a new, tested patch. Thanks! + char *shm_create_name; - /* set up client list */ + sts = apr_file_mktemp(&tmpfile, shm_create_name, 0, ctx);