Apache HTTPD
mod_md_os.c
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
17#include <assert.h>
18#include <apr_strings.h>
19
20#include <mpm_common.h>
21#include <httpd.h>
22#include <http_log.h>
23#include <ap_mpm.h>
24
25#if APR_HAVE_UNISTD_H
26#include <unistd.h>
27#endif
28#if AP_NEED_SET_MUTEX_PERMS
29#include "unixd.h"
30#endif
31
32#include "md_util.h"
33#include "mod_md_os.h"
34
35apr_status_t md_try_chown(const char *fname, unsigned int uid, int gid, apr_pool_t *p)
36{
37#if AP_NEED_SET_MUTEX_PERMS && HAVE_UNISTD_H
38 /* Since we only switch user when running as root, we only need to chown directories
39 * in that case. Otherwise, the server will ignore any "user/group" directives and
40 * child processes have the same privileges as the parent.
41 */
42 if (!geteuid()) {
43 if (-1 == chown(fname, (uid_t)uid, (gid_t)gid)) {
45 if (!APR_STATUS_IS_ENOENT(rv)) {
47 "Can't change owner of %s", fname);
48 }
49 return rv;
50 }
51 }
52 return APR_SUCCESS;
53#else
54 return APR_ENOTIMPL;
55#endif
56}
57
59{
60#ifdef WIN32
61 return APR_ENOTIMPL;
62#else
63 return md_try_chown(fname, ap_unixd_config.user_id, -1, p);
64#endif
65}
66
67#ifdef WIN32
68
70{
71 return APR_ENOTIMPL;
72}
73
74#else
75
77{
78 apr_status_t rv;
79
80 (void)p;
81 (void)s;
83 ap_log_error(APLOG_MARK, APLOG_TRACE1, errno, NULL, "sent signal to parent");
84 return rv;
85}
86
87#endif
88
Apache Multi-Processing Module library.
APR Strings library.
#define APLOGNO(n)
Definition http_log.h:117
#define APLOG_ERR
Definition http_log.h:67
#define ap_log_error
Definition http_log.h:370
#define APLOG_MARK
Definition http_log.h:283
#define ap_log_perror
Definition http_log.h:412
#define APLOG_TRACE1
Definition http_log.h:72
#define AP_SIG_GRACEFUL
Definition mpm_common.h:67
#define APR_ENOTIMPL
Definition apr_errno.h:476
apr_fileperms_t apr_uid_t uid
apr_fileperms_t apr_uid_t apr_gid_t gid
#define APR_STATUS_IS_ENOENT(s)
Definition apr_errno.h:1246
apr_size_t size
#define APR_FROM_OS_ERROR(e)
Definition apr_errno.h:1214
#define APR_SUCCESS
Definition apr_errno.h:225
int apr_status_t
Definition apr_errno.h:44
const char * fname
const char * s
Definition apr_strings.h:95
Apache Logging library.
HTTP Daemon routines.
apr_pool_t * p
Definition md_event.c:32
apr_status_t md_try_chown(const char *fname, unsigned int uid, int gid, apr_pool_t *p)
Definition mod_md_os.c:35
apr_status_t md_make_worker_accessible(const char *fname, apr_pool_t *p)
Definition mod_md_os.c:58
apr_status_t md_server_graceful(apr_pool_t *p, server_rec *s)
Definition mod_md_os.c:76
return NULL
Definition mod_so.c:359
Multi-Processing Modules functions.
A structure to store information for each virtual server.
Definition httpd.h:1322