expcov report - Generated Sat Oct 15 21:39:18 2016

 Index  Statistics  Last 
Directory./os/unix
Filenameunixd.c
ModifiedTue Feb 15 05:18:20 2011

Pass Half Fail Excluded Total
Function
0
0.00%
14
100.00%
0
0.00%
14
100%
Expressions
0
0.00%
256
100.00%
0
0.00%
256
100%
Conditions
0
0.00%
0
0.00%
39
100.00%
0
0.00%
39
100%
MC/DC
0
0.00%
9
100.00%
0
0.00%
9
100%
Branches

if
0
0.00%
0
0.00%
46
100.00%
0
0.00%
46
100%
for
0
0.00%
0
0.00%
0
0.00%
0
0.00%
0
100%
while
0
0.00%
0
0.00%
2
100.00%
0
0.00%
2
100%
case
0
0.00%
0
0.00%
12
100.00%
0
0.00%
12
100%

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#include "ap_config.h"
18#define CORE_PRIVATE
19#include "httpd.h"
20#include "http_config.h"
21#include "http_main.h"
22#include "http_log.h"
23#include "unixd.h"
24#include "mpm_common.h"
25#include "os.h"
26#include "ap_mpm.h"
27#include "apr_thread_proc.h"
28#include "apr_strings.h"
29#include "apr_portable.h"
30#ifdef HAVE_PWD_H
31#include <pwd.h>
32#endif
33#ifdef HAVE_SYS_RESOURCE_H
34#include <sys/resource.h>
35#endif
36/* XXX */
37#include <sys/stat.h>
38#ifdef HAVE_UNISTD_H
39#include <unistd.h>
40#endif
41#ifdef HAVE_GRP_H
42#include <grp.h>
43#endif
44#ifdef HAVE_STRINGS_H
45#include <strings.h>
46#endif
47#ifdef HAVE_SYS_SEM_H
48#include <sys/sem.h>
49#endif
50#ifdef HAVE_SYS_PRCTL_H
51#include <sys/prctl.h>
52#endif
53
54unixd_config_rec unixd_config;
55
56/* Set group privileges.
57 *
58 * Note that we use the username as set in the config files, rather than
59 * the lookup of to uid --- the same uid may have multiple passwd entries,
60 * with different sets of groups for each.
61 */
62
63static int set_group_privs : call=0
s
et_group_privs(void)
64{
65    if : true=0, false=0
i
f (! : true=0, false=0
!
geteuid : enter=0, leave=0

geteuid : /usr/include/unistd.h line=697 column=16
g
eteuid()) {
66        const char *name;
67
68        /* Get username if passed as a uid */
69
70        if : true=0, false=0
i
f (unixd_config : os/unix/unixd.c line=54 column=18
u
nixd_config.user_name : os/unix/unixd.h line=71 column=17
u
ser_name[] : enter=0, leave=0
[
0] == : true=0, false=0
=
= '#') {
71            struct passwd *ent;
72            uid_t uid = atoi : enter=0, leave=0

atoi : /usr/include/stdlib.h line=148 column=12
a
toi(&unixd_config : os/unix/unixd.c line=54 column=18
u
nixd_config.user_name : os/unix/unixd.h line=71 column=17
u
ser_name[] : enter=0, leave=0
[
1]);
73
74            if : true=0, false=0
i
f ((ent : os/unix/unixd.c line=71 column=28
e
nt = : pass=0
=
 getpwuid : enter=0, leave=0

getpwuid : /usr/include/pwd.h line=111 column=23
g
etpwuid(uid : os/unix/unixd.c line=72 column=19
u
id)) == : true=0, false=0
=
= NULL) {
75                ap_log_error : enter=0, leave=0

ap_log_error : include/http_log.h line=171 column=18
a
p_log_error(APLOG_MARK, APLOG_ALERT, errno, NULL,
76                         "getpwuid: couldn't determine user name from uid %u, "
77                         "you probably need to modify the User directive",
78                         (unsigned)uid : os/unix/unixd.c line=72 column=19
u
id);
79                return : pass=0
r
eturn -1;
80            }
81
82            name : os/unix/unixd.c line=66 column=21
n
ame = : pass=0
=
 ent : os/unix/unixd.c line=71 column=28
e
nt-> : enter=0, leave=0
-
>pw_name : /usr/include/pwd.h line=52 column=9 pw_name;
83        }
84        else
85            name : os/unix/unixd.c line=66 column=21
n
ame = : pass=0
=
 unixd_config : os/unix/unixd.c line=54 column=18
u
nixd_config.user_name : os/unix/unixd.h line=71 column=17
u
ser_name;
86
87#if !defined(OS2) && !defined(TPF)
88        /* OS/2 and TPF don't support groups. */
89
90        /*
91         * Set the GID before initgroups(), since on some platforms
92         * setgid() is known to zap the group list.
93         */
94        if : true=0, false=0
i
f (setgid : enter=0, leave=0

setgid : /usr/include/unistd.h line=736 column=12
s
etgid(unixd_config : os/unix/unixd.c line=54 column=18
u
nixd_config.group_id : os/unix/unixd.h line=73 column=11
g
roup_id) == : true=0, false=0
=
= -1) {
95            ap_log_error : enter=0, leave=0

ap_log_error : include/http_log.h line=171 column=18
a
p_log_error(APLOG_MARK, APLOG_ALERT, errno, NULL,
96                        "setgid: unable to set group id to Group %u",
97                        (unsigned)unixd_config : os/unix/unixd.c line=54 column=18
u
nixd_config.group_id : os/unix/unixd.h line=73 column=11
g
roup_id);
98            return : pass=0
r
eturn -1;
99        }
100
101        /* Reset `groups' attributes. */
102
103        if : true=0, false=0
i
f (initgroups : enter=0, leave=0

initgroups : /usr/include/grp.h line=203 column=12
i
nitgroups(name : os/unix/unixd.c line=66 column=21
n
ame, unixd_config : os/unix/unixd.c line=54 column=18
u
nixd_config.group_id : os/unix/unixd.h line=73 column=11
g
roup_id) == : true=0, false=0
=
= -1) {
104            ap_log_error : enter=0, leave=0

ap_log_error : include/http_log.h line=171 column=18
a
p_log_error(APLOG_MARK, APLOG_ALERT, errno, NULL,
105                        "initgroups: unable to set groups for User %s "
106                        "and Group %u", name : os/unix/unixd.c line=66 column=21
n
ame, (unsigned)unixd_config : os/unix/unixd.c line=54 column=18
u
nixd_config.group_id : os/unix/unixd.h line=73 column=11
g
roup_id);
107            return : pass=0
r
eturn -1;
108        }
109#endif /* !defined(OS2) && !defined(TPF) */
110    }
111    return : pass=0
r
eturn 0;
112}
113
114
115AP_DECLARE(int) unixd_setup_child : call=0
u
nixd_setup_child(void)
116{
117    if : true=0, false=0
i
f (set_group_privs : enter=0, leave=0

set_group_privs : os/unix/unixd.c line=63 column=12
s
et_group_privs()) {
118        return : pass=0
r
eturn -1;
119    }
120
121    if : true=0, false=0
i
f (NULL != : true=0, false=0
!
unixd_config : os/unix/unixd.c line=54 column=18
u
nixd_config.chroot_dir : os/unix/unixd.h line=75 column=17
c
hroot_dir) {
122        if : true=0, false=0
i
f (geteuid : enter=0, leave=0

geteuid : /usr/include/unistd.h line=697 column=16
g
eteuid()) {
123            ap_log_error : enter=0, leave=0

ap_log_error : include/http_log.h line=171 column=18
a
p_log_error(APLOG_MARK, APLOG_ALERT, errno, NULL,
124                         "Cannot chroot when not started as root");
125            return : pass=0
r
eturn -1;
126        }
127        if : true=0, false=0
i
f (chdir : enter=0, leave=0

chdir : /usr/include/unistd.h line=494 column=12
c
hdir(unixd_config : os/unix/unixd.c line=54 column=18
u
nixd_config.chroot_dir : os/unix/unixd.h line=75 column=17
c
hroot_dir) != : true=0, false=0
!
= 0) {
128            ap_log_error : enter=0, leave=0

ap_log_error : include/http_log.h line=171 column=18
a
p_log_error(APLOG_MARK, APLOG_ALERT, errno, NULL,
129                         "Can't chdir to %s", unixd_config : os/unix/unixd.c line=54 column=18
u
nixd_config.chroot_dir : os/unix/unixd.h line=75 column=17
c
hroot_dir);
130            return : pass=0
r
eturn -1;
131        }
132        if : true=0, false=0
i
f (chroot : enter=0, leave=0

chroot : /usr/include/unistd.h line=963 column=12
c
hroot(unixd_config : os/unix/unixd.c line=54 column=18
u
nixd_config.chroot_dir : os/unix/unixd.h line=75 column=17
c
hroot_dir) != : true=0, false=0
!
= 0) {
133            ap_log_error : enter=0, leave=0

ap_log_error : include/http_log.h line=171 column=18
a
p_log_error(APLOG_MARK, APLOG_ALERT, errno, NULL,
134                         "Can't chroot to %s", unixd_config : os/unix/unixd.c line=54 column=18
u
nixd_config.chroot_dir : os/unix/unixd.h line=75 column=17
c
hroot_dir);
135            return : pass=0
r
eturn -1;
136        }
137        if : true=0, false=0
i
f (chdir : enter=0, leave=0

chdir : /usr/include/unistd.h line=494 column=12
c
hdir("/") != : true=0, false=0
!
= 0) {
138            ap_log_error : enter=0, leave=0

ap_log_error : include/http_log.h line=171 column=18
a
p_log_error(APLOG_MARK, APLOG_ALERT, errno, NULL,
139                         "Can't chdir to new root");
140            return : pass=0
r
eturn -1;
141        }
142    }
143
144#ifdef MPE
145    /* Only try to switch if we're running as MANAGER.SYS */
146    if (geteuid() == 1 && unixd_config.user_id > 1) {
147        GETPRIVMODE();
148        if (setuid(unixd_config.user_id) == -1) {
149            GETUSERMODE();
150            ap_log_error(APLOG_MARK, APLOG_ALERT, errno, NULL,
151                        "setuid: unable to change to uid: %ld",
152                        (long) unixd_config.user_id);
153            exit(1);
154        }
155        GETUSERMODE();
156    }
157#else
158    /* Only try to switch if we're running as root */
159    if : true=0, false=0
i
f (! : true=0, false=0
MC/DC independently affect : true=0, false=0
!TF
geteuid : enter=0, leave=0

geteuid : /usr/include/unistd.h line=697 column=16
g
eteuid() && : true=0, false=0
&
& (
160#ifdef _OSD_POSIX
161        os_init_job_environment(NULL, unixd_config.user_name, ap_exists_config_define("DEBUG")) != 0 ||
162#endif
163        setuid : enter=0, leave=0

setuid : /usr/include/unistd.h line=719 column=12
s
etuid(unixd_config : os/unix/unixd.c line=54 column=18
u
nixd_config.user_id : os/unix/unixd.h line=72 column=11
u
ser_id) == : true=0, false=0
MC/DC independently affect : true=0, false=0
=TF
= -1)) {
164        ap_log_error : enter=0, leave=0

ap_log_error : include/http_log.h line=171 column=18
a
p_log_error(APLOG_MARK, APLOG_ALERT, errno, NULL,
165                    "setuid: unable to change to uid: %ld",
166                    (long) unixd_config : os/unix/unixd.c line=54 column=18
u
nixd_config.user_id : os/unix/unixd.h line=72 column=11
u
ser_id);
167        return : pass=0
r
eturn -1;
168    }
169#if defined(HAVE_PRCTL) && defined(PR_SET_DUMPABLE)
170    /* this applies to Linux 2.4+ */
171#ifdef AP_MPM_WANT_SET_COREDUMPDIR
172    if : true=0, false=0
i
f (ap_coredumpdir_configured : include/mpm_common.h line=333 column=12
a
p_coredumpdir_configured) {
173        if : true=0, false=0
i
f (prctl : enter=0, leave=0

prctl : /usr/include/sys/prctl.h line=28 column=12
p
rctl(PR_SET_DUMPABLE, 1)) {
174            ap_log_error : enter=0, leave=0

ap_log_error : include/http_log.h line=171 column=18
a
p_log_error(APLOG_MARK, APLOG_ALERT, errno, NULL,
175                         "set dumpable failed - this child will not coredump"
176                         " after software errors");
177        }
178    }
179#endif
180#endif
181#endif
182    return : pass=0
r
eturn 0;
183}
184
185
186AP_DECLARE(const char *) unixd_set_user : call=0
u
nixd_set_user(cmd_parms *cmd, void *dummy,
187                                        const char *arg)
188{
189    const char *err = ap_check_cmd_context : enter=0, leave=0

ap_check_cmd_context : include/http_config.h line=710 column=26
a
p_check_cmd_context(cmd : os/unix/unixd.c line=186 column=52
c
md, GLOBAL_ONLY);
190    if : true=0, false=0
i
f (err : os/unix/unixd.c line=189 column=17
e
rr != : true=0, false=0
!
= NULL) {
191        return : pass=0
r
eturn err : os/unix/unixd.c line=189 column=17
e
rr;
192    }
193
194    unixd_config : os/unix/unixd.c line=54 column=18
u
nixd_config.user_name : os/unix/unixd.h line=71 column=17
u
ser_name = : pass=0
=
 arg : os/unix/unixd.c line=187 column=53
a
rg;
195    unixd_config : os/unix/unixd.c line=54 column=18
u
nixd_config.user_id : os/unix/unixd.h line=72 column=11
u
ser_id = : pass=0
=
 ap_uname2id : enter=0, leave=0

ap_uname2id : include/mpm_common.h line=204 column=19
a
p_uname2id(arg : os/unix/unixd.c line=187 column=53
a
rg);
196#if !defined (BIG_SECURITY_HOLE) && !defined (OS2)
197    if : true=0, false=0
i
f (unixd_config : os/unix/unixd.c line=54 column=18
u
nixd_config.user_id : os/unix/unixd.h line=72 column=11
u
ser_id == : true=0, false=0
=
= 0) {
198        return : pass=0
r
eturn "Error:\tApache has not been designed to serve pages while\n"
199                "\trunning as root.  There are known race conditions that\n"
200                "\twill allow any local user to read any file on the system.\n"
201                "\tIf you still desire to serve pages as root then\n"
202                "\tadd -DBIG_SECURITY_HOLE to the CFLAGS env variable\n"
203                "\tand then rebuild the server.\n"
204                "\tIt is strongly suggested that you instead modify the User\n"
205                "\tdirective in your httpd.conf file to list a non-root\n"
206                "\tuser.\n";
207    }
208#endif
209
210    return : pass=0
r
eturn NULL;
211}
212
213AP_DECLARE(const char *) unixd_set_group : call=0
u
nixd_set_group(cmd_parms *cmd, void *dummy,
214                                         const char *arg)
215{
216    const char *err = ap_check_cmd_context : enter=0, leave=0

ap_check_cmd_context : include/http_config.h line=710 column=26
a
p_check_cmd_context(cmd : os/unix/unixd.c line=213 column=53
c
md, GLOBAL_ONLY);
217    if : true=0, false=0
i
f (err : os/unix/unixd.c line=216 column=17
e
rr != : true=0, false=0
!
= NULL) {
218        return : pass=0
r
eturn err : os/unix/unixd.c line=216 column=17
e
rr;
219    }
220
221    unixd_config : os/unix/unixd.c line=54 column=18
u
nixd_config.group_id : os/unix/unixd.h line=73 column=11
g
roup_id = : pass=0
=
 ap_gname2id : enter=0, leave=0

ap_gname2id : include/mpm_common.h line=214 column=19
a
p_gname2id(arg : os/unix/unixd.c line=214 column=54
a
rg);
222
223    return : pass=0
r
eturn NULL;
224}
225AP_DECLARE(const char *) unixd_set_chroot_dir : call=0
u
nixd_set_chroot_dir(cmd_parms *cmd, void *dummy,
226                                              const char *arg)
227{
228    const char *err = ap_check_cmd_context : enter=0, leave=0

ap_check_cmd_context : include/http_config.h line=710 column=26
a
p_check_cmd_context(cmd : os/unix/unixd.c line=225 column=58
c
md, GLOBAL_ONLY);
229    if : true=0, false=0
i
f (err : os/unix/unixd.c line=228 column=17
e
rr != : true=0, false=0
!
= NULL) {
230        return : pass=0
r
eturn err : os/unix/unixd.c line=228 column=17
e
rr;
231    }
232    if : true=0, false=0
i
f (! : true=0, false=0
!
ap_is_directory : enter=0, leave=0

ap_is_directory : include/httpd.h line=1818 column=17
a
p_is_directory(cmd : os/unix/unixd.c line=225 column=58
c
md-> : enter=0, leave=0
-
>pool : include/http_config.h line=291 column=17
p
ool, arg : os/unix/unixd.c line=226 column=59
a
rg)) {
233        return : pass=0
r
eturn "ChrootDir must be a valid directory";
234    }
235
236    unixd_config : os/unix/unixd.c line=54 column=18
u
nixd_config.chroot_dir : os/unix/unixd.h line=75 column=17
c
hroot_dir = : pass=0
=
 arg : os/unix/unixd.c line=226 column=59
a
rg;
237    return : pass=0
r
eturn NULL;
238}
239
240AP_DECLARE(const char *) unixd_set_suexec : call=0
u
nixd_set_suexec(cmd_parms *cmd, void *dummy,
241                                          int arg)
242{
243    const char *err = ap_check_cmd_context : enter=0, leave=0

ap_check_cmd_context : include/http_config.h line=710 column=26
a
p_check_cmd_context(cmd : os/unix/unixd.c line=240 column=54
c
md, GLOBAL_ONLY);
244    if : true=0, false=0
i
f (err : os/unix/unixd.c line=243 column=17
e
rr != : true=0, false=0
!
= NULL) {
245        return : pass=0
r
eturn err : os/unix/unixd.c line=243 column=17
e
rr;
246    }
247
248    if : true=0, false=0
i
f (! : true=0, false=0
MC/DC independently affect : true=0, false=0
!TF
unixd_config : os/unix/unixd.c line=54 column=18
u
nixd_config.suexec_enabled : os/unix/unixd.h line=74 column=9
s
uexec_enabled && : true=0, false=0
&
MC/DC independently affect : true=0, false=0

arg : os/unix/unixd.c line=241 column=47
aTF
rg) {
249        return : pass=0
r
eturn "suEXEC isn't supported; check existence, owner, and "
250               "file mode of " SUEXEC_BIN;
251    }
252
253    unixd_config : os/unix/unixd.c line=54 column=18
u
nixd_config.suexec_enabled : os/unix/unixd.h line=74 column=9
s
uexec_enabled = : pass=0
=
 arg : os/unix/unixd.c line=241 column=47
a
rg;
254    return : pass=0
r
eturn NULL;
255}
256
257AP_DECLARE(void) unixd_pre_config : call=0
u
nixd_pre_config(apr_pool_t *ptemp)
258{
259    apr_finfo_t wrapper;
260
261    unixd_config : os/unix/unixd.c line=54 column=18
u
nixd_config.user_name : os/unix/unixd.h line=71 column=17
u
ser_name = : pass=0
=
 DEFAULT_USER;
262    unixd_config : os/unix/unixd.c line=54 column=18
u
nixd_config.user_id : os/unix/unixd.h line=72 column=11
u
ser_id = : pass=0
=
 ap_uname2id : enter=0, leave=0

ap_uname2id : include/mpm_common.h line=204 column=19
a
p_uname2id(DEFAULT_USER);
263    unixd_config : os/unix/unixd.c line=54 column=18
u
nixd_config.group_id : os/unix/unixd.h line=73 column=11
g
roup_id = : pass=0
=
 ap_gname2id : enter=0, leave=0

ap_gname2id : include/mpm_common.h line=214 column=19
a
p_gname2id(DEFAULT_GROUP);
264    
265    unixd_config : os/unix/unixd.c line=54 column=18
u
nixd_config.chroot_dir : os/unix/unixd.h line=75 column=17
c
hroot_dir = : pass=0
=
 NULL; /* none */
266
267    /* Check for suexec */
268    unixd_config : os/unix/unixd.c line=54 column=18
u
nixd_config.suexec_enabled : os/unix/unixd.h line=74 column=9
s
uexec_enabled = : pass=0
=
 0;
269    if : true=0, false=0
i
f ((apr_stat : enter=0, leave=0

apr_stat : /usr/include/apr-1/apr_file_info.h line=229 column=27
a
pr_stat(&wrapper : os/unix/unixd.c line=259 column=17
w
rapper, SUEXEC_BIN,
270                  APR_FINFO_NORM, ptemp : os/unix/unixd.c line=257 column=47
p
temp)) != : true=0, false=0
!
= APR_SUCCESS) {
271        return : pass=0
r
eturn;
272    }
273
274    if : true=0, false=0
i
f ((wrapper : os/unix/unixd.c line=259 column=17
w
rapper.protection : /usr/include/apr-1/apr_file_info.h line=181 column=21 protection & : pass=0
&
 APR_USETID) && : true=0, false=0
&
wrapper : os/unix/unixd.c line=259 column=17
w
rapper.user : /usr/include/apr-1/apr_file_info.h line=188 column=15 user == : true=0, false=0
MC/DC independently affect : true=0, false=0
=TF
= 0) {
275        unixd_config : os/unix/unixd.c line=54 column=18
u
nixd_config.suexec_enabled : os/unix/unixd.h line=74 column=9
s
uexec_enabled = : pass=0
=
 1;
276    }
277}
278
279
280AP_DECLARE(void) unixd_set_rlimit : call=0
u
nixd_set_rlimit(cmd_parms *cmd, struct rlimit **plimit,
281                           const char *arg, const char * arg2, int type)
282{
283#if (defined(RLIMIT_CPU) || defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_NPROC) || defined(RLIMIT_AS)) && APR_HAVE_STRUCT_RLIMIT && APR_HAVE_GETRLIMIT
284    char *str;
285    struct rlimit *limit;
286    /* If your platform doesn't define rlim_t then typedef it in ap_config.h */
287    rlim_t cur = 0;
288    rlim_t max = 0;
289
290    *plimit : os/unix/unixd.c line=280 column=67
p
limit = : enter=0, leave=0
=
 (struct rlimit *)apr_pcalloc(cmd : os/unix/unixd.c line=280 column=46
c
md-> : enter=0, leave=0
-
>pool : include/http_config.h line=291 column=17
p
ool, sizeof(**plimit));
291    limit : os/unix/unixd.c line=285 column=20
l
imit = : pass=0
=
 * dereference : enter=0, leave=0
*
plimit : os/unix/unixd.c line=280 column=67
p
limit;
292    if : true=0, false=0
i
f ((getrlimit : enter=0, leave=0

getrlimit : /usr/include/sys/resource.h line=51 column=12
g
etrlimit(type : os/unix/unixd.c line=281 column=68
t
ype, limit : os/unix/unixd.c line=285 column=20
l
imit)) != : true=0, false=0
!
= 0)  {
293        *plimit : os/unix/unixd.c line=280 column=67
p
limit = : enter=0, leave=0
=
 NULL;
294        ap_log_error : enter=0, leave=0

ap_log_error : include/http_log.h line=171 column=18
a
p_log_error(APLOG_MARK, APLOG_ERR, errno, cmd : os/unix/unixd.c line=280 column=46
c
md-> : enter=0, leave=0
-
>server : include/http_config.h line=296 column=17
s
erver,
295                     "%s: getrlimit failed", cmd : os/unix/unixd.c line=280 column=46
c
md-> : enter=0, leave=0
-
>cmd : include/http_config.h line=305 column=24
c
md-> : enter=0, leave=0
-
>name : include/http_config.h line=204 column=17
n
ame);
296        return : pass=0
r
eturn;
297    }
298
299    if : true=0, false=0
i
f ((str : os/unix/unixd.c line=284 column=11
s
tr = : pass=0
=
 ap_getword_conf : enter=0, leave=0

ap_getword_conf : include/httpd.h line=1358 column=20
a
p_getword_conf(cmd : os/unix/unixd.c line=280 column=46
c
md-> : enter=0, leave=0
-
>pool : include/http_config.h line=291 column=17
p
ool, &arg : os/unix/unixd.c line=281 column=40
a
rg))) {
300        if : true=0, false=0
i
f (! : true=0, false=0
!
strcasecmp : enter=0, leave=0

strcasecmp : /usr/include/string.h line=536 column=12
s
trcasecmp(str : os/unix/unixd.c line=284 column=11
s
tr, "max")) {
301            cur : os/unix/unixd.c line=287 column=12
c
ur = : pass=0
=
 limit : os/unix/unixd.c line=285 column=20
l
imit-> : enter=0, leave=0
-
>rlim_max : /usr/include/bits/resource.h line=140 column=12 rlim_max;
302        }
303        else {
304            cur : os/unix/unixd.c line=287 column=12
c
ur = : pass=0
=
 atol : enter=0, leave=0

atol : /usr/include/stdlib.h line=151 column=17
a
tol(str : os/unix/unixd.c line=284 column=11
s
tr);
305        }
306    }
307    else {
308        ap_log_error : enter=0, leave=0

ap_log_error : include/http_log.h line=171 column=18
a
p_log_error(APLOG_MARK, APLOG_ERR, 0, cmd : os/unix/unixd.c line=280 column=46
c
md-> : enter=0, leave=0
-
>server : include/http_config.h line=296 column=17
s
erver,
309                     "Invalid parameters for %s", cmd : os/unix/unixd.c line=280 column=46
c
md-> : enter=0, leave=0
-
>cmd : include/http_config.h line=305 column=24
c
md-> : enter=0, leave=0
-
>name : include/http_config.h line=204 column=17
n
ame);
310        return : pass=0
r
eturn;
311    }
312
313    if : true=0, false=0
i
f (MC/DC independently affect : true=0, false=0

arg2 : os/unix/unixd.c line=281 column=58
aTF
rg2 && : true=0, false=0
&
& (str : os/unix/unixd.c line=284 column=11
s
tr = : pass=0
MC/DC independently affect : true=0, false=0
=TF
 ap_getword_conf : enter=0, leave=0

ap_getword_conf : include/httpd.h line=1358 column=20
a
p_getword_conf(cmd : os/unix/unixd.c line=280 column=46
c
md-> : enter=0, leave=0
-
>pool : include/http_config.h line=291 column=17
p
ool, &arg2 : os/unix/unixd.c line=281 column=58
a
rg2))) {
314        max : os/unix/unixd.c line=288 column=12
m
ax = : pass=0
=
 atol : enter=0, leave=0

atol : /usr/include/stdlib.h line=151 column=17
a
tol(str : os/unix/unixd.c line=284 column=11
s
tr);
315    }
316
317    /* if we aren't running as root, cannot increase max */
318    if : true=0, false=0
i
f (geteuid : enter=0, leave=0

geteuid : /usr/include/unistd.h line=697 column=16
g
eteuid()) {
319        limit : os/unix/unixd.c line=285 column=20
l
imit-> : enter=0, leave=0
-
>rlim_cur : /usr/include/bits/resource.h line=138 column=12 rlim_cur = : enter=0, leave=0
=
 cur : os/unix/unixd.c line=287 column=12
c
ur;
320        if : true=0, false=0
i
f (max : os/unix/unixd.c line=288 column=12
m
ax) {
321            ap_log_error : enter=0, leave=0

ap_log_error : include/http_log.h line=171 column=18
a
p_log_error(APLOG_MARK, APLOG_ERR, 0, cmd : os/unix/unixd.c line=280 column=46
c
md-> : enter=0, leave=0
-
>server : include/http_config.h line=296 column=17
s
erver,
322                         "Must be uid 0 to raise maximum %s", cmd : os/unix/unixd.c line=280 column=46
c
md-> : enter=0, leave=0
-
>cmd : include/http_config.h line=305 column=24
c
md-> : enter=0, leave=0
-
>name : include/http_config.h line=204 column=17
n
ame);
323        }
324    }
325    else {
326        if : true=0, false=0
i
f (cur : os/unix/unixd.c line=287 column=12
c
ur) {
327            limit : os/unix/unixd.c line=285 column=20
l
imit-> : enter=0, leave=0
-
>rlim_cur : /usr/include/bits/resource.h line=138 column=12 rlim_cur = : enter=0, leave=0
=
 cur : os/unix/unixd.c line=287 column=12
c
ur;
328        }
329        if : true=0, false=0
i
f (max : os/unix/unixd.c line=288 column=12
m
ax) {
330            limit : os/unix/unixd.c line=285 column=20
l
imit-> : enter=0, leave=0
-
>rlim_max : /usr/include/bits/resource.h line=140 column=12 rlim_max = : enter=0, leave=0
=
 max : os/unix/unixd.c line=288 column=12
m
ax;
331        }
332    }
333#else
334
335    ap_log_error(APLOG_MARK, APLOG_ERR, 0, cmd->server,
336                 "Platform does not support rlimit for %s", cmd->cmd->name);
337#endif
338}
339
340APR_HOOK_STRUCT(
341               APR_HOOK_LINK(get_suexec_identity)
342)
343
344AP_IMPLEMENT_HOOK_RUN_FIRST(ap_unix_identity_t *, get_suexec_identity,
345                         (const request_rec *r), (r : os/unix/unixd.c line=345 column=46
r
), NULL)
346
347static apr_status_t ap_unix_create_privileged_process : call=0
a
p_unix_create_privileged_process(
348                              apr_proc_t *newproc, const char *progname,
349                              const char * const *args,
350                              const char * const *env,
351                              apr_procattr_t *attr, ap_unix_identity_t *ugid,
352                              apr_pool_t *p)
353{
354    int i = 0;
355    const char **newargs;
356    char *newprogname;
357    char *execuser, *execgroup;
358    const char *argv0;
359
360    if : true=0, false=0
i
f (! : true=0, false=0
!
unixd_config : os/unix/unixd.c line=54 column=18
u
nixd_config.suexec_enabled : os/unix/unixd.h line=74 column=9
s
uexec_enabled) {
361        return : pass=0
r
eturn apr_proc_create : enter=0, leave=0

apr_proc_create : /usr/include/apr-1/apr_thread_proc.h line=608 column=27
a
pr_proc_create(newproc : os/unix/unixd.c line=348 column=43
n
ewproc, progname : os/unix/unixd.c line=348 column=64
p
rogname, args : os/unix/unixd.c line=349 column=51
a
rgs, env : os/unix/unixd.c line=350 column=51
e
nv, attr : os/unix/unixd.c line=351 column=47
a
ttr, p : os/unix/unixd.c line=352 column=43
p
);
362    }
363
364    argv0 : os/unix/unixd.c line=358 column=17
a
rgv0 = : pass=0
=
 ap_strrchr_c(progname : os/unix/unixd.c line=348 column=64
p
rogname, '/');
365    /* Allow suexec's "/" check to succeed */
366    if : true=0, false=0
i
f (argv0 : os/unix/unixd.c line=358 column=17
a
rgv0 != : true=0, false=0
!
= NULL) {
367        argv0 : os/unix/unixd.c line=358 column=17
a
rgv0++ : pass=0
+
+;
368    }
369    else {
370        argv0 : os/unix/unixd.c line=358 column=17
a
rgv0 = : pass=0
=
 progname : os/unix/unixd.c line=348 column=64
p
rogname;
371    }
372
373
374    if : true=0, false=0
i
f (ugid : os/unix/unixd.c line=351 column=73
u
gid-> : enter=0, leave=0
-
>userdir : os/unix/unixd.h line=54 column=9
u
serdir) {
375        execuser : os/unix/unixd.c line=357 column=11
e
xecuser = : pass=0
=
 apr_psprintf : enter=0, leave=0

apr_psprintf : /usr/include/apr-1/apr_strings.h line=170 column=28
a
pr_psprintf(p : os/unix/unixd.c line=352 column=43
p
, "~%ld", (long) ugid : os/unix/unixd.c line=351 column=73
u
gid-> : enter=0, leave=0
-
>uid : os/unix/unixd.h line=52 column=11
u
id);
376    }
377    else {
378        execuser : os/unix/unixd.c line=357 column=11
e
xecuser = : pass=0
=
 apr_psprintf : enter=0, leave=0

apr_psprintf : /usr/include/apr-1/apr_strings.h line=170 column=28
a
pr_psprintf(p : os/unix/unixd.c line=352 column=43
p
, "%ld", (long) ugid : os/unix/unixd.c line=351 column=73
u
gid-> : enter=0, leave=0
-
>uid : os/unix/unixd.h line=52 column=11
u
id);
379    }
380    execgroup : os/unix/unixd.c line=357 column=22
e
xecgroup = : pass=0
=
 apr_psprintf : enter=0, leave=0

apr_psprintf : /usr/include/apr-1/apr_strings.h line=170 column=28
a
pr_psprintf(p : os/unix/unixd.c line=352 column=43
p
, "%ld", (long) ugid : os/unix/unixd.c line=351 column=73
u
gid-> : enter=0, leave=0
-
>gid : os/unix/unixd.h line=53 column=11
g
id);
381
382    if : true=0, false=0
i
f (! : true=0, false=0
MC/DC independently affect : true=0, false=0
!TF
execuser : os/unix/unixd.c line=357 column=11
e
xecuser || : true=0, false=0
|
! : true=0, false=0
MC/DC independently affect : true=0, false=0
!TF
execgroup : os/unix/unixd.c line=357 column=22
e
xecgroup) {
383        return : pass=0
r
eturn APR_ENOMEM;
384    }
385
386    i : os/unix/unixd.c line=354 column=9
i
 = : pass=0
=
 0;
387    if : true=0, false=0
i
f (args : os/unix/unixd.c line=349 column=51
a
rgs) {
388        while : true=0, false=0
w
hile (args : os/unix/unixd.c line=349 column=51
a
rgs[] : enter=0, leave=0
[
i : os/unix/unixd.c line=354 column=9
i
]) {
389            i : os/unix/unixd.c line=354 column=9
i
++ : pass=0
+
+;
390            }
391    }
392    /* allocate space for 4 new args, the input args, and a null terminator */
393    newargs : os/unix/unixd.c line=355 column=18
n
ewargs = : pass=0
=
 apr_palloc : enter=0, leave=0

apr_palloc : /usr/include/apr-1/apr_pools.h line=419 column=21
a
pr_palloc(p : os/unix/unixd.c line=352 column=43
p
, sizeof(char *) * : pass=0
*
 (i : os/unix/unixd.c line=354 column=9
i
 + : pass=0
+
 4));
394    newprogname : os/unix/unixd.c line=356 column=11
n
ewprogname = : pass=0
=
 SUEXEC_BIN;
395    newargs : os/unix/unixd.c line=355 column=18
n
ewargs[0] = : enter=0, leave=0
=
 SUEXEC_BIN;
396    newargs : os/unix/unixd.c line=355 column=18
n
ewargs[1] = : enter=0, leave=0
=
 execuser : os/unix/unixd.c line=357 column=11
e
xecuser;
397    newargs : os/unix/unixd.c line=355 column=18
n
ewargs[2] = : enter=0, leave=0
=
 execgroup : os/unix/unixd.c line=357 column=22
e
xecgroup;
398    newargs : os/unix/unixd.c line=355 column=18
n
ewargs[3] = : enter=0, leave=0
=
 apr_pstrdup : enter=0, leave=0

apr_pstrdup : /usr/include/apr-1/apr_strings.h line=95 column=21
a
pr_pstrdup(p : os/unix/unixd.c line=352 column=43
p
argv0 : os/unix/unixd.c line=358 column=17
a
rgv0);
399
400    /*
401    ** using a shell to execute suexec makes no sense thus
402    ** we force everything to be APR_PROGRAM, and never
403    ** APR_SHELLCMD
404    */
405    if : true=0, false=0
i
f(apr_procattr_cmdtype_set : enter=0, leave=0

apr_procattr_cmdtype_set : /usr/include/apr-1/apr_thread_proc.h line=491 column=27
a
pr_procattr_cmdtype_set(attr : os/unix/unixd.c line=351 column=47
a
ttr, APR_PROGRAM : /usr/include/apr-1/apr_thread_proc.h line=47 column=5 APR_PROGRAM) != : true=0, false=0
!
= APR_SUCCESS) {
406        return : pass=0
r
eturn APR_EGENERAL;
407    }
408
409    i : os/unix/unixd.c line=354 column=9
i
 = : pass=0
=
 1;
410    do {
411        newargs : os/unix/unixd.c line=355 column=18
n
ewargs[i : os/unix/unixd.c line=354 column=9
i
 + : pass=0
+
 3] = : enter=0, leave=0
=
 args : os/unix/unixd.c line=349 column=51
a
rgs[] : enter=0, leave=0
[
i : os/unix/unixd.c line=354 column=9
i
];
412    } while : true=0, false=0
w
hile (args : os/unix/unixd.c line=349 column=51
a
rgs[] : enter=0, leave=0
[
i : os/unix/unixd.c line=354 column=9
i
++ : pass=0
+
+]);
413
414    return : pass=0
r
eturn apr_proc_create : enter=0, leave=0

apr_proc_create : /usr/include/apr-1/apr_thread_proc.h line=608 column=27
a
pr_proc_create(newproc : os/unix/unixd.c line=348 column=43
n
ewproc, newprogname : os/unix/unixd.c line=356 column=11
n
ewprogname, newargs : os/unix/unixd.c line=355 column=18
n
ewargs, env : os/unix/unixd.c line=350 column=51
e
nv, attr : os/unix/unixd.c line=351 column=47
a
ttr, p : os/unix/unixd.c line=352 column=43
p
);
415}
416
417AP_DECLARE(apr_status_t) ap_os_create_privileged_process : call=0
a
p_os_create_privileged_process(
418    const request_rec *r,
419    apr_proc_t *newproc, const char *progname,
420    const char * const *args,
421    const char * const *env,
422    apr_procattr_t *attr, apr_pool_t *p)
423{
424    ap_unix_identity_t *ugid = ap_run_get_suexec_identity : enter=0, leave=0

ap_run_get_suexec_identity : os/unix/ line=240 column=1
a
p_run_get_suexec_identity(r : os/unix/unixd.c line=418 column=24
r
);
425
426    if : true=0, false=0
i
f (ugid : os/unix/unixd.c line=424 column=25
u
gid == : true=0, false=0
=
= NULL) {
427        return : pass=0
r
eturn apr_proc_create : enter=0, leave=0

apr_proc_create : /usr/include/apr-1/apr_thread_proc.h line=608 column=27
a
pr_proc_create(newproc : os/unix/unixd.c line=419 column=17
n
ewproc, progname : os/unix/unixd.c line=419 column=38
p
rogname, args : os/unix/unixd.c line=420 column=25
a
rgs, env : os/unix/unixd.c line=421 column=25
e
nv, attr : os/unix/unixd.c line=422 column=21
a
ttr, p : os/unix/unixd.c line=422 column=39
p
);
428    }
429
430    return : pass=0
r
eturn ap_unix_create_privileged_process : enter=0, leave=0

ap_unix_create_privileged_process : os/unix/unixd.c line=347 column=21
a
p_unix_create_privileged_process(newproc : os/unix/unixd.c line=419 column=17
n
ewproc, progname : os/unix/unixd.c line=419 column=38
p
rogname, args : os/unix/unixd.c line=420 column=25
a
rgs, env : os/unix/unixd.c line=421 column=25
e
nv,
431                                              attr : os/unix/unixd.c line=422 column=21
a
ttr, ugid : os/unix/unixd.c line=424 column=25
u
gid, p : os/unix/unixd.c line=422 column=39
p
);
432}
433
434/* XXX move to APR and externalize (but implement differently :) ) */
435static apr_lockmech_e proc_mutex_mech : call=0
p
roc_mutex_mech(apr_proc_mutex_t *pmutex)
436{
437    const char *mechname = apr_proc_mutex_name : enter=0, leave=0

apr_proc_mutex_name : /usr/include/apr-1/apr_proc_mutex.h line=147 column=27
a
pr_proc_mutex_name(pmutex : os/unix/unixd.c line=435 column=57
p
mutex);
438
439    if : true=0, false=0
i
f (! : true=0, false=0
!
strcmp : enter=0, leave=0

strcmp : /usr/include/string.h line=143 column=12
s
trcmp(mechname : os/unix/unixd.c line=437 column=17
m
echname, "sysvsem")) {
440        return : pass=0
r
eturn APR_LOCK_SYSVSEM : /usr/include/apr-1/apr_proc_mutex.h line=47 column=5 APR_LOCK_SYSVSEM;
441    }
442    else if : true=0, false=0
i
f (! : true=0, false=0
!
strcmp : enter=0, leave=0

strcmp : /usr/include/string.h line=143 column=12
s
trcmp(mechname : os/unix/unixd.c line=437 column=17
m
echname, "flock")) {
443        return : pass=0
r
eturn APR_LOCK_FLOCK : /usr/include/apr-1/apr_proc_mutex.h line=46 column=5 APR_LOCK_FLOCK;
444    }
445    return : pass=0
r
eturn APR_LOCK_DEFAULT : /usr/include/apr-1/apr_proc_mutex.h line=50 column=5 APR_LOCK_DEFAULT;
446}
447
448AP_DECLARE(apr_status_t) unixd_set_proc_mutex_perms : call=0
u
nixd_set_proc_mutex_perms(apr_proc_mutex_t *pmutex)
449{
450    if : true=0, false=0
i
f (! : true=0, false=0
!
geteuid : enter=0, leave=0

geteuid : /usr/include/unistd.h line=697 column=16
g
eteuid()) {
451        apr_lockmech_e mech = proc_mutex_mech : enter=0, leave=0

proc_mutex_mech : os/unix/unixd.c line=435 column=23
p
roc_mutex_mech(pmutex : os/unix/unixd.c line=448 column=71
p
mutex);
452
453        switch : pass=0
s
witch(mech : os/unix/unixd.c line=451 column=24
m
ech) {
454#if APR_HAS_SYSVSEM_SERIALIZE
455        case : true=0, false=0
c
ase APR_LOCK_SYSVSEM:
456        {
457            apr_os_proc_mutex_t ospmutex;
458#if !APR_HAVE_UNION_SEMUN
459            union semun {
460                long val;
461                struct semid_ds *buf;
462                unsigned short *array;
463            };
464#endif
465            union semun ick;
466            struct semid_ds buf;
467
468            apr_os_proc_mutex_get : enter=0, leave=0

apr_os_proc_mutex_get : /usr/include/apr-1/apr_portable.h line=248 column=27
a
pr_os_proc_mutex_get(&ospmutex : os/unix/unixd.c line=457 column=33
o
spmutex, pmutex : os/unix/unixd.c line=448 column=71
p
mutex);
469            buf : os/unix/unixd.c line=466 column=29
b
uf.sem_perm : /usr/include/bits/sem.h line=41 column=19 sem_perm.uid : /usr/include/bits/ipc.h line=46 column=13 uid = : pass=0
=
 unixd_config : os/unix/unixd.c line=54 column=18
u
nixd_config.user_id : os/unix/unixd.h line=72 column=11
u
ser_id;
470            buf : os/unix/unixd.c line=466 column=29
b
uf.sem_perm : /usr/include/bits/sem.h line=41 column=19 sem_perm.gid : /usr/include/bits/ipc.h line=47 column=13 gid = : pass=0
=
 unixd_config : os/unix/unixd.c line=54 column=18
u
nixd_config.group_id : os/unix/unixd.h line=73 column=11
g
roup_id;
471            buf : os/unix/unixd.c line=466 column=29
b
uf.sem_perm : /usr/include/bits/sem.h line=41 column=19 sem_perm.mode : /usr/include/bits/ipc.h line=50 column=24 mode = : pass=0
=
 0600;
472            ick : os/unix/unixd.c line=465 column=25
i
ck.buf : os/unix/unixd.c line=461 column=34
b
uf = : pass=0
=
 &buf : os/unix/unixd.c line=466 column=29
b
uf;
473            if : true=0, false=0
i
f (semctl : enter=0, leave=0

semctl : /usr/include/sys/sem.h line=53 column=12
s
emctl(ospmutex : os/unix/unixd.c line=457 column=33
o
spmutex.crossproc : /usr/include/apr-1/apr_portable.h line=130 column=9 crossproc, 0, IPC_SET, ick : os/unix/unixd.c line=465 column=25
i
ck) < : true=0, false=0
<
 0) {
474                return : pass=0
r
eturn errno;
475            }
476        }
477        break : pass=0
b
reak;
478#endif
479#if APR_HAS_FLOCK_SERIALIZE
480        case : true=0, false=0
c
ase APR_LOCK_FLOCK:
481        {
482            const char *lockfile = apr_proc_mutex_lockfile : enter=0, leave=0

apr_proc_mutex_lockfile : /usr/include/apr-1/apr_proc_mutex.h line=140 column=27
a
pr_proc_mutex_lockfile(pmutex : os/unix/unixd.c line=448 column=71
p
mutex);
483
484            if : true=0, false=0
i
f (lockfile : os/unix/unixd.c line=482 column=25
l
ockfile) {
485                if : true=0, false=0
i
f (chown : enter=0, leave=0

chown : /usr/include/unistd.h line=470 column=12
c
hown(lockfile : os/unix/unixd.c line=482 column=25
l
ockfile, unixd_config : os/unix/unixd.c line=54 column=18
u
nixd_config.user_id : os/unix/unixd.h line=72 column=11
u
ser_id,
486                          -1 /* no gid change */) < : true=0, false=0
<
 0) {
487                    return : pass=0
r
eturn errno;
488                }
489            }
490        }
491        break : pass=0
b
reak;
492#endif
493        default : true=0, false=0
d
efault:
494            /* do nothing */
495            break : pass=0
b
reak;
496        }
497    }
498    return : pass=0
r
eturn APR_SUCCESS;
499}
500
501AP_DECLARE(apr_status_t) unixd_set_global_mutex_perms : call=0
u
nixd_set_global_mutex_perms(apr_global_mutex_t *gmutex)
502{
503#if !APR_PROC_MUTEX_IS_GLOBAL
504    apr_os_global_mutex_t osgmutex;
505    apr_os_global_mutex_get : enter=0, leave=0

apr_os_global_mutex_get : /usr/include/apr-1/apr_portable.h line=212 column=27
a
pr_os_global_mutex_get(&osgmutex : os/unix/unixd.c line=504 column=27
o
sgmutex, gmutex : os/unix/unixd.c line=501 column=75
g
mutex);
506    return : pass=0
r
eturn unixd_set_proc_mutex_perms : enter=0, leave=0

unixd_set_proc_mutex_perms : os/unix/unixd.c line=448 column=26
u
nixd_set_proc_mutex_perms(osgmutex : os/unix/unixd.c line=504 column=27
o
sgmutex.proc_mutex : /usr/include/apr-1/apr_portable.h line=205 column=27 proc_mutex);
507#else  /* APR_PROC_MUTEX_IS_GLOBAL */
508    /* In this case, apr_proc_mutex_t and apr_global_mutex_t are the same. */
509    return unixd_set_proc_mutex_perms(gmutex);
510#endif /* APR_PROC_MUTEX_IS_GLOBAL */
511}
512
513AP_DECLARE(apr_status_t) unixd_accept : call=0
u
nixd_accept(void **accepted, ap_listen_rec *lr,
514                                        apr_pool_t *ptrans)
515{
516    apr_socket_t *csd;
517    apr_status_t status;
518#ifdef _OSD_POSIX
519    int sockdes;
520#endif
521
522    *accepted : os/unix/unixd.c line=513 column=46
a
ccepted = : enter=0, leave=0
=
 NULL;
523    status : os/unix/unixd.c line=517 column=18
s
tatus = : pass=0
=
 apr_socket_accept : enter=0, leave=0

apr_socket_accept : /usr/include/apr-1/apr_network_io.h line=337 column=27
a
pr_socket_accept(&csd : os/unix/unixd.c line=516 column=19
c
sd, lr : os/unix/unixd.c line=513 column=71
l
r-> : enter=0, leave=0
-
>sd : include/ap_listen.h line=54 column=19
s
d, ptrans : os/unix/unixd.c line=514 column=53
p
trans);
524    if : true=0, false=0
i
f (status : os/unix/unixd.c line=517 column=18
s
tatus == : true=0, false=0
=
= APR_SUCCESS) {
525        *accepted : os/unix/unixd.c line=513 column=46
a
ccepted = : enter=0, leave=0
=
 csd : os/unix/unixd.c line=516 column=19
c
sd;
526#ifdef _OSD_POSIX
527        apr_os_sock_get(&sockdes, csd);
528        if (sockdes >= FD_SETSIZE) {
529            ap_log_error(APLOG_MARK, APLOG_WARNING, 0, NULL,
530                         "new file descriptor %d is too large; you probably need "
531                         "to rebuild Apache with a larger FD_SETSIZE "
532                         "(currently %d)",
533                         sockdes, FD_SETSIZE);
534            apr_socket_close(csd);
535            return APR_EINTR;
536        }
537#endif
538        return : pass=0
r
eturn APR_SUCCESS;
539    }
540
541    if : true=0, false=0
i
f (APR_STATUS_IS_EINTR(status : os/unix/unixd.c line=517 column=18
s
tatus)) {
542        return : pass=0
r
eturn status : os/unix/unixd.c line=517 column=18
s
tatus;
543    }
544    /* Our old behaviour here was to continue after accept()
545     * errors.  But this leads us into lots of troubles
546     * because most of the errors are quite fatal.  For
547     * example, EMFILE can be caused by slow descriptor
548     * leaks (say in a 3rd party module, or libc).  It's
549     * foolish for us to continue after an EMFILE.  We also
550     * seem to tickle kernel bugs on some platforms which
551     * lead to never-ending loops here.  So it seems best
552     * to just exit in most cases.
553     */
554    switch : pass=0
s
witch (status : os/unix/unixd.c line=517 column=18
s
tatus) {
555#if defined(HPUX11) && defined(ENOBUFS)
556        /* On HPUX 11.x, the 'ENOBUFS, No buffer space available'
557         * error occurs because the accept() cannot complete.
558         * You will not see ENOBUFS with 10.20 because the kernel
559         * hides any occurrence from being returned to user space.
560         * ENOBUFS with 11.x's TCP/IP stack is possible, and could
561         * occur intermittently. As a work-around, we are going to
562         * ignore ENOBUFS.
563         */
564        case ENOBUFS:
565#endif
566
567#ifdef EPROTO
568        /* EPROTO on certain older kernels really means
569         * ECONNABORTED, so we need to ignore it for them.
570         * See discussion in new-httpd archives nh.9701
571         * search for EPROTO.
572         *
573         * Also see nh.9603, search for EPROTO:
574         * There is potentially a bug in Solaris 2.x x<6,
575         * and other boxes that implement tcp sockets in
576         * userland (i.e. on top of STREAMS).  On these
577         * systems, EPROTO can actually result in a fatal
578         * loop.  See PR#981 for example.  It's hard to
579         * handle both uses of EPROTO.
580         */
581        case : true=0, false=0
c
ase EPROTO:
582#endif
583#ifdef ECONNABORTED
584        case : true=0, false=0
c
ase ECONNABORTED:
585#endif
586        /* Linux generates the rest of these, other tcp
587         * stacks (i.e. bsd) tend to hide them behind
588         * getsockopt() interfaces.  They occur when
589         * the net goes sour or the client disconnects
590         * after the three-way handshake has been done
591         * in the kernel but before userland has picked
592         * up the socket.
593         */
594#ifdef ECONNRESET
595        case : true=0, false=0
c
ase ECONNRESET:
596#endif
597#ifdef ETIMEDOUT
598        case : true=0, false=0
c
ase ETIMEDOUT:
599#endif
600#ifdef EHOSTUNREACH
601        case : true=0, false=0
c
ase EHOSTUNREACH:
602#endif
603#ifdef ENETUNREACH
604        case : true=0, false=0
c
ase ENETUNREACH:
605#endif
606        /* EAGAIN/EWOULDBLOCK can be returned on BSD-derived
607         * TCP stacks when the connection is aborted before
608         * we call connect, but only because our listener
609         * sockets are non-blocking (AP_NONBLOCK_WHEN_MULTI_LISTEN)
610         */
611#ifdef EAGAIN
612        case : true=0, false=0
c
ase EAGAIN:
613#endif
614#ifdef EWOULDBLOCK
615#if !defined(EAGAIN) || EAGAIN != EWOULDBLOCK
616        case EWOULDBLOCK:
617#endif
618#endif
619            break : pass=0
b
reak;
620#ifdef ENETDOWN
621        case : true=0, false=0
c
ase ENETDOWN:
622            /*
623             * When the network layer has been shut down, there
624             * is not much use in simply exiting: the parent
625             * would simply re-create us (and we'd fail again).
626             * Use the CHILDFATAL code to tear the server down.
627             * @@@ Martin's idea for possible improvement:
628             * A different approach would be to define
629             * a new APEXIT_NETDOWN exit code, the reception
630             * of which would make the parent shutdown all
631             * children, then idle-loop until it detected that
632             * the network is up again, and restart the children.
633             * Ben Hyde noted that temporary ENETDOWN situations
634             * occur in mobile IP.
635             */
636            ap_log_error : enter=0, leave=0

ap_log_error : include/http_log.h line=171 column=18
a
p_log_error(APLOG_MARK, APLOG_EMERG, status : os/unix/unixd.c line=517 column=18
s
tatus, ap_server_conf : server/mpm/prefork/mpm.h line=60 column=20
a
p_server_conf,
637                         "apr_socket_accept: giving up.");
638            return : pass=0
r
eturn APR_EGENERAL;
639#endif /*ENETDOWN*/
640
641#ifdef TPF
642        case EINACT:
643            ap_log_error(APLOG_MARK, APLOG_EMERG, status, ap_server_conf,
644                         "offload device inactive");
645            return APR_EGENERAL;
646            break;
647        default:
648            ap_log_error(APLOG_MARK, APLOG_ERR, 0, ap_server_conf,
649                         "select/accept error (%d)", status);
650            return APR_EGENERAL;
651#else
652        default : true=0, false=0
d
efault:
653            ap_log_error : enter=0, leave=0

ap_log_error : include/http_log.h line=171 column=18
a
p_log_error(APLOG_MARK, APLOG_ERR, status : os/unix/unixd.c line=517 column=18
s
tatus, ap_server_conf : server/mpm/prefork/mpm.h line=60 column=20
a
p_server_conf,
654                         "apr_socket_accept: (client socket)");
655            return : pass=0
r
eturn APR_EGENERAL;
656#endif
657    }
658    return : pass=0
r
eturn status : os/unix/unixd.c line=517 column=18
s
tatus;
659}
660
661
662#ifdef _OSD_POSIX
663
664#include "apr_lib.h"
665
666#define USER_LEN 8
667
668typedef enum
669{
670    bs2_unknown,     /* not initialized yet. */
671    bs2_noFORK,      /* no fork() because -X flag was specified */
672    bs2_FORK,        /* only fork() because uid != 0 */
673    bs2_UFORK        /* Normally, ufork() is used to switch identities. */
674} bs2_ForkType;
675
676static bs2_ForkType forktype = bs2_unknown;
677
678
679static void ap_str_toupper(char *str)
680{
681    while (*str) {
682        *str = apr_toupper(*str);
683        ++str;
684    }
685}
686
687/* Determine the method for forking off a child in such a way as to
688 * set both the POSIX and BS2000 user id's to the unprivileged user.
689 */
690static bs2_ForkType os_forktype(int one_process)
691{
692    /* have we checked the OS version before? If yes return the previous
693     * result - the OS release isn't going to change suddenly!
694     */
695    if (forktype == bs2_unknown) {
696        /* not initialized yet */
697
698        /* No fork if the one_process option was set */
699        if (one_process) {
700            forktype = bs2_noFORK;
701        }
702        /* If the user is unprivileged, use the normal fork() only. */
703        else if (getuid() != 0) {
704            forktype = bs2_FORK;
705        }
706        else
707            forktype = bs2_UFORK;
708    }
709    return forktype;
710}
711
712
713
714/* This routine complements the setuid() call: it causes the BS2000 job
715 * environment to be switched to the target user's user id.
716 * That is important if CGI scripts try to execute native BS2000 commands.
717 */
718int os_init_job_environment(server_rec *server, const char *user_name, int one_process)
719{
720    bs2_ForkType            type = os_forktype(one_process);
721
722    /* We can be sure that no change to uid==0 is possible because of
723     * the checks in http_core.c:set_user()
724     */
725
726    if (one_process) {
727
728        type = forktype = bs2_noFORK;
729
730        ap_log_error(APLOG_MARK, APLOG_ERR, 0, server,
731                     "The debug mode of Apache should only "
732                     "be started by an unprivileged user!");
733        return 0;
734    }
735
736    return 0;
737}
738
739/* BS2000 requires a "special" version of fork() before a setuid() call */
740pid_t os_fork(const char *user)
741{
742    pid_t pid;
743    char  username[USER_LEN+1];
744
745    switch (os_forktype(0)) {
746
747      case bs2_FORK:
748        pid = fork();
749        break;
750
751      case bs2_UFORK:
752        apr_cpystrn(username, user, sizeof username);
753
754        /* Make user name all upper case - for some versions of ufork() */
755        ap_str_toupper(username);
756
757        pid = ufork(username);
758        if (pid == -1 && errno == EPERM) {
759            ap_log_error(APLOG_MARK, APLOG_EMERG, errno,
760                         NULL, "ufork: Possible mis-configuration "
761                         "for user %s - Aborting.", user);
762            exit(1);
763        }
764        break;
765
766      default:
767        pid = 0;
768        break;
769    }
770
771    return pid;
772}
773
774#endif /* _OSD_POSIX */
775
776[EOF]


Generated by expcov