Commit c1259d8f authored by Aaron Bannert's avatar Aaron Bannert
Browse files

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
parent 10d6e815
Loading
Loading
Loading
Loading
+33 −1
Original line number Diff line number Diff line
@@ -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;
}
+2 −0
Original line number Diff line number Diff line
@@ -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)))