1 diff -urN mod_fastcgi-2.4.2.org/fcgi_pm.c mod_fastcgi-2.4.2/fcgi_pm.c
2 --- mod_fastcgi-2.4.2.org/fcgi_pm.c 2004-03-07 18:43:25.801230680 +0100
3 +++ mod_fastcgi-2.4.2/fcgi_pm.c 2004-03-07 22:39:30.635790455 +0100
5 static void reduce_privileges(void)
8 + int have_user_name = 1;
13 struct passwd *ent = getpwuid(uid);
17 + name = &ap_user_name[1];
19 ap_log_error(FCGI_LOG_ALERT, fcgi_apache_main_server,
20 "FastCGI: process manager exiting, getpwuid(%u) couldn't determine user name, "
21 "you probably need to modify the User directive", (unsigned)uid);
24 - name = ent->pw_name;
27 + name = ent->pw_name;
32 + ap_log_error(FCGI_LOG_ALERT, fcgi_apache_main_server, "name=[%s]", name);
36 if (setgid(ap_group_id) == -1) {
37 ap_log_error(FCGI_LOG_ALERT, fcgi_apache_main_server,
39 /* See Apache PR2580. Until its resolved, do it the same way CGI is done.. */
41 /* Initialize supplementary groups */
42 - if (initgroups(name, ap_group_id) == -1) {
43 + if (have_user_name && initgroups(name, ap_group_id) == -1) {
44 ap_log_error(FCGI_LOG_ALERT, fcgi_apache_main_server,
45 "FastCGI: process manager exiting, initgroups(%s,%u) failed",
46 name, (unsigned)ap_group_id);
47 @@ -1132,13 +1140,16 @@
48 s->uid = (uid_t)atol(user);
49 pw = getpwuid(s->uid);
51 + s->username = apr_psprintf(sp, "%ld", (long)s->uid);
53 ap_log_error(FCGI_LOG_CRIT, fcgi_apache_main_server,
54 "FastCGI: can't create (dynamic) server \"%s\": can't get uid/gid for wrapper: getwpuid(%ld) failed",
55 execName, (long)s->uid);
60 + s->username = apr_pstrdup(sp, pw->pw_name);
61 s->user = apr_pstrdup(sp, user);
62 - s->username = apr_pstrdup(sp, pw->pw_name);
64 s->gid = (gid_t)atol(group);
65 s->group = apr_pstrdup(sp, group);
66 diff -urN mod_fastcgi-2.4.2.org/fcgi_util.c mod_fastcgi-2.4.2/fcgi_util.c
67 --- mod_fastcgi-2.4.2.org/fcgi_util.c 2004-03-07 18:43:25.803230257 +0100
68 +++ mod_fastcgi-2.4.2/fcgi_util.c 2004-03-07 22:39:30.637790026 +0100
73 + s->user = apr_psprintf(p, "%ld", uid);
74 + if (s->user == NULL)
75 return apr_psprintf(p,
76 "getpwuid() couldn't determine the username for uid '%ld', "
77 "you probably need to modify the User directive: %s",
78 (long)uid, strerror(errno));
80 - s->user = apr_pstrdup(p, pw->pw_name);
82 + s->user = apr_pstrdup(p, pw->pw_name);
83 s->username = s->user;
88 + s->group = apr_psprintf(p, "%ld", gid);
89 + if (s->group == NULL)
90 return apr_psprintf(p,
91 "getgrgid() couldn't determine the group name for gid '%ld', "
92 "you probably need to modify the Group directive: %s",
93 (long)gid, strerror(errno));
95 - s->group = apr_pstrdup(p, gr->gr_name);
97 + s->group = apr_pstrdup(p, gr->gr_name);