unixd.h revision b682e60dd82772dba52ba77138e494f15c00a551
97a9a944b5887e91042b019776c41d5dd74557aferikabele/* Licensed to the Apache Software Foundation (ASF) under one or more
97a9a944b5887e91042b019776c41d5dd74557aferikabele * contributor license agreements. See the NOTICE file distributed with
97a9a944b5887e91042b019776c41d5dd74557aferikabele * this work for additional information regarding copyright ownership.
a945f35eff8b6a88009ce73de6d4c862ce58de3cslive * The ASF licenses this file to You under the Apache License, Version 2.0
a945f35eff8b6a88009ce73de6d4c862ce58de3cslive * (the "License"); you may not use this file except in compliance with
a945f35eff8b6a88009ce73de6d4c862ce58de3cslive * the License. You may obtain a copy of the License at
b686b6a420bde7f78c416b90be11db94cb789979nd *
b686b6a420bde7f78c416b90be11db94cb789979nd * http://www.apache.org/licenses/LICENSE-2.0
b686b6a420bde7f78c416b90be11db94cb789979nd *
b686b6a420bde7f78c416b90be11db94cb789979nd * Unless required by applicable law or agreed to in writing, software
b686b6a420bde7f78c416b90be11db94cb789979nd * distributed under the License is distributed on an "AS IS" BASIS,
b686b6a420bde7f78c416b90be11db94cb789979nd * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
b686b6a420bde7f78c416b90be11db94cb789979nd * See the License for the specific language governing permissions and
b686b6a420bde7f78c416b90be11db94cb789979nd * limitations under the License.
3f08db06526d6901aa08c110b5bc7dde6bc39905nd */
b686b6a420bde7f78c416b90be11db94cb789979nd
b686b6a420bde7f78c416b90be11db94cb789979nd/**
b686b6a420bde7f78c416b90be11db94cb789979nd * @file unixd.h
3f08db06526d6901aa08c110b5bc7dde6bc39905nd * @brief common stuff that unix MPMs will want
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd *
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd * @addtogroup APACHE_OS_UNIX
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd * @{
b05ab3ff5ab54aa22610b13d56eaba6ddfc3db60nd */
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor
7f5b59ccc63c0c0e3e678a168f09ee6a2f51f9d0nd#ifndef UNIXD_H
63f06dce77bb2d9b1c5aa5deeb47a1069987fd1end#define UNIXD_H
d474d8ef01ec5c2a09341cd148851ed383c3287crbowen
d474d8ef01ec5c2a09341cd148851ed383c3287crbowen#include "httpd.h"
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd#include "http_config.h"
b686b6a420bde7f78c416b90be11db94cb789979nd#include "ap_listen.h"
06ba4a61654b3763ad65f52283832ebf058fdf1cslive#ifdef HAVE_SYS_TIME_H
06ba4a61654b3763ad65f52283832ebf058fdf1cslive#include <sys/time.h>
381b101317d64df9ce37f788d903a999f9f26ca7rbowen#endif
381b101317d64df9ce37f788d903a999f9f26ca7rbowen#ifdef HAVE_SYS_RESOURCE_H
06ba4a61654b3763ad65f52283832ebf058fdf1cslive#include <sys/resource.h>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive#endif
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd#include "apr_hooks.h"
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd#include "apr_thread_proc.h"
5b10fd3977e6dfff19afe770e612e276962f7950nd#include "apr_proc_mutex.h"
5b10fd3977e6dfff19afe770e612e276962f7950nd#include "apr_global_mutex.h"
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd#include <pwd.h>
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd#include <grp.h>
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd#if APR_HAVE_SYS_TYPES_H
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd#include <sys/types.h>
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd#endif
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd#ifdef HAVE_SYS_IPC_H
5b10fd3977e6dfff19afe770e612e276962f7950nd#include <sys/ipc.h>
5b10fd3977e6dfff19afe770e612e276962f7950nd#endif
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd#ifdef __cplusplus
2aff288113d772cedca6add888eb643afffe9fb1ndextern "C" {
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd#endif
2aff288113d772cedca6add888eb643afffe9fb1nd
166c7891cc2a7545eca0f4dda6af92026bc43fcfrpluemtypedef struct {
166c7891cc2a7545eca0f4dda6af92026bc43fcfrpluem uid_t uid;
2aff288113d772cedca6add888eb643afffe9fb1nd gid_t gid;
2aff288113d772cedca6add888eb643afffe9fb1nd int userdir;
316f02e3836836c82e19019ff23f90a7ebc65289nilgun} ap_unix_identity_t;
2aff288113d772cedca6add888eb643afffe9fb1nd
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2ndAP_DECLARE_HOOK(ap_unix_identity_t *, get_suexec_identity,(const request_rec *r))
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd
2aff288113d772cedca6add888eb643afffe9fb1nd
2aff288113d772cedca6add888eb643afffe9fb1nd/* Default user name and group name. These may be specified as numbers by
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd * placing a # before a number */
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd#ifndef DEFAULT_USER
b43f840409794ed298e8634f6284741f193b6c4ftakashi#define DEFAULT_USER "#-1"
7ec4d5cc4aa574e3191bc5a612e68fd8f25ab7earpluem#endif
7ec4d5cc4aa574e3191bc5a612e68fd8f25ab7earpluem#ifndef DEFAULT_GROUP
7ec4d5cc4aa574e3191bc5a612e68fd8f25ab7earpluem#define DEFAULT_GROUP "#-1"
2aff288113d772cedca6add888eb643afffe9fb1nd#endif
2aff288113d772cedca6add888eb643afffe9fb1nd
2aff288113d772cedca6add888eb643afffe9fb1ndtypedef struct {
50c04f297d76a57ead2fa6b73845f7563b1fc788sf const char *user_name;
2aff288113d772cedca6add888eb643afffe9fb1nd uid_t user_id;
2aff288113d772cedca6add888eb643afffe9fb1nd gid_t group_id;
2aff288113d772cedca6add888eb643afffe9fb1nd int suexec_enabled;
2aff288113d772cedca6add888eb643afffe9fb1nd const char *chroot_dir;
635e08c1d8332adc365b1c20bbe3577d59ebcd78kess const char *suexec_disabled_reason; /* suitable msg if !suexec_enabled */
d9b843d090f14405079b4a61a493316cd3f1e5b9minfrin} unixd_config_rec;
2aff288113d772cedca6add888eb643afffe9fb1ndAP_DECLARE_DATA extern unixd_config_rec ap_unixd_config;
2aff288113d772cedca6add888eb643afffe9fb1nd
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin#if defined(RLIMIT_CPU) || defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_NPROC) || defined(RLIMIT_AS)
909ce17e2bd0faef7b1c294f2307f009793fd493ndAP_DECLARE(void) ap_unixd_set_rlimit(cmd_parms *cmd, struct rlimit **plimit,
2aff288113d772cedca6add888eb643afffe9fb1nd const char *arg,
2aff288113d772cedca6add888eb643afffe9fb1nd const char * arg2, int type);
a29610af88e278144045bfa1bc63b4a1a4b5ff14trawick#endif
a29610af88e278144045bfa1bc63b4a1a4b5ff14trawick
42af92a661a06b3cebc88d585aad75064a309d51nd/**
42af92a661a06b3cebc88d585aad75064a309d51nd * One of the functions to set mutex permissions should be called in
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin * the parent process on platforms that switch identity when the
6fe26506780e73be2a412d758af77fafdf03291and * server is started as root.
2aff288113d772cedca6add888eb643afffe9fb1nd * If the child init logic is performed before switching identity
2aff288113d772cedca6add888eb643afffe9fb1nd * (e.g., MPM setup for an accept mutex), it should only be called
2aff288113d772cedca6add888eb643afffe9fb1nd * for SysV semaphores. Otherwise, it is safe to call it for all
2aff288113d772cedca6add888eb643afffe9fb1nd * mutex types.
64c02f1310b7747423957823ee09fb3608430f89nd */
aa0b2780958e9b1467c9d0153a05738e399811a5ndAP_DECLARE(apr_status_t) ap_unixd_set_proc_mutex_perms(apr_proc_mutex_t *pmutex);
2aff288113d772cedca6add888eb643afffe9fb1ndAP_DECLARE(apr_status_t) ap_unixd_set_global_mutex_perms(apr_global_mutex_t *gmutex);
2aff288113d772cedca6add888eb643afffe9fb1ndAP_DECLARE(apr_status_t) ap_unixd_accept(void **accepted, ap_listen_rec *lr, apr_pool_t *ptrans);
2aff288113d772cedca6add888eb643afffe9fb1nd
43f6cc6aa3312619633538b8978619a48c0ce52eminfrin#ifdef HAVE_KILLPG
4624ec7c743a08f22e90521b97d612c9499ae7efminfrin#define ap_unixd_killpg(x, y) (killpg ((x), (y)))
78f97ce162b66a0dbfd7af4dcd9984f162569b04minfrin#define ap_os_killpg(x, y) (killpg ((x), (y)))
0734f81384d5f2528bb119f89d135043a280d5b2minfrin#else /* HAVE_KILLPG */
0734f81384d5f2528bb119f89d135043a280d5b2minfrin#define ap_unixd_killpg(x, y) (kill (-(x), (y)))
2aff288113d772cedca6add888eb643afffe9fb1nd#define ap_os_killpg(x, y) (kill (-(x), (y)))
2aff288113d772cedca6add888eb643afffe9fb1nd#endif /* HAVE_KILLPG */
2aff288113d772cedca6add888eb643afffe9fb1nd
2aff288113d772cedca6add888eb643afffe9fb1nd#ifdef __cplusplus
2aff288113d772cedca6add888eb643afffe9fb1nd}
7906201913b68fe78b9d6a22ab33bf21d82c490eminfrin#endif
7906201913b68fe78b9d6a22ab33bf21d82c490eminfrin
2aff288113d772cedca6add888eb643afffe9fb1nd#endif
e67fa8d3f161e595dd448fc24a591ee17ae59131nd/** @} */
05ede5110427cb9dc071cc671d5aaba5d3b88c79nd