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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 * Given one or more group identifers on the command line (e.g.,
19 * "httpd" or "#-1"), figure out whether they'll be valid for
20 * the server to use at run-time.
22 * If a groupname isn't found, or we can't setgid() to it, return
23 * -1. If all groups are valid, return 0.
25 * This may need to be run as the superuser for the setgid() to
26 * succeed; running it as any other user may result in a false
30 #include "ap_config.h"
37 #if APR_HAVE_SYS_TYPES_H
38 #include <sys/types.h>
47 int main(int argc
, char *argv
[])
53 struct group fake_grent
;
59 for (i
= 1; i
< argc
; ++i
) {
64 * If it's from a 'Group #-1' statement, get the numeric value
65 * and skip the group lookup stuff.
69 fake_grent
.gr_gid
= gid
;
73 grent
= getgrnam(arg
);
77 * A NULL return means no such group was found, so we're done
81 fprintf(stderr
, "%s: group '%s' not found\n", argv
[0], arg
);
88 * See if we can switch to the numeric GID we have. If so,
89 * all well and good; if not, well..
94 fprintf(stderr
, "%s: invalid group '%s'\n", argv
[0], arg
);
101 * Worst-case return value.
108 * c-file-style: "bsd"