From: Aaron Bannert Date: Fri, 19 Oct 2001 23:32:43 +0000 (+0000) Subject: Use the APR's new OS-specific proc mutex accessors -- they are used X-Git-Tag: 2.0.27~72 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=648ae56dbaf94dec3edd968c88108483d1963204;p=thirdparty%2Fapache%2Fhttpd.git Use the APR's new OS-specific proc mutex accessors -- they are used here to set permissions on SysV Semaphores. MPMs will be modified to call this new function as they are ported to the new APR lock API. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@91579 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/os/unix/unixd.c b/os/unix/unixd.c index 66e1012e923..e7059881914 100644 --- a/os/unix/unixd.c +++ b/os/unix/unixd.c @@ -390,7 +390,7 @@ AP_DECLARE(apr_status_t) unixd_set_lock_perms(apr_lock_t *lock) long val; struct semid_ds *buf; ushort *array; -}; + }; #endif union semun ick; struct semid_ds buf; @@ -409,3 +409,35 @@ AP_DECLARE(apr_status_t) unixd_set_lock_perms(apr_lock_t *lock) return APR_SUCCESS; } +AP_DECLARE(apr_status_t) unixd_set_proc_mutex_perms(apr_proc_mutex_t *pmutex) +{ +/* MPM shouldn't call us unless we're actually using a SysV sem; + * this is just to avoid compile issues on systems without that + * feature + */ +#if APR_HAS_SYSVSEM_SERIALIZE + apr_os_proc_mutex_t ospmutex; +#if !APR_HAVE_UNION_SEMUN + union semun { + long val; + struct semid_ds *buf; + ushort *array; + }; +#endif + union semun ick; + struct semid_ds buf; + + if (!geteuid()) { + apr_os_proc_mutex_get(&ospmutex, pmutex); + buf.sem_perm.uid = unixd_config.user_id; + buf.sem_perm.gid = unixd_config.group_id; + buf.sem_perm.mode = 0600; + ick.buf = &buf; + if (semctl(ospmutex.crossproc, 0, IPC_SET, ick) < 0) { + return errno; + } + } +#endif + return APR_SUCCESS; +} + diff --git a/os/unix/unixd.h b/os/unix/unixd.h index cb0485c8c24..434013a7486 100644 --- a/os/unix/unixd.h +++ b/os/unix/unixd.h @@ -70,6 +70,7 @@ #include "apr_hooks.h" #include "apr_thread_proc.h" #include "apr_lock.h" +#include "apr_proc_mutex.h" #include #include @@ -118,6 +119,7 @@ AP_DECLARE(void) unixd_set_rlimit(cmd_parms *cmd, struct rlimit **plimit, const char *arg, const char * arg2, int type); #endif AP_DECLARE(apr_status_t) unixd_set_lock_perms(apr_lock_t *lock); +AP_DECLARE(apr_status_t) unixd_set_proc_mutex_perms(apr_proc_mutex_t *pmutex); #ifdef HAVE_KILLPG #define unixd_killpg(x, y) (killpg ((x), (y)))