]>
Commit | Line | Data |
---|---|---|
5391c623 AM |
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 | |
4 | @@ -756,6 +756,7 @@ | |
5 | static void reduce_privileges(void) | |
6 | { | |
7 | const char *name; | |
8 | + int have_user_name = 1; | |
9 | ||
10 | if (geteuid() != 0) | |
11 | return; | |
12 | @@ -767,16 +768,23 @@ | |
13 | struct passwd *ent = getpwuid(uid); | |
14 | ||
15 | if (ent == NULL) { | |
16 | + have_user_name = 0; | |
17 | + name = &ap_user_name[1]; | |
18 | + if (name == NULL) { | |
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); | |
22 | exit(1); | |
23 | - } | |
24 | - name = ent->pw_name; | |
25 | + } | |
26 | + } else | |
27 | + name = ent->pw_name; | |
28 | } | |
29 | else | |
30 | name = ap_user_name; | |
31 | ||
32 | + ap_log_error(FCGI_LOG_ALERT, fcgi_apache_main_server, "name=[%s]", name); | |
33 | + | |
34 | + | |
35 | /* Change Group */ | |
36 | if (setgid(ap_group_id) == -1) { | |
37 | ap_log_error(FCGI_LOG_ALERT, fcgi_apache_main_server, | |
38 | @@ -787,7 +795,7 @@ | |
39 | /* See Apache PR2580. Until its resolved, do it the same way CGI is done.. */ | |
40 | ||
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); | |
50 | if (!pw) { | |
ce665460 | 51 | + s->username = apr_psprintf(sp, "%ld", (long)s->uid); |
5391c623 AM |
52 | + /* |
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); | |
56 | goto BagNewServer; | |
57 | - } | |
58 | + */ | |
59 | + } else | |
ce665460 AM |
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); | |
5391c623 AM |
63 | |
64 | s->gid = (gid_t)atol(group); | |
ce665460 | 65 | s->group = apr_pstrdup(sp, group); |
5391c623 AM |
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 | |
69 | @@ -462,23 +462,27 @@ | |
70 | s->uid = uid; | |
71 | pw = getpwuid(uid); | |
72 | if (pw == NULL) { | |
ce665460 | 73 | + s->user = apr_psprintf(p, "%ld", uid); |
5391c623 | 74 | + if (s->user == NULL) |
ce665460 | 75 | return apr_psprintf(p, |
5391c623 AM |
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)); | |
79 | - } | |
ce665460 | 80 | - s->user = apr_pstrdup(p, pw->pw_name); |
5391c623 | 81 | + } else |
ce665460 | 82 | + s->user = apr_pstrdup(p, pw->pw_name); |
5391c623 AM |
83 | s->username = s->user; |
84 | ||
85 | s->gid = gid; | |
86 | gr = getgrgid(gid); | |
87 | if (gr == NULL) { | |
ce665460 | 88 | + s->group = apr_psprintf(p, "%ld", gid); |
5391c623 | 89 | + if (s->group == NULL) |
ce665460 | 90 | return apr_psprintf(p, |
5391c623 AM |
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)); | |
94 | - } | |
ce665460 | 95 | - s->group = apr_pstrdup(p, gr->gr_name); |
5391c623 | 96 | + } else |
ce665460 | 97 | + s->group = apr_pstrdup(p, gr->gr_name); |
5391c623 AM |
98 | |
99 | #endif /* !WIN32 */ | |
100 |