|
Line 0
Link Here
|
|
|
1 |
--- fcgi_util.c.orig 2009-07-08 17:16:29.816884000 +0800 |
| 2 |
+++ fcgi_util.c 2009-07-09 08:43:09.222180000 +0800 |
| 3 |
@@ -268,13 +268,17 @@ |
| 4 |
/* Get the user membership for the file's group. If the |
| 5 |
* uid is a member, check the group bits. */ |
| 6 |
{ |
| 7 |
- const struct group * const gr = getgrgid(statBuf->st_gid); |
| 8 |
- const struct passwd * const pw = getpwuid(uid); |
| 9 |
+ char buf[1024], buf2[1024]; |
| 10 |
+ struct group gr, *r; |
| 11 |
+ struct passwd pw, *r2; |
| 12 |
|
| 13 |
- if (gr != NULL && pw != NULL) { |
| 14 |
- char **user = gr->gr_mem; |
| 15 |
+ getgrgid_r(statBuf->st_gid, &gr, buf, sizeof(buf), &r); |
| 16 |
+ getpwuid_r(uid, &pw, buf2, sizeof(buf2), &r2); |
| 17 |
+ |
| 18 |
+ if (r != NULL && r2 != NULL) { |
| 19 |
+ char **user = r->gr_mem; |
| 20 |
for ( ; *user != NULL; user++) { |
| 21 |
- if (strcmp(*user, pw->pw_name) == 0) { |
| 22 |
+ if (strcmp(*user, r2->pw_name) == 0) { |
| 23 |
if (mode & R_OK && !(statBuf->st_mode & S_IRGRP)) |
| 24 |
return "read not allowed by group"; |
| 25 |
if (mode & W_OK && !(statBuf->st_mode & S_IWGRP)) |
| 26 |
@@ -445,8 +449,9 @@ |
| 27 |
{ |
| 28 |
#ifndef WIN32 |
| 29 |
|
| 30 |
+ char buf[1024]; |
| 31 |
struct passwd *pw; |
| 32 |
- struct group *gr; |
| 33 |
+ struct group gr, *r; |
| 34 |
|
| 35 |
if (fcgi_wrapper == NULL) |
| 36 |
return NULL; |
| 37 |
@@ -467,14 +472,14 @@ |
| 38 |
s->username = s->user; |
| 39 |
|
| 40 |
s->gid = gid; |
| 41 |
- gr = getgrgid(gid); |
| 42 |
- if (gr == NULL) { |
| 43 |
+ getgrgid_r(gid, &gr, buf, sizeof(buf), &r); |
| 44 |
+ if (r == NULL) { |
| 45 |
return ap_psprintf(p, |
| 46 |
"getgrgid() couldn't determine the group name for gid '%ld', " |
| 47 |
"you probably need to modify the Group directive: %s", |
| 48 |
(long)gid, strerror(errno)); |
| 49 |
} |
| 50 |
- s->group = ap_pstrdup(p, gr->gr_name); |
| 51 |
+ s->group = ap_pstrdup(p, r->gr_name); |
| 52 |
|
| 53 |
#endif /* !WIN32 */ |
| 54 |
|