mirror of
https://github.com/apache/httpd.git
synced 2025-07-25 17:01:22 +00:00
Make mod_cgi and mod_include work when compiled as DSO's again. This is
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
This commit is contained in:
@ -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;
|
||||
|
@ -101,7 +101,7 @@
|
||||
#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>
|
||||
|
@ -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
|
||||
|
@ -62,6 +62,10 @@
|
||||
#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);
|
||||
}
|
||||
|
||||
|
@ -64,6 +64,20 @@
|
||||
#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 */
|
||||
|
||||
|
Reference in New Issue
Block a user