You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by ji...@apache.org on 2013/10/17 17:10:12 UTC
svn commit: r1533105 - in /apr/apr/branches/1.5.x: ./ include/
include/arch/unix/ locks/beos/ locks/netware/ locks/os2/ locks/unix/
locks/win32/ shmem/beos/ shmem/os2/ shmem/unix/ shmem/win32/ strings/
threadproc/beos/ threadproc/netware/ threadproc/os...
Author: jim
Date: Thu Oct 17 15:10:11 2013
New Revision: 1533105
URL: http://svn.apache.org/r1533105
Log:
Merge r1533104 from trunk:
it should really handle src==NULL
Reviewed/backported by: jim
Modified:
apr/apr/branches/1.5.x/ (props changed)
apr/apr/branches/1.5.x/include/apr_global_mutex.h
apr/apr/branches/1.5.x/include/apr_proc_mutex.h
apr/apr/branches/1.5.x/include/apr_shm.h
apr/apr/branches/1.5.x/include/apr_thread_proc.h
apr/apr/branches/1.5.x/include/arch/unix/apr_arch_proc_mutex.h
apr/apr/branches/1.5.x/include/arch/unix/apr_arch_shm.h
apr/apr/branches/1.5.x/include/arch/unix/apr_arch_threadproc.h
apr/apr/branches/1.5.x/locks/beos/proc_mutex.c
apr/apr/branches/1.5.x/locks/netware/proc_mutex.c
apr/apr/branches/1.5.x/locks/os2/proc_mutex.c
apr/apr/branches/1.5.x/locks/unix/global_mutex.c
apr/apr/branches/1.5.x/locks/unix/proc_mutex.c
apr/apr/branches/1.5.x/locks/win32/proc_mutex.c
apr/apr/branches/1.5.x/shmem/beos/shm.c
apr/apr/branches/1.5.x/shmem/os2/shm.c
apr/apr/branches/1.5.x/shmem/unix/shm.c
apr/apr/branches/1.5.x/shmem/win32/shm.c
apr/apr/branches/1.5.x/strings/apr_cpystrn.c
apr/apr/branches/1.5.x/threadproc/beos/proc.c
apr/apr/branches/1.5.x/threadproc/netware/proc.c
apr/apr/branches/1.5.x/threadproc/os2/proc.c
apr/apr/branches/1.5.x/threadproc/unix/proc.c
apr/apr/branches/1.5.x/threadproc/win32/proc.c
Propchange: apr/apr/branches/1.5.x/
------------------------------------------------------------------------------
Merged /apr/apr/trunk:r1533104
Modified: apr/apr/branches/1.5.x/include/apr_global_mutex.h
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.5.x/include/apr_global_mutex.h?rev=1533105&r1=1533104&r2=1533105&view=diff
==============================================================================
--- apr/apr/branches/1.5.x/include/apr_global_mutex.h (original)
+++ apr/apr/branches/1.5.x/include/apr_global_mutex.h Thu Oct 17 15:10:11 2013
@@ -135,6 +135,11 @@ APR_DECLARE(const char *) apr_global_mut
APR_DECLARE(const char *) apr_global_mutex_name(apr_global_mutex_t *mutex);
/**
+ * Set mutex permissions.
+ */
+APR_PERMS_SET_IMPLEMENT(global_mutex);
+
+/**
* Get the pool used by this global_mutex.
* @return apr_pool_t the pool
*/
Modified: apr/apr/branches/1.5.x/include/apr_proc_mutex.h
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.5.x/include/apr_proc_mutex.h?rev=1533105&r1=1533104&r2=1533105&view=diff
==============================================================================
--- apr/apr/branches/1.5.x/include/apr_proc_mutex.h (original)
+++ apr/apr/branches/1.5.x/include/apr_proc_mutex.h Thu Oct 17 15:10:11 2013
@@ -25,6 +25,7 @@
#include "apr.h"
#include "apr_pools.h"
#include "apr_errno.h"
+#include "apr_perms_set.h"
#ifdef __cplusplus
extern "C" {
@@ -152,6 +153,11 @@ APR_DECLARE(const char *) apr_proc_mutex
APR_DECLARE(const char *) apr_proc_mutex_defname(void);
/**
+ * Set mutex permissions.
+ */
+APR_PERMS_SET_IMPLEMENT(proc_mutex);
+
+/**
* Get the pool used by this proc_mutex.
* @return apr_pool_t the pool
*/
Modified: apr/apr/branches/1.5.x/include/apr_shm.h
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.5.x/include/apr_shm.h?rev=1533105&r1=1533104&r2=1533105&view=diff
==============================================================================
--- apr/apr/branches/1.5.x/include/apr_shm.h (original)
+++ apr/apr/branches/1.5.x/include/apr_shm.h Thu Oct 17 15:10:11 2013
@@ -25,6 +25,7 @@
#include "apr.h"
#include "apr_pools.h"
#include "apr_errno.h"
+#include "apr_perms_set.h"
#ifdef __cplusplus
extern "C" {
@@ -133,6 +134,11 @@ APR_DECLARE(void *) apr_shm_baseaddr_get
APR_DECLARE(apr_size_t) apr_shm_size_get(const apr_shm_t *m);
/**
+ * Set shared memory permissions.
+ */
+APR_PERMS_SET_IMPLEMENT(shm);
+
+/**
* Get the pool used by this shared memory segment.
*/
APR_POOL_DECLARE_ACCESSOR(shm);
Modified: apr/apr/branches/1.5.x/include/apr_thread_proc.h
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.5.x/include/apr_thread_proc.h?rev=1533105&r1=1533104&r2=1533105&view=diff
==============================================================================
--- apr/apr/branches/1.5.x/include/apr_thread_proc.h (original)
+++ apr/apr/branches/1.5.x/include/apr_thread_proc.h Thu Oct 17 15:10:11 2013
@@ -26,6 +26,7 @@
#include "apr_file_io.h"
#include "apr_pools.h"
#include "apr_errno.h"
+#include "apr_perms_set.h"
#if APR_HAVE_STRUCT_RLIMIT
#include <sys/time.h>
@@ -577,6 +578,18 @@ APR_DECLARE(apr_status_t) apr_procattr_g
const char *groupname);
+/**
+ * Register permission set function
+ * @param attr The procattr we care about.
+ * @param perms_set_fn Permission set callback
+ * @param data Data to pass to permission callback function
+ * @param perms Permissions to set
+ */
+APR_DECLARE(apr_status_t) apr_procattr_perms_set_register(apr_procattr_t *attr,
+ apr_perms_setfn_t *perms_set_fn,
+ void *data,
+ apr_fileperms_t perms);
+
#if APR_HAS_FORK
/**
* This is currently the only non-portable call in APR. This executes
Modified: apr/apr/branches/1.5.x/include/arch/unix/apr_arch_proc_mutex.h
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.5.x/include/arch/unix/apr_arch_proc_mutex.h?rev=1533105&r1=1533104&r2=1533105&view=diff
==============================================================================
--- apr/apr/branches/1.5.x/include/arch/unix/apr_arch_proc_mutex.h (original)
+++ apr/apr/branches/1.5.x/include/arch/unix/apr_arch_proc_mutex.h Thu Oct 17 15:10:11 2013
@@ -75,6 +75,7 @@ struct apr_proc_mutex_unix_lock_methods_
apr_status_t (*release)(apr_proc_mutex_t *);
apr_status_t (*cleanup)(void *);
apr_status_t (*child_init)(apr_proc_mutex_t **, apr_pool_t *, const char *);
+ apr_status_t (*perms_set)(apr_proc_mutex_t *, apr_fileperms_t, apr_uid_t, apr_gid_t);
const char *name;
};
typedef struct apr_proc_mutex_unix_lock_methods_t apr_proc_mutex_unix_lock_methods_t;
Modified: apr/apr/branches/1.5.x/include/arch/unix/apr_arch_shm.h
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.5.x/include/arch/unix/apr_arch_shm.h?rev=1533105&r1=1533104&r2=1533105&view=diff
==============================================================================
--- apr/apr/branches/1.5.x/include/arch/unix/apr_arch_shm.h (original)
+++ apr/apr/branches/1.5.x/include/arch/unix/apr_arch_shm.h Thu Oct 17 15:10:11 2013
@@ -67,6 +67,7 @@ struct apr_shm_t {
const char *filename; /* NULL if anonymous */
#if APR_USE_SHMEM_SHMGET || APR_USE_SHMEM_SHMGET_ANON
int shmid; /* shmem ID returned from shmget() */
+ key_t shmkey; /* shmem key IPC_ANON or returned from ftok() */
#endif
};
Modified: apr/apr/branches/1.5.x/include/arch/unix/apr_arch_threadproc.h
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.5.x/include/arch/unix/apr_arch_threadproc.h?rev=1533105&r1=1533104&r2=1533105&view=diff
==============================================================================
--- apr/apr/branches/1.5.x/include/arch/unix/apr_arch_threadproc.h (original)
+++ apr/apr/branches/1.5.x/include/arch/unix/apr_arch_threadproc.h Thu Oct 17 15:10:11 2013
@@ -19,6 +19,7 @@
#include "apr_thread_proc.h"
#include "apr_file_io.h"
#include "apr_arch_file_io.h"
+#include "apr_perms_set.h"
/* System headers required for thread/process library */
#if APR_HAVE_PTHREAD_H
@@ -76,6 +77,14 @@ struct apr_thread_once_t {
#endif
+typedef struct apr_procattr_pscb_t apr_procattr_pscb_t;
+struct apr_procattr_pscb_t {
+ struct apr_procattr_pscb_t *next;
+ apr_perms_setfn_t *perms_set_fn;
+ apr_fileperms_t perms;
+ const void *data;
+};
+
struct apr_procattr_t {
apr_pool_t *pool;
apr_file_t *parent_in;
@@ -103,6 +112,7 @@ struct apr_procattr_t {
apr_int32_t errchk;
apr_uid_t uid;
apr_gid_t gid;
+ apr_procattr_pscb_t *perms_set_callbacks;
};
#endif /* ! THREAD_PROC_H */
Modified: apr/apr/branches/1.5.x/locks/beos/proc_mutex.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.5.x/locks/beos/proc_mutex.c?rev=1533105&r1=1533104&r2=1533105&view=diff
==============================================================================
--- apr/apr/branches/1.5.x/locks/beos/proc_mutex.c (original)
+++ apr/apr/branches/1.5.x/locks/beos/proc_mutex.c Thu Oct 17 15:10:11 2013
@@ -140,6 +140,8 @@ APR_DECLARE(const char *) apr_proc_mutex
return "beossem";
}
+APR_PERMS_SET_ENOTIMPL(proc_mutex)
+
APR_POOL_IMPLEMENT_ACCESSOR(proc_mutex)
/* Implement OS-specific accessors defined in apr_portable.h */
Modified: apr/apr/branches/1.5.x/locks/netware/proc_mutex.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.5.x/locks/netware/proc_mutex.c?rev=1533105&r1=1533104&r2=1533105&view=diff
==============================================================================
--- apr/apr/branches/1.5.x/locks/netware/proc_mutex.c (original)
+++ apr/apr/branches/1.5.x/locks/netware/proc_mutex.c Thu Oct 17 15:10:11 2013
@@ -97,6 +97,8 @@ APR_DECLARE(const char *) apr_proc_mutex
return "netwarethread";
}
+APR_PERMS_SET_ENOTIMPL(proc_mutex)
+
APR_POOL_IMPLEMENT_ACCESSOR(proc_mutex)
/* Implement OS-specific accessors defined in apr_portable.h */
Modified: apr/apr/branches/1.5.x/locks/os2/proc_mutex.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.5.x/locks/os2/proc_mutex.c?rev=1533105&r1=1533104&r2=1533105&view=diff
==============================================================================
--- apr/apr/branches/1.5.x/locks/os2/proc_mutex.c (original)
+++ apr/apr/branches/1.5.x/locks/os2/proc_mutex.c Thu Oct 17 15:10:11 2013
@@ -199,7 +199,7 @@ APR_DECLARE(apr_status_t) apr_proc_mutex
return APR_FROM_OS_ERROR(rc);
}
-
+APR_PERMS_SET_ENOTIMPL(proc_mutex)
APR_POOL_IMPLEMENT_ACCESSOR(proc_mutex)
Modified: apr/apr/branches/1.5.x/locks/unix/global_mutex.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.5.x/locks/unix/global_mutex.c?rev=1533105&r1=1533104&r2=1533105&view=diff
==============================================================================
--- apr/apr/branches/1.5.x/locks/unix/global_mutex.c (original)
+++ apr/apr/branches/1.5.x/locks/unix/global_mutex.c Thu Oct 17 15:10:11 2013
@@ -185,4 +185,13 @@ APR_DECLARE(const char *) apr_global_mut
return apr_proc_mutex_name(mutex->proc_mutex);
}
+APR_PERMS_SET_IMPLEMENT(global_mutex)
+{
+ apr_status_t rv;
+ apr_global_mutex_t *mutex = (apr_global_mutex_t *)theglobal_mutex;
+
+ rv = apr_proc_mutex_set_perms(mutex->proc_mutex, perms, uid, gid);
+ return rv;
+}
+
APR_POOL_IMPLEMENT_ACCESSOR(global_mutex)
Modified: apr/apr/branches/1.5.x/locks/unix/proc_mutex.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.5.x/locks/unix/proc_mutex.c?rev=1533105&r1=1533104&r2=1533105&view=diff
==============================================================================
--- apr/apr/branches/1.5.x/locks/unix/proc_mutex.c (original)
+++ apr/apr/branches/1.5.x/locks/unix/proc_mutex.c Thu Oct 17 15:10:11 2013
@@ -35,6 +35,17 @@ static apr_status_t proc_mutex_no_child_
}
#endif
+#if APR_HAS_POSIXSEM_SERIALIZE || APR_HAS_PROC_PTHREAD_SERIALIZE
+static apr_status_t proc_mutex_no_perms_set(apr_proc_mutex_t *mutex,
+ apr_fileperms_t perms,
+ apr_uid_t uid,
+ apr_gid_t gid)
+{
+ return APR_ENOTIMPL;
+}
+#endif
+
+
#if APR_HAS_POSIXSEM_SERIALIZE
#ifndef SEM_FAILED
@@ -183,6 +194,7 @@ static const apr_proc_mutex_unix_lock_me
proc_mutex_posix_release,
proc_mutex_posix_cleanup,
proc_mutex_no_child_init,
+ proc_mutex_no_perms_set,
"posixsem"
};
@@ -291,6 +303,24 @@ static apr_status_t proc_mutex_sysv_rele
return APR_SUCCESS;
}
+static apr_status_t proc_mutex_sysv_perms_set(apr_proc_mutex_t *mutex,
+ apr_fileperms_t perms,
+ apr_uid_t uid,
+ apr_gid_t gid)
+{
+
+ union semun ick;
+ struct semid_ds buf;
+ buf.sem_perm.uid = uid;
+ buf.sem_perm.gid = gid;
+ buf.sem_perm.mode = apr_unix_perms2mode(perms);
+ ick.buf = &buf;
+ if (semctl(mutex->interproc->filedes, 0, IPC_SET, ick) < 0) {
+ return errno;
+ }
+ return APR_SUCCESS;
+}
+
static const apr_proc_mutex_unix_lock_methods_t mutex_sysv_methods =
{
#if APR_PROCESS_LOCK_IS_GLOBAL || !APR_HAS_THREADS || defined(SYSVSEM_IS_GLOBAL)
@@ -304,6 +334,7 @@ static const apr_proc_mutex_unix_lock_me
proc_mutex_sysv_release,
proc_mutex_sysv_cleanup,
proc_mutex_no_child_init,
+ proc_mutex_sysv_perms_set,
"sysvsem"
};
@@ -499,6 +530,7 @@ static const apr_proc_mutex_unix_lock_me
proc_mutex_proc_pthread_release,
proc_mutex_proc_pthread_cleanup,
proc_mutex_no_child_init,
+ proc_mutex_no_perms_set,
"pthread"
};
@@ -620,6 +652,22 @@ static apr_status_t proc_mutex_fcntl_rel
return APR_SUCCESS;
}
+static apr_status_t proc_mutex_fcntl_perms_set(apr_proc_mutex_t *mutex,
+ apr_fileperms_t perms,
+ apr_uid_t uid,
+ apr_gid_t gid)
+{
+
+ if (mutex->fname) {
+ if (!(perms & APR_FPROT_GSETID))
+ gid = -1;
+ if (fchown(mutex->interproc->filedes, uid, gid) < 0) {
+ return errno;
+ }
+ }
+ return APR_SUCCESS;
+}
+
static const apr_proc_mutex_unix_lock_methods_t mutex_fcntl_methods =
{
#if APR_PROCESS_LOCK_IS_GLOBAL || !APR_HAS_THREADS || defined(FCNTL_IS_GLOBAL)
@@ -633,6 +681,7 @@ static const apr_proc_mutex_unix_lock_me
proc_mutex_fcntl_release,
proc_mutex_fcntl_cleanup,
proc_mutex_no_child_init,
+ proc_mutex_fcntl_perms_set,
"fcntl"
};
@@ -758,6 +807,22 @@ static apr_status_t proc_mutex_flock_chi
return APR_SUCCESS;
}
+static apr_status_t proc_mutex_flock_perms_set(apr_proc_mutex_t *mutex,
+ apr_fileperms_t perms,
+ apr_uid_t uid,
+ apr_gid_t gid)
+{
+
+ if (mutex->fname) {
+ if (!(perms & APR_FPROT_GSETID))
+ gid = -1;
+ if (fchown(mutex->interproc->filedes, uid, gid) < 0) {
+ return errno;
+ }
+ }
+ return APR_SUCCESS;
+}
+
static const apr_proc_mutex_unix_lock_methods_t mutex_flock_methods =
{
#if APR_PROCESS_LOCK_IS_GLOBAL || !APR_HAS_THREADS || defined(FLOCK_IS_GLOBAL)
@@ -771,6 +836,7 @@ static const apr_proc_mutex_unix_lock_me
proc_mutex_flock_release,
proc_mutex_flock_cleanup,
proc_mutex_flock_child_init,
+ proc_mutex_flock_perms_set,
"flock"
};
@@ -943,6 +1009,12 @@ APR_DECLARE(const char *) apr_proc_mutex
return NULL;
}
+APR_PERMS_SET_IMPLEMENT(proc_mutex)
+{
+ apr_proc_mutex_t *mutex = (apr_proc_mutex_t *)theproc_mutex;
+ return mutex->meth->perms_set(mutex, perms, uid, gid);
+}
+
APR_POOL_IMPLEMENT_ACCESSOR(proc_mutex)
/* Implement OS-specific accessors defined in apr_portable.h */
Modified: apr/apr/branches/1.5.x/locks/win32/proc_mutex.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.5.x/locks/win32/proc_mutex.c?rev=1533105&r1=1533104&r2=1533105&view=diff
==============================================================================
--- apr/apr/branches/1.5.x/locks/win32/proc_mutex.c (original)
+++ apr/apr/branches/1.5.x/locks/win32/proc_mutex.c Thu Oct 17 15:10:11 2013
@@ -199,6 +199,8 @@ APR_DECLARE(const char *) apr_proc_mutex
return "win32mutex";
}
+APR_PERMS_SET_ENOTIMPL(proc_mutex)
+
APR_POOL_IMPLEMENT_ACCESSOR(proc_mutex)
/* Implement OS-specific accessors defined in apr_portable.h */
Modified: apr/apr/branches/1.5.x/shmem/beos/shm.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.5.x/shmem/beos/shm.c?rev=1533105&r1=1533104&r2=1533105&view=diff
==============================================================================
--- apr/apr/branches/1.5.x/shmem/beos/shm.c (original)
+++ apr/apr/branches/1.5.x/shmem/beos/shm.c Thu Oct 17 15:10:11 2013
@@ -149,6 +149,8 @@ APR_DECLARE(apr_size_t) apr_shm_size_get
return m->reqsize;
}
+APR_PERMS_SET_ENOTIMPL(shm)
+
APR_POOL_IMPLEMENT_ACCESSOR(shm)
APR_DECLARE(apr_status_t) apr_os_shm_get(apr_os_shm_t *osshm,
Modified: apr/apr/branches/1.5.x/shmem/os2/shm.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.5.x/shmem/os2/shm.c?rev=1533105&r1=1533104&r2=1533105&view=diff
==============================================================================
--- apr/apr/branches/1.5.x/shmem/os2/shm.c (original)
+++ apr/apr/branches/1.5.x/shmem/os2/shm.c Thu Oct 17 15:10:11 2013
@@ -113,6 +113,8 @@ APR_DECLARE(apr_size_t) apr_shm_size_get
return size;
}
+APR_PERMS_SET_ENOTIMPL(shm)
+
APR_POOL_IMPLEMENT_ACCESSOR(shm)
APR_DECLARE(apr_status_t) apr_os_shm_get(apr_os_shm_t *osshm,
Modified: apr/apr/branches/1.5.x/shmem/unix/shm.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.5.x/shmem/unix/shm.c?rev=1533105&r1=1533104&r2=1533105&view=diff
==============================================================================
--- apr/apr/branches/1.5.x/shmem/unix/shm.c (original)
+++ apr/apr/branches/1.5.x/shmem/unix/shm.c Thu Oct 17 15:10:11 2013
@@ -15,6 +15,7 @@
*/
#include "apr_arch_shm.h"
+#include "apr_arch_file_io.h"
#include "apr_general.h"
#include "apr_errno.h"
@@ -102,7 +103,6 @@ APR_DECLARE(apr_status_t) apr_shm_create
#endif
#if APR_USE_SHMEM_SHMGET
apr_size_t nbytes;
- key_t shmkey;
#endif
#if APR_USE_SHMEM_MMAP_ZERO || APR_USE_SHMEM_SHMGET || \
APR_USE_SHMEM_MMAP_TMP || APR_USE_SHMEM_MMAP_SHM
@@ -175,8 +175,8 @@ APR_DECLARE(apr_status_t) apr_shm_create
new_m->reqsize = reqsize;
new_m->realsize = reqsize;
new_m->filename = NULL;
-
- if ((new_m->shmid = shmget(IPC_PRIVATE, new_m->realsize,
+ new_m->shmkey = IPC_PRIVATE;
+ if ((new_m->shmid = shmget(new_m->shmkey, new_m->realsize,
SHM_R | SHM_W | IPC_CREAT)) < 0) {
return errno;
}
@@ -312,13 +312,13 @@ APR_DECLARE(apr_status_t) apr_shm_create
/* ftok() (on solaris at least) requires that the file actually
* exist before calling ftok(). */
- shmkey = ftok(filename, 1);
- if (shmkey == (key_t)-1) {
+ new_m->shmkey = ftok(filename, 1);
+ if (new_m->shmkey == (key_t)-1) {
apr_file_close(file);
return errno;
}
- if ((new_m->shmid = shmget(shmkey, new_m->realsize,
+ if ((new_m->shmid = shmget(new_m->shmkey, new_m->realsize,
SHM_R | SHM_W | IPC_CREAT | IPC_EXCL)) < 0) {
apr_file_close(file);
return errno;
@@ -523,7 +523,6 @@ APR_DECLARE(apr_status_t) apr_shm_attach
apr_status_t status;
apr_file_t *file; /* file where metadata is stored */
apr_size_t nbytes;
- key_t shmkey;
new_m = apr_palloc(pool, sizeof(apr_shm_t));
@@ -546,11 +545,11 @@ APR_DECLARE(apr_status_t) apr_shm_attach
new_m->filename = apr_pstrdup(pool, filename);
new_m->pool = pool;
- shmkey = ftok(filename, 1);
- if (shmkey == (key_t)-1) {
+ new_m->shmkey = ftok(filename, 1);
+ if (new_m->shmkey == (key_t)-1) {
return errno;
}
- if ((new_m->shmid = shmget(shmkey, 0, SHM_R | SHM_W)) == -1) {
+ if ((new_m->shmid = shmget(new_m->shmkey, 0, SHM_R | SHM_W)) == -1) {
return errno;
}
if ((new_m->base = shmat(new_m->shmid, NULL, 0)) == (void *)-1) {
@@ -587,6 +586,28 @@ APR_DECLARE(apr_size_t) apr_shm_size_get
return m->reqsize;
}
+APR_PERMS_SET_IMPLEMENT(shm)
+{
+#if APR_USE_SHMEM_SHMGET || APR_USE_SHMEM_SHMGET_ANON
+ struct shmid_ds shmbuf;
+ int shmid;
+ apr_shm_t *m = (apr_shm_t *)theshm;
+
+ if ((shmid = shmget(m->shmkey, 0, SHM_R | SHM_W)) == -1) {
+ return errno;
+ }
+ shmbuf.shm_perm.uid = uid;
+ shmbuf.shm_perm.gid = gid;
+ shmbuf.shm_perm.mode = apr_unix_perms2mode(perms);
+ if (shmctl(shmid, IPC_SET, &shmbuf) == -1) {
+ return errno;
+ }
+ return APR_SUCCESS;
+#else
+ return APR_ENOTIMPL;
+#endif
+}
+
APR_POOL_IMPLEMENT_ACCESSOR(shm)
APR_DECLARE(apr_status_t) apr_os_shm_get(apr_os_shm_t *osshm,
Modified: apr/apr/branches/1.5.x/shmem/win32/shm.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.5.x/shmem/win32/shm.c?rev=1533105&r1=1533104&r2=1533105&view=diff
==============================================================================
--- apr/apr/branches/1.5.x/shmem/win32/shm.c (original)
+++ apr/apr/branches/1.5.x/shmem/win32/shm.c Thu Oct 17 15:10:11 2013
@@ -281,6 +281,8 @@ APR_DECLARE(apr_size_t) apr_shm_size_get
return m->length;
}
+APR_PERMS_SET_ENOTIMPL(shm)
+
APR_POOL_IMPLEMENT_ACCESSOR(shm)
APR_DECLARE(apr_status_t) apr_os_shm_get(apr_os_shm_t *osshm,
Modified: apr/apr/branches/1.5.x/strings/apr_cpystrn.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.5.x/strings/apr_cpystrn.c?rev=1533105&r1=1533104&r2=1533105&view=diff
==============================================================================
--- apr/apr/branches/1.5.x/strings/apr_cpystrn.c (original)
+++ apr/apr/branches/1.5.x/strings/apr_cpystrn.c Thu Oct 17 15:10:11 2013
@@ -38,6 +38,7 @@
* (3) Instead of returning the pointer to the beginning of
* the destination string, we return a pointer to the
* terminating '\0' to allow us to "check" for truncation
+ * (4) If src is NULL, null terminate dst (empty string copy)
*
* apr_cpystrn() follows the same call structure as strncpy().
*/
@@ -51,13 +52,15 @@ APR_DECLARE(char *) apr_cpystrn(char *ds
return (dst);
}
- d = dst;
- end = dst + dst_size - 1;
-
- for (; d < end; ++d, ++src) {
- if (!(*d = *src)) {
- return (d);
- }
+ if (src) {
+ d = dst;
+ end = dst + dst_size - 1;
+
+ for (; d < end; ++d, ++src) {
+ if (!(*d = *src)) {
+ return (d);
+ }
+ }
}
*d = '\0'; /* always null terminate */
Modified: apr/apr/branches/1.5.x/threadproc/beos/proc.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.5.x/threadproc/beos/proc.c?rev=1533105&r1=1533104&r2=1533105&view=diff
==============================================================================
--- apr/apr/branches/1.5.x/threadproc/beos/proc.c (original)
+++ apr/apr/branches/1.5.x/threadproc/beos/proc.c Thu Oct 17 15:10:11 2013
@@ -444,3 +444,11 @@ APR_DECLARE(apr_status_t) apr_procattr_g
{
return APR_ENOTIMPL;
}
+
+APR_DECLARE(apr_status_t) apr_procattr_perms_set_register(apr_procattr_t *attr,
+ apr_perms_setfn_t *perms_set_fn,
+ void *data,
+ apr_fileperms_t perms)
+{
+ return APR_ENOTIMPL;
+}
Modified: apr/apr/branches/1.5.x/threadproc/netware/proc.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.5.x/threadproc/netware/proc.c?rev=1533105&r1=1533104&r2=1533105&view=diff
==============================================================================
--- apr/apr/branches/1.5.x/threadproc/netware/proc.c (original)
+++ apr/apr/branches/1.5.x/threadproc/netware/proc.c Thu Oct 17 15:10:11 2013
@@ -505,3 +505,11 @@ APR_DECLARE(apr_status_t) apr_procattr_g
/* Always return SUCCESS because NetWare threads don't run within a group */
return APR_SUCCESS;
}
+
+APR_DECLARE(apr_status_t) apr_procattr_perms_set_register(apr_procattr_t *attr,
+ apr_perms_setfn_t *perms_set_fn,
+ void *data,
+ apr_fileperms_t perms)
+{
+ return APR_ENOTIMPL;
+}
Modified: apr/apr/branches/1.5.x/threadproc/os2/proc.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.5.x/threadproc/os2/proc.c?rev=1533105&r1=1533104&r2=1533105&view=diff
==============================================================================
--- apr/apr/branches/1.5.x/threadproc/os2/proc.c (original)
+++ apr/apr/branches/1.5.x/threadproc/os2/proc.c Thu Oct 17 15:10:11 2013
@@ -662,3 +662,11 @@ APR_DECLARE(apr_status_t) apr_procattr_g
{
return APR_ENOTIMPL;
}
+
+APR_DECLARE(apr_status_t) apr_procattr_perms_set_register(apr_procattr_t *attr,
+ apr_perms_setfn_t *perms_set_fn,
+ void *data,
+ apr_fileperms_t perms)
+{
+ return APR_ENOTIMPL;
+}
Modified: apr/apr/branches/1.5.x/threadproc/unix/proc.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.5.x/threadproc/unix/proc.c?rev=1533105&r1=1533104&r2=1533105&view=diff
==============================================================================
--- apr/apr/branches/1.5.x/threadproc/unix/proc.c (original)
+++ apr/apr/branches/1.5.x/threadproc/unix/proc.c Thu Oct 17 15:10:11 2013
@@ -461,7 +461,19 @@ APR_DECLARE(apr_status_t) apr_proc_creat
_exit(-1); /* We have big problems, the child should exit. */
}
}
+ if (!geteuid()) {
+ apr_procattr_pscb_t *c = attr->perms_set_callbacks;
+ while (c) {
+ apr_status_t r;
+ r = (*c->perms_set_fn)((void *)c->data, c->perms,
+ attr->uid, attr->gid);
+ if (r != APR_SUCCESS || r != APR_ENOTIMPL) {
+ _exit(-1);
+ }
+ c = c->next;
+ }
+ }
/* Only try to switch if we are running as root */
if (attr->gid != -1 && !geteuid()) {
if (setgid(attr->gid)) {
@@ -709,3 +721,20 @@ APR_DECLARE(apr_status_t) apr_procattr_l
}
#endif /* APR_HAVE_STRUCT_RLIMIT */
+APR_DECLARE(apr_status_t) apr_procattr_perms_set_register(apr_procattr_t *attr,
+ apr_perms_setfn_t *perms_set_fn,
+ void *data,
+ apr_fileperms_t perms)
+{
+ apr_procattr_pscb_t *c;
+
+ c = apr_palloc(attr->pool, sizeof(apr_procattr_pscb_t));
+ c->data = data;
+ c->perms = perms;
+ c->perms_set_fn = perms_set_fn;
+ c->next = attr->perms_set_callbacks;
+ attr->perms_set_callbacks = c;
+
+ return APR_SUCCESS;
+}
+
Modified: apr/apr/branches/1.5.x/threadproc/win32/proc.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.5.x/threadproc/win32/proc.c?rev=1533105&r1=1533104&r2=1533105&view=diff
==============================================================================
--- apr/apr/branches/1.5.x/threadproc/win32/proc.c (original)
+++ apr/apr/branches/1.5.x/threadproc/win32/proc.c Thu Oct 17 15:10:11 2013
@@ -1147,3 +1147,11 @@ APR_DECLARE(apr_status_t) apr_proc_detac
{
return APR_ENOTIMPL;
}
+
+APR_DECLARE(apr_status_t) apr_procattr_perms_set_register(apr_procattr_t *attr,
+ apr_perms_setfn_t *perms_set_fn,
+ void *data,
+ apr_fileperms_t perms)
+{
+ return APR_ENOTIMPL;
+}