From fe14908713bfad7c116227c8c35d6ce76b0c1a72 Mon Sep 17 00:00:00 2001 From: Greg Brockman Date: Sun, 15 Aug 2010 10:51:37 -0400 Subject: [PATCH] Hard-code ~username for LDAP vhosts. Signed-off-by: Geoffrey Thomas Signed-off-by: Anders Kaseorg [gdb@mit.edu: Reimplement using mod_userdir] --- mod_vhost_ldap.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/mod_vhost_ldap.c b/mod_vhost_ldap.c index 0c78330..6bc67fc 100644 --- a/mod_vhost_ldap.c +++ b/mod_vhost_ldap.c @@ -51,6 +51,7 @@ #define MIN_UID 100 #define MIN_GID 100 +const char USERDIR[] = "web_scripts"; #define MAX_FAILURES 5 @@ -650,6 +651,30 @@ null: return HTTP_INTERNAL_SERVER_ERROR; } + if (reqc->uid != NULL) { + char *username; + char *userdir_val; + uid_t uid = (uid_t) atoll(reqc->uid); + + if ((code = reconfigure_directive(r->pool, server, "UserDir", USERDIR)) != 0) + return code; + + /* Deal with ~ expansion */ + if ((code = reconfigure_directive(r->pool, server, "UserDir", "disabled")) != 0) + return code; + + if (apr_uid_name_get(&username, uid, r->pool) != APR_SUCCESS) { + ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, 0, r, + "could not get username for uid %d", uid); + return HTTP_INTERNAL_SERVER_ERROR; + } + + userdir_val = apr_pstrcat(r->pool, "enabled ", username, (const char *)NULL); + + if ((code = reconfigure_directive(r->pool, server, "UserDir", userdir_val)) != 0) + return code; + } + ap_fixup_virtual_host(r->pool, r->server, server); r->server = server; -- 2.45.0