]> granicus.if.org Git - apache/commitdiff
Make mod_cgi and mod_include work when compiled as DSO's again. This is
authorRyan Bloom <rbb@apache.org>
Tue, 31 Oct 2000 00:47:24 +0000 (00:47 +0000)
committerRyan Bloom <rbb@apache.org>
Tue, 31 Oct 2000 00:47:24 +0000 (00:47 +0000)
accomplished by moving suexec out of it's own file and into unixd.[ch].
The problem was that suexec.c wasn't being linked into the server unless
a module was actually using ap_os_create_process.  This is still not clean,
but it works now.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@86772 13f79535-47bb-0310-9956-ffa450edef68

modules/generators/mod_suexec.c
modules/mappers/mod_userdir.c
os/unix/Makefile.in
os/unix/unixd.c
os/unix/unixd.h

index f33ed77d14c18055e1a52cb1e9351831c5ebd151..b03e27f67966033af7e971aaead075cb403ff860 100644 (file)
@@ -61,7 +61,6 @@
 #include "http_core.h"
 #include "http_request.h"
 #include "apr_strings.h"
-#include "suexec.h"
 #include "unixd.h"
 
 module MODULE_VAR_EXPORT suexec_module;
index 308f3798c43e790d20cb7065e5d50c4707cbc796..cec849bd39245a317868f60a482e808407bd4fbb 100644 (file)
 #include "http_config.h"
 #include "http_request.h"
 #ifdef HAVE_UNIX_SUEXEC
-#include "suexec.h"        /* Contains the suexec_identity hook used on Unix */
+#include "unixd.h"        /* Contains the suexec_identity hook used on Unix */
 #endif
 #ifdef HAVE_PWD_H
 #include <pwd.h>
index 521f2984640f527dd0505c105341b3c54c27242e..63596967db125f6ceb5798cf56a04b7465f5309c 100644 (file)
@@ -1,5 +1,5 @@
 
 LTLIBRARY_NAME    = libos.la
-LTLIBRARY_SOURCES = os-inline.c unixd.c suexec.c
+LTLIBRARY_SOURCES = os-inline.c unixd.c
 
 include $(top_srcdir)/build/ltlib.mk
index d70b3fd5ccb826db455bbd38067d5e09f2a6bba8..1b8a465ab857a718d2da2b28f13afeae0b543f8f 100644 (file)
 #include "http_main.h"
 #include "http_log.h"
 #include "unixd.h"
+#include "os.h"
+#include "ap_mpm.h"
+#include "apr_thread_proc.h"
+#include "apr_strings.h"
 #ifdef HAVE_PWD_H
 #include <pwd.h>
 #endif
@@ -414,3 +418,68 @@ AP_DECLARE(void) unixd_set_rlimit(cmd_parms *cmd, struct rlimit **plimit,
 #endif
 }
 
+AP_HOOK_STRUCT(
+               AP_HOOK_LINK(get_suexec_identity)
+)
+
+AP_IMPLEMENT_HOOK_RUN_FIRST(ap_unix_identity_t *, get_suexec_identity,
+                         (const request_rec *r), (r), NULL)
+
+static apr_status_t ap_unix_create_privileged_process(
+                              apr_proc_t *newproc, const char *progname,
+                              char *const *args, char **env,
+                              apr_procattr_t *attr, ap_unix_identity_t *ugid,
+                              apr_pool_t *p)
+{
+    int i = 0;
+    char **newargs;
+    char *newprogname;
+    char *execuser, *execgroup;
+
+    if (!unixd_config.suexec_enabled) {
+        return apr_create_process(newproc, progname, args, env, attr, p);
+    }
+
+    execuser = apr_psprintf(p, "%ld", (long) ugid->uid);
+    execgroup = apr_psprintf(p, "%ld", (long) ugid->gid);
+
+    if (!execuser || !execgroup) {
+        return APR_ENOMEM;
+    }
+
+    i = 0;
+    if (args) {
+        while (args[i]) {
+            i++;
+           }
+    }
+    newargs = apr_palloc(p, sizeof(char *) * (i + 4));
+    newprogname = SUEXEC_BIN;
+    newargs[0] = SUEXEC_BIN;
+    newargs[1] = execuser;
+    newargs[2] = execgroup;
+    newargs[3] = apr_pstrdup(p, progname);
+
+    i = 0;
+    do {
+        newargs[i + 4] = args[i];
+    } while (args[i++]);
+
+    return apr_create_process(newproc, newprogname, newargs, env, attr, p);
+}
+
+AP_DECLARE(apr_status_t) ap_os_create_privileged_process(const request_rec *r,
+                              apr_proc_t *newproc, const char *progname,
+                              char *const *args, char **env,
+                              apr_procattr_t *attr, apr_pool_t *p)
+{
+    ap_unix_identity_t *ugid = ap_run_get_suexec_identity(r);
+
+    if (ugid == NULL) {
+        return apr_create_process(newproc, progname, args, env, attr, p);
+    }
+
+    return ap_unix_create_privileged_process(newproc, progname, args, env,
+                                              attr, ugid, p);
+}
+
index d8ac46f87bae6e8a57f6136e41bcadff8f511ca3..9bf16f8154744e542d29c97a56bc0ed6bbdb604f 100644 (file)
 #ifdef HAVE_SYS_RESOURCE_H
 #include <sys/resource.h>
 #endif
+#include "ap_hooks.h"
+#include "apr_thread_proc.h"
+
+#include <pwd.h>
+#include <grp.h>
+#include <sys/types.h>
+
+typedef struct {
+    uid_t uid;
+    gid_t gid;
+} ap_unix_identity_t;
+
+AP_DECLARE_HOOK(ap_unix_identity_t *, get_suexec_identity,(const request_rec *r)
+)
 
 /* common stuff that unix MPMs will want */