]> granicus.if.org Git - apache/blob - os/unix/unixd.h
Introduce ap_(get|set)_core_module_config() functions/macros and use them
[apache] / os / unix / unixd.h
1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2  * contributor license agreements.  See the NOTICE file distributed with
3  * this work for additional information regarding copyright ownership.
4  * The ASF licenses this file to You under the Apache License, Version 2.0
5  * (the "License"); you may not use this file except in compliance with
6  * the License.  You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 /**
18  * @file  unixd.h
19  * @brief common stuff that unix MPMs will want 
20  *
21  * @addtogroup APACHE_OS_UNIX
22  * @{
23  */
24
25 #ifndef UNIXD_H
26 #define UNIXD_H
27
28 #include "httpd.h"
29 #include "http_config.h"
30 #include "ap_listen.h"
31 #ifdef HAVE_SYS_TIME_H
32 #include <sys/time.h>
33 #endif
34 #ifdef HAVE_SYS_RESOURCE_H
35 #include <sys/resource.h>
36 #endif
37 #include "apr_hooks.h"
38 #include "apr_thread_proc.h"
39 #include "apr_proc_mutex.h"
40 #include "apr_global_mutex.h"
41
42 #include <pwd.h>
43 #include <grp.h>
44 #if APR_HAVE_SYS_TYPES_H
45 #include <sys/types.h>
46 #endif
47 #ifdef HAVE_SYS_IPC_H
48 #include <sys/ipc.h>
49 #endif
50
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
54
55 typedef struct {
56     uid_t uid;
57     gid_t gid;
58     int userdir;
59 } ap_unix_identity_t;
60
61 AP_DECLARE_HOOK(ap_unix_identity_t *, get_suexec_identity,(const request_rec *r))
62
63
64 /* Default user name and group name. These may be specified as numbers by
65  * placing a # before a number */
66
67 #ifndef DEFAULT_USER
68 #define DEFAULT_USER "#-1"
69 #endif
70 #ifndef DEFAULT_GROUP
71 #define DEFAULT_GROUP "#-1"
72 #endif
73
74 typedef struct {
75     const char *user_name;
76     uid_t user_id;
77     gid_t group_id;
78     int suexec_enabled;
79     const char *chroot_dir;
80     const char *suexec_disabled_reason; /* suitable msg if !suexec_enabled */
81 } unixd_config_rec;
82 AP_DECLARE_DATA extern unixd_config_rec ap_unixd_config;
83
84 #if defined(RLIMIT_CPU) || defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_NPROC) || defined(RLIMIT_AS)
85 AP_DECLARE(void) ap_unixd_set_rlimit(cmd_parms *cmd, struct rlimit **plimit,
86                                      const char *arg, 
87                                      const char * arg2, int type);
88 #endif
89
90 /**
91  * One of the functions to set mutex permissions should be called in
92  * the parent process on platforms that switch identity when the 
93  * server is started as root.
94  * If the child init logic is performed before switching identity
95  * (e.g., MPM setup for an accept mutex), it should only be called
96  * for SysV semaphores.  Otherwise, it is safe to call it for all
97  * mutex types.
98  */
99 AP_DECLARE(apr_status_t) ap_unixd_set_proc_mutex_perms(apr_proc_mutex_t *pmutex);
100 AP_DECLARE(apr_status_t) ap_unixd_set_global_mutex_perms(apr_global_mutex_t *gmutex);
101 AP_DECLARE(apr_status_t) ap_unixd_accept(void **accepted, ap_listen_rec *lr, apr_pool_t *ptrans);
102
103 #ifdef HAVE_KILLPG
104 #define ap_unixd_killpg(x, y)   (killpg ((x), (y)))
105 #define ap_os_killpg(x, y)      (killpg ((x), (y)))
106 #else /* HAVE_KILLPG */
107 #define ap_unixd_killpg(x, y)   (kill (-(x), (y)))
108 #define ap_os_killpg(x, y)      (kill (-(x), (y)))
109 #endif /* HAVE_KILLPG */
110
111 #ifdef __cplusplus
112 }
113 #endif
114
115 #endif
116 /** @} */