Apache2
unixd.h
Go to the documentation of this file.
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 
25 #ifndef UNIXD_H
26 #define UNIXD_H
27 
28 #include "httpd.h"
29 #include "http_config.h"
30 #include "scoreboard.h"
31 #include "ap_listen.h"
32 #ifdef HAVE_SYS_TIME_H
33 #include <sys/time.h>
34 #endif
35 #ifdef HAVE_SYS_RESOURCE_H
36 #include <sys/resource.h>
37 #endif
38 #include "apr_hooks.h"
39 #include "apr_thread_proc.h"
40 #include "apr_proc_mutex.h"
41 #include "apr_global_mutex.h"
42 
43 #include <pwd.h>
44 #include <grp.h>
45 #if APR_HAVE_SYS_TYPES_H
46 #include <sys/types.h>
47 #endif
48 #ifdef HAVE_SYS_IPC_H
49 #include <sys/ipc.h>
50 #endif
51 
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55 
56 typedef struct {
57  uid_t uid;
58  gid_t gid;
59  int userdir;
61 
63 
64 
65 /* Default user name and group name. These may be specified as numbers by
66  * placing a # before a number */
67 
68 #ifndef DEFAULT_USER
69 #define DEFAULT_USER "#-1"
70 #endif
71 #ifndef DEFAULT_GROUP
72 #define DEFAULT_GROUP "#-1"
73 #endif
74 
75 typedef struct {
76  const char *user_name;
77  const char *group_name;
78  uid_t user_id;
79  gid_t group_id;
81  const char *chroot_dir;
82  const char *suexec_disabled_reason; /* suitable msg if !suexec_enabled */
85 
86 #if defined(RLIMIT_CPU) || defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_NPROC) || defined(RLIMIT_AS)
87 AP_DECLARE(void) ap_unixd_set_rlimit(cmd_parms *cmd, struct rlimit **plimit,
88  const char *arg,
89  const char * arg2, int type);
90 #endif
91 
104 
105 #ifdef HAVE_KILLPG
106 #define ap_unixd_killpg(x, y) (killpg ((x), (y)))
107 #define ap_os_killpg(x, y) (killpg ((x), (y)))
108 #else /* HAVE_KILLPG */
109 #define ap_unixd_killpg(x, y) (kill (-(x), (y)))
110 #define ap_os_killpg(x, y) (kill (-(x), (y)))
111 #endif /* HAVE_KILLPG */
112 
113 typedef struct {
114  void *baton; /* MPM's */
115 
116  /* volatile because they're updated from signals' handlers */
117  int volatile mpm_state;
118  int volatile shutdown_pending;
119  int volatile restart_pending;
120  int volatile is_ungraceful;
121 
125 
126  /*
127  * Current number of listeners buckets and maximum reached across
128  * restarts (to size retained data according to dynamic num_buckets,
129  * eg. idle_spawn_rate).
130  */
131  int num_buckets, max_buckets;
133 
135 AP_DECLARE(void) ap_unixd_mpm_set_signals(apr_pool_t *pconf, int once_process);
136 
137 #ifdef __cplusplus
138 }
139 #endif
140 
141 #endif
#define AP_DECLARE_HOOK(ret, name, args)
Definition: ap_hooks.h:74
Apache Listeners Library.
APR Global Locking Routines.
Apache hook functions.
APR Process Locking Routines.
APR Thread and Process Library.
ap_unix_identity_t * get_suexec_identity(const request_rec *r)
apr_status_t ap_unixd_accept(void **accepted, ap_listen_rec *lr, apr_pool_t *ptrans)
ap_unixd_mpm_retained_data * ap_unixd_mpm_get_retained_data(void)
apr_status_t ap_unixd_set_proc_mutex_perms(apr_proc_mutex_t *pmutex)
apr_status_t ap_unixd_set_global_mutex_perms(apr_global_mutex_t *gmutex)
AP_DECLARE_DATA unixd_config_rec ap_unixd_config
void ap_unixd_mpm_set_signals(apr_pool_t *pconf, int once_process)
request_rec * r
Definition: mod_dav.h:518
int apr_status_t
Definition: apr_errno.h:44
struct apr_pool_t apr_pool_t
Definition: apr_pools.h:60
Apache Configuration.
HTTP Daemon routines.
#define AP_DECLARE_DATA
Definition: macros.h:15
#define AP_DECLARE(x)
Definition: macros.h:1
Apache scoreboard library.
int ap_generation_t
Definition: scoreboard.h:78
Apache's listeners record.
Definition: ap_listen.h:54
Definition: unixd.h:56
uid_t uid
Definition: unixd.h:57
int userdir
Definition: unixd.h:59
gid_t gid
Definition: unixd.h:58
Definition: unixd.h:113
int volatile is_ungraceful
Definition: unixd.h:120
int was_graceful
Definition: unixd.h:124
int volatile restart_pending
Definition: unixd.h:119
int module_loads
Definition: unixd.h:123
int max_buckets
Definition: unixd.h:131
void * baton
Definition: unixd.h:114
int volatile mpm_state
Definition: unixd.h:117
ap_generation_t my_generation
Definition: unixd.h:122
int volatile shutdown_pending
Definition: unixd.h:118
Definition: apr_arch_global_mutex.h:23
Definition: apr_arch_proc_mutex.h:27
Definition: http_config.h:288
A structure that represents the current request.
Definition: httpd.h:856
Definition: unixd.h:75
const char * group_name
Definition: unixd.h:77
uid_t user_id
Definition: unixd.h:78
const char * chroot_dir
Definition: unixd.h:81
const char * user_name
Definition: unixd.h:76
int suexec_enabled
Definition: unixd.h:80
const char * suexec_disabled_reason
Definition: unixd.h:82
gid_t group_id
Definition: unixd.h:79