|
|
ad4e62 |
diff --git a/modules/md/mod_md_os.c b/modules/md/mod_md_os.c
|
|
|
ad4e62 |
index f96d566..8df0248 100644
|
|
|
ad4e62 |
--- a/modules/md/mod_md_os.c
|
|
|
ad4e62 |
+++ b/modules/md/mod_md_os.c
|
|
|
ad4e62 |
@@ -41,14 +41,20 @@
|
|
|
ad4e62 |
|
|
|
ad4e62 |
apr_status_t md_try_chown(const char *fname, unsigned int uid, int gid, apr_pool_t *p)
|
|
|
ad4e62 |
{
|
|
|
ad4e62 |
-#if AP_NEED_SET_MUTEX_PERMS
|
|
|
ad4e62 |
- if (-1 == chown(fname, (uid_t)uid, (gid_t)gid)) {
|
|
|
ad4e62 |
- apr_status_t rv = APR_FROM_OS_ERROR(errno);
|
|
|
ad4e62 |
- if (!APR_STATUS_IS_ENOENT(rv)) {
|
|
|
ad4e62 |
- ap_log_perror(APLOG_MARK, APLOG_ERR, rv, p, APLOGNO(10082)
|
|
|
ad4e62 |
- "Can't change owner of %s", fname);
|
|
|
ad4e62 |
+#if AP_NEED_SET_MUTEX_PERMS && HAVE_UNISTD_H
|
|
|
ad4e62 |
+ /* Since we only switch user when running as root, we only need to chown directories
|
|
|
ad4e62 |
+ * in that case. Otherwise, the server will ignore any "user/group" directives and
|
|
|
ad4e62 |
+ * child processes have the same privileges as the parent.
|
|
|
ad4e62 |
+ */
|
|
|
ad4e62 |
+ if (!geteuid()) {
|
|
|
ad4e62 |
+ if (-1 == chown(fname, (uid_t)uid, (gid_t)gid)) {
|
|
|
ad4e62 |
+ apr_status_t rv = APR_FROM_OS_ERROR(errno);
|
|
|
ad4e62 |
+ if (!APR_STATUS_IS_ENOENT(rv)) {
|
|
|
ad4e62 |
+ ap_log_perror(APLOG_MARK, APLOG_ERR, rv, p, APLOGNO(10082)
|
|
|
ad4e62 |
+ "Can't change owner of %s", fname);
|
|
|
ad4e62 |
+ }
|
|
|
ad4e62 |
+ return rv;
|
|
|
ad4e62 |
}
|
|
|
ad4e62 |
- return rv;
|
|
|
ad4e62 |
}
|
|
|
ad4e62 |
return APR_SUCCESS;
|
|
|
ad4e62 |
#else
|
|
|
ad4e62 |
@@ -58,11 +64,7 @@ apr_status_t md_try_chown(const char *fname, unsigned int uid, int gid, apr_pool
|
|
|
ad4e62 |
|
|
|
ad4e62 |
apr_status_t md_make_worker_accessible(const char *fname, apr_pool_t *p)
|
|
|
ad4e62 |
{
|
|
|
ad4e62 |
-#if AP_NEED_SET_MUTEX_PERMS
|
|
|
ad4e62 |
return md_try_chown(fname, ap_unixd_config.user_id, -1, p);
|
|
|
ad4e62 |
-#else
|
|
|
ad4e62 |
- return APR_ENOTIMPL;
|
|
|
ad4e62 |
-#endif
|
|
|
ad4e62 |
}
|
|
|
ad4e62 |
|
|
|
ad4e62 |
#ifdef WIN32
|