]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Use the APR's new OS-specific proc mutex accessors -- they are used
authorAaron Bannert <aaron@apache.org>
Fri, 19 Oct 2001 23:32:43 +0000 (23:32 +0000)
committerAaron Bannert <aaron@apache.org>
Fri, 19 Oct 2001 23:32:43 +0000 (23:32 +0000)
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

os/unix/unixd.c
os/unix/unixd.h

index 66e1012e9231bcbee4fabbe1698a573cfa48248e..e7059881914fa31c7867f8fc52d78af8bbcdc9bd 100644 (file)
@@ -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;
+}
+
index cb0485c8c2463f46c890da98ff84229ffd147328..434013a7486f2e4f5a770ff4540c004eba6f3559 100644 (file)
@@ -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)))