upload http
[bottlenecks.git] / rubbos / app / httpd-2.0.64 / 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 #ifndef UNIXD_H
18 #define UNIXD_H
19
20 #include "httpd.h"
21 #include "http_config.h"
22 #include "ap_listen.h"
23 #ifdef HAVE_SYS_TIME_H
24 #include <sys/time.h>
25 #endif
26 #ifdef HAVE_SYS_RESOURCE_H
27 #include <sys/resource.h>
28 #endif
29 #include "apr_hooks.h"
30 #include "apr_thread_proc.h"
31 #include "apr_proc_mutex.h"
32 #include "apr_global_mutex.h"
33
34 #include <pwd.h>
35 #include <grp.h>
36 #ifdef APR_HAVE_SYS_TYPES_H
37 #include <sys/types.h>
38 #endif
39 #ifdef HAVE_SYS_IPC_H
40 #include <sys/ipc.h>
41 #endif
42
43 typedef struct {
44     uid_t uid;
45     gid_t gid;
46     int userdir;
47 } ap_unix_identity_t;
48
49 AP_DECLARE_HOOK(ap_unix_identity_t *, get_suexec_identity,(const request_rec *r))
50
51 /* common stuff that unix MPMs will want */
52
53 /* Default user name and group name. These may be specified as numbers by
54  * placing a # before a number */
55
56 #ifndef DEFAULT_USER
57 #define DEFAULT_USER "#-1"
58 #endif
59 #ifndef DEFAULT_GROUP
60 #define DEFAULT_GROUP "#-1"
61 #endif
62
63 typedef struct {
64     const char *user_name;
65     uid_t user_id;
66     gid_t group_id;
67     int suexec_enabled;
68 } unixd_config_rec;
69 AP_DECLARE_DATA extern unixd_config_rec unixd_config;
70
71 AP_DECLARE(int) unixd_setup_child(void);
72 AP_DECLARE(void) unixd_pre_config(apr_pool_t *ptemp);
73 AP_DECLARE(const char *) unixd_set_user(cmd_parms *cmd, void *dummy, 
74                                         const char *arg);
75 AP_DECLARE(const char *) unixd_set_group(cmd_parms *cmd, void *dummy, 
76                                          const char *arg);
77 #if defined(RLIMIT_CPU) || defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_NPROC) || defined(RLIMIT_AS)
78 AP_DECLARE(void) unixd_set_rlimit(cmd_parms *cmd, struct rlimit **plimit,
79                            const char *arg, const char * arg2, int type);
80 #endif
81
82 /**
83  * One of the functions to set mutex permissions should be called in
84  * the parent process on platforms that switch identity when the 
85  * server is started as root.
86  * If the child init logic is performed before switching identity
87  * (e.g., MPM setup for an accept mutex), it should only be called
88  * for SysV semaphores.  Otherwise, it is safe to call it for all
89  * mutex types.
90  */
91 AP_DECLARE(apr_status_t) unixd_set_proc_mutex_perms(apr_proc_mutex_t *pmutex);
92 AP_DECLARE(apr_status_t) unixd_set_global_mutex_perms(apr_global_mutex_t *gmutex);
93 AP_DECLARE(apr_status_t) unixd_accept(void **accepted, ap_listen_rec *lr, apr_pool_t *ptrans);
94
95 #ifdef HAVE_KILLPG
96 #define unixd_killpg(x, y)      (killpg ((x), (y)))
97 #define ap_os_killpg(x, y)      (killpg ((x), (y)))
98 #else /* HAVE_KILLPG */
99 #define unixd_killpg(x, y)      (kill (-(x), (y)))
100 #define ap_os_killpg(x, y)      (kill (-(x), (y)))
101 #endif /* HAVE_KILLPG */
102
103 #define UNIX_DAEMON_COMMANDS    \
104 AP_INIT_TAKE1("User", unixd_set_user, NULL, RSRC_CONF, \
105   "Effective user id for this server"), \
106 AP_INIT_TAKE1("Group", unixd_set_group, NULL, RSRC_CONF, \
107   "Effective group id for this server")
108
109 #endif