- work with uid/gid only, too (so entries in passwd/group no longer needed)
[packages/apache1-mod_fastcgi.git] / apache-mod_fastcgi-allow-uid-gid.patch
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) {
51 +                       s->username = ap_psprintf(sp, "%ld", (long)s->uid);
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
60 +                       s->username = ap_pstrdup(sp, pw->pw_name);
61                      s->user = ap_pstrdup(sp, user);
62 -                    s->username = ap_pstrdup(sp, pw->pw_name);
63  
64                      s->gid = (gid_t)atol(group);
65                      s->group = ap_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
69 @@ -462,23 +462,27 @@
70      s->uid = uid;
71      pw = getpwuid(uid);
72      if (pw == NULL) {
73 +       s->user = ap_psprintf(p, "%ld", uid);
74 +       if (s->user == NULL)
75          return ap_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));
79 -    }
80 -    s->user = ap_pstrdup(p, pw->pw_name);
81 +    } else
82 +       s->user = ap_pstrdup(p, pw->pw_name);
83      s->username = s->user;
84  
85      s->gid = gid;
86      gr = getgrgid(gid);
87      if (gr == NULL) {
88 +       s->group = ap_psprintf(p, "%ld", gid);
89 +       if (s->group == NULL)
90          return ap_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));
94 -    }
95 -    s->group = ap_pstrdup(p, gr->gr_name);
96 +    } else
97 +       s->group = ap_pstrdup(p, gr->gr_name);
98  
99  #endif /* !WIN32 */
100  
This page took 0.041618 seconds and 3 git commands to generate.