You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by pq...@apache.org on 2008/10/30 01:54:03 UTC
svn commit: r709062 - in /httpd/httpd/trunk/server/mpm/simple: simple_api.c
simple_api.h simple_run.c
Author: pquerna
Date: Wed Oct 29 17:54:02 2008
New Revision: 709062
URL: http://svn.apache.org/viewvc?rev=709062&view=rev
Log:
Create a new drop_privileges hook for the Simple MPM.
Added:
httpd/httpd/trunk/server/mpm/simple/simple_api.h (with props)
Modified:
httpd/httpd/trunk/server/mpm/simple/simple_api.c
httpd/httpd/trunk/server/mpm/simple/simple_run.c
Modified: httpd/httpd/trunk/server/mpm/simple/simple_api.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/simple/simple_api.c?rev=709062&r1=709061&r2=709062&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/simple/simple_api.c (original)
+++ httpd/httpd/trunk/server/mpm/simple/simple_api.c Wed Oct 29 17:54:02 2008
@@ -25,6 +25,7 @@
#include "simple_types.h"
#include "simple_run.h"
#include "http_core.h"
+#include "simple_api.h"
/* Thie file contains the absolute minimal MPM API, to interface with httpd. */
@@ -32,6 +33,13 @@
server_rec *ap_server_conf = NULL;
+APR_HOOK_STRUCT(
+ APR_HOOK_LINK(simple_drop_privileges)
+)
+
+AP_IMPLEMENT_HOOK_RUN_ALL(int, simple_drop_privileges,
+ (apr_pool_t *pchild, server_rec *s),
+ (pchild, s), OK, DECLINED)
int
ap_mpm_run(apr_pool_t *pconf,
Added: httpd/httpd/trunk/server/mpm/simple/simple_api.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/simple/simple_api.h?rev=709062&view=auto
==============================================================================
--- httpd/httpd/trunk/server/mpm/simple/simple_api.h (added)
+++ httpd/httpd/trunk/server/mpm/simple/simple_api.h Wed Oct 29 17:54:02 2008
@@ -0,0 +1,43 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "apr.h"
+#include "apr_pools.h"
+#include "apr_poll.h"
+#include "apr_hash.h"
+#include "apr_ring.h"
+#include "apr_thread_pool.h"
+#include "apr_buckets.h"
+#include "httpd.h"
+
+#ifndef APACHE_MPM_SIMPLE_API_H
+#define APACHE_MPM_SIMPLE_API_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Called after child as forked, before child_init, to be used by modules that
+ * wish to chroot or change the processes running UserID before we begin serving requests.
+ */
+AP_DECLARE_HOOK(int,simple_drop_privileges,(apr_pool_t *pchild, server_rec *s))
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* APACHE_MPM_SIMPLE_API_H */
+
Propchange: httpd/httpd/trunk/server/mpm/simple/simple_api.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: httpd/httpd/trunk/server/mpm/simple/simple_api.h
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: httpd/httpd/trunk/server/mpm/simple/simple_api.h
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: httpd/httpd/trunk/server/mpm/simple/simple_run.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/simple/simple_run.c?rev=709062&r1=709061&r2=709062&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/simple/simple_run.c (original)
+++ httpd/httpd/trunk/server/mpm/simple/simple_run.c Wed Oct 29 17:54:02 2008
@@ -27,7 +27,7 @@
#include "scoreboard.h"
#include "ap_listen.h"
-
+#include "simple_api.h"
#include "mpm.h"
/**
@@ -269,7 +269,14 @@
/* TODO: none of the above. Just a child_init hook, which can be
* instantianted in a module
*/
- ap_run_child_init(sc->pool, ap_server_conf);
+ int rv = ap_run_simple_drop_privileges(sc->pool, ap_server_conf);
+
+ if (rv) {
+ ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL,
+ "simple_setup_privs: ap_run_simple_drop_privileges failed");
+ return rv;
+ }
+
return 0;
}
@@ -299,6 +306,8 @@
return !OK;
}
+ ap_run_child_init(sc->pool, ap_server_conf);
+
return simple_run_loop(sc);
}