- ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
- "No user or group set - set suPHP_UserGroup");
- return HTTP_INTERNAL_SERVER_ERROR;
+
+ /* Identify mod_userdir request
+ As Apache 1.3 does not yet provide a clean way to see
+ whether a request was handled by mod_userdir, we assume
+ this is true for any request beginning with ~ */
+
+ int ud_success = 0; /* set to 1 on success */
+
+ if (!strncmp("/~", r->uri, 2)) {
+ char *username = ap_pstrdup(r->pool, r->uri + 2);
+ char *pos = strchr(username, '/');
+ if (pos) {
+ *pos = 0;
+ if (strlen(username)) {
+ struct passwd *pw;
+ struct group *gr;
+ gid_t gid;
+ char *grpname;
+ if ((pw = getpwnam(username)) != NULL) {
+ gid = pw->pw_gid;
+
+ if ((gr = getgrgid(gid)) != NULL) {
+ grpname = gr->gr_name;
+ } else {
+ if ((grpname = ap_palloc(r->pool, 16)) == NULL) {
+ return HTTP_INTERNAL_SERVER_ERROR;
+ }
+ ap_snprintf(grpname, 16, "#%ld", (long) gid);
+ }
+
+ ud_user = username;
+ ud_group = grpname;
+ ud_success = 1;
+ }
+ }
+ }
+ }
+
+ if (!ud_success) {
+ /* This is not a userdir request and user/group are not
+ set, so log the error and return */
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
+ "No user or group set - set suPHP_UserGroup");
+ return HTTP_INTERNAL_SERVER_ERROR;
+ }