From 1705a1540030dd4199d116b53904b4aa4315f828 Mon Sep 17 00:00:00 2001 From: Justin Erenkrantz Date: Thu, 25 Apr 2002 07:18:40 +0000 Subject: [PATCH] Fix suexec invocations from userdir - the ~ was not being prepended to the uid per our convention. Therefore, bad things would happen (like we wouldn't cd to the right directory). Add a flag to the ap_unix_identity_t structure to indicate if we are in a userdir - if so, prefix the ~. (Modified by Justin, but Colm's patch pointed me in the right direction.) PR: 7810 Submitted by: Colm Reviewed by: Justin Erenkrantz git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@94791 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 3 +++ modules/generators/mod_suexec.c | 1 + modules/mappers/mod_userdir.c | 1 + os/unix/unixd.c | 7 ++++++- os/unix/unixd.h | 1 + 5 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 4054518ecc..8b0cf39c73 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,8 @@ Changes with Apache 2.0.36 + *) Fix suexec behavior with user directories. PR 7810. + [Colm ] + *) Reject a blank UserDir directive since it is ambiguous. PR 8472. [Justin Erenkrantz] diff --git a/modules/generators/mod_suexec.c b/modules/generators/mod_suexec.c index 14d87ae9e0..7057773ca8 100644 --- a/modules/generators/mod_suexec.c +++ b/modules/generators/mod_suexec.c @@ -110,6 +110,7 @@ static const char *set_suexec_ugid(cmd_parms *cmd, void *mconfig, if (unixd_config.suexec_enabled) { cfg->ugid.uid = ap_uname2id(uid); cfg->ugid.gid = ap_gname2id(gid); + cfg->ugid.userdir = 0; cfg->active = 1; } else { diff --git a/modules/mappers/mod_userdir.c b/modules/mappers/mod_userdir.c index 151ac35920..d8b36fdfb0 100644 --- a/modules/mappers/mod_userdir.c +++ b/modules/mappers/mod_userdir.c @@ -379,6 +379,7 @@ static ap_unix_identity_t *get_suexec_id_doer(const request_rec *r) return NULL; } + ugid->userdir = 1; #endif return ugid; } diff --git a/os/unix/unixd.c b/os/unix/unixd.c index b0f927a4ba..5b655d36e4 100644 --- a/os/unix/unixd.c +++ b/os/unix/unixd.c @@ -331,7 +331,12 @@ static apr_status_t ap_unix_create_privileged_process( return apr_proc_create(newproc, progname, args, env, attr, p); } - execuser = apr_psprintf(p, "%ld", (long) ugid->uid); + if (ugid->userdir) { + execuser = apr_psprintf(p, "~%ld", (long) ugid->uid); + } + else { + execuser = apr_psprintf(p, "%ld", (long) ugid->uid); + } execgroup = apr_psprintf(p, "%ld", (long) ugid->gid); if (!execuser || !execgroup) { diff --git a/os/unix/unixd.h b/os/unix/unixd.h index ec77762433..144cdf979f 100644 --- a/os/unix/unixd.h +++ b/os/unix/unixd.h @@ -84,6 +84,7 @@ typedef struct { uid_t uid; gid_t gid; + int userdir; } ap_unix_identity_t; AP_DECLARE_HOOK(ap_unix_identity_t *, get_suexec_identity,(const request_rec *r)) -- 2.40.0