diff options
author | Aaron Bannert <aaron@apache.org> | 2001-10-20 01:32:43 +0200 |
---|---|---|
committer | Aaron Bannert <aaron@apache.org> | 2001-10-20 01:32:43 +0200 |
commit | 648ae56dbaf94dec3edd968c88108483d1963204 (patch) | |
tree | ebc21cc78cea9152a385ae484d683ba5e5c722d7 /os | |
parent | Win32: ap_max_requests_per_child should not be a local static in mpm_winnt.c. (diff) | |
download | apache2-648ae56dbaf94dec3edd968c88108483d1963204.tar.xz apache2-648ae56dbaf94dec3edd968c88108483d1963204.zip |
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
Diffstat (limited to 'os')
-rw-r--r-- | os/unix/unixd.c | 34 | ||||
-rw-r--r-- | os/unix/unixd.h | 2 |
2 files changed, 35 insertions, 1 deletions
diff --git a/os/unix/unixd.c b/os/unix/unixd.c index 66e1012e92..e705988191 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 cb0485c8c2..434013a748 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 <pwd.h> #include <grp.h> @@ -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))) |