unixd.h revision 24c37fed37c126e979b4b750e9d2bd05ccb479a5
0066eddda7203f6345b56f77d146a759298dc635gryzor/* ====================================================================
0066eddda7203f6345b56f77d146a759298dc635gryzor * The Apache Software License, Version 1.1
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd *
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd * Copyright (c) 2000-2001 The Apache Software Foundation. All rights
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd * reserved.
0066eddda7203f6345b56f77d146a759298dc635gryzor *
0066eddda7203f6345b56f77d146a759298dc635gryzor * Redistribution and use in source and binary forms, with or without
0066eddda7203f6345b56f77d146a759298dc635gryzor * modification, are permitted provided that the following conditions
0066eddda7203f6345b56f77d146a759298dc635gryzor * are met:
96ad5d81ee4a2cc66a4ae19893efc8aa6d06fae7jailletc *
0066eddda7203f6345b56f77d146a759298dc635gryzor * 1. Redistributions of source code must retain the above copyright
0066eddda7203f6345b56f77d146a759298dc635gryzor * notice, this list of conditions and the following disclaimer.
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen *
2e545ce2450a9953665f701bb05350f0d3f26275nd * 2. Redistributions in binary form must reproduce the above copyright
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen * notice, this list of conditions and the following disclaimer in
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen * the documentation and/or other materials provided with the
0066eddda7203f6345b56f77d146a759298dc635gryzor * distribution.
0066eddda7203f6345b56f77d146a759298dc635gryzor *
0066eddda7203f6345b56f77d146a759298dc635gryzor * 3. The end-user documentation included with the redistribution,
af33a4994ae2ff15bc67d19ff1a7feb906745bf8rbowen * if any, must include the following acknowledgment:
3f08db06526d6901aa08c110b5bc7dde6bc39905nd * "This product includes software developed by the
0066eddda7203f6345b56f77d146a759298dc635gryzor * Apache Software Foundation (http://www.apache.org/)."
0066eddda7203f6345b56f77d146a759298dc635gryzor * Alternately, this acknowledgment may appear in the software itself,
0066eddda7203f6345b56f77d146a759298dc635gryzor * if and wherever such third-party acknowledgments normally appear.
3f08db06526d6901aa08c110b5bc7dde6bc39905nd *
0066eddda7203f6345b56f77d146a759298dc635gryzor * 4. The names "Apache" and "Apache Software Foundation" must
0066eddda7203f6345b56f77d146a759298dc635gryzor * not be used to endorse or promote products derived from this
0066eddda7203f6345b56f77d146a759298dc635gryzor * software without prior written permission. For written
0066eddda7203f6345b56f77d146a759298dc635gryzor * permission, please contact apache@apache.org.
0066eddda7203f6345b56f77d146a759298dc635gryzor *
0066eddda7203f6345b56f77d146a759298dc635gryzor * 5. Products derived from this software may not be called "Apache",
0066eddda7203f6345b56f77d146a759298dc635gryzor * nor may "Apache" appear in their name, without prior written
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjung * permission of the Apache Software Foundation.
0066eddda7203f6345b56f77d146a759298dc635gryzor *
0066eddda7203f6345b56f77d146a759298dc635gryzor * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
0066eddda7203f6345b56f77d146a759298dc635gryzor * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
0066eddda7203f6345b56f77d146a759298dc635gryzor * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
0066eddda7203f6345b56f77d146a759298dc635gryzor * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
0066eddda7203f6345b56f77d146a759298dc635gryzor * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0066eddda7203f6345b56f77d146a759298dc635gryzor * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0066eddda7203f6345b56f77d146a759298dc635gryzor * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
cd8142d105a47b208d863bea7cdb540727a5f02digalic * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
cd8142d105a47b208d863bea7cdb540727a5f02digalic * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
cd8142d105a47b208d863bea7cdb540727a5f02digalic * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
cd8142d105a47b208d863bea7cdb540727a5f02digalic * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
cd8142d105a47b208d863bea7cdb540727a5f02digalic * SUCH DAMAGE.
0066eddda7203f6345b56f77d146a759298dc635gryzor * ====================================================================
0066eddda7203f6345b56f77d146a759298dc635gryzor *
0066eddda7203f6345b56f77d146a759298dc635gryzor * This software consists of voluntary contributions made by many
0066eddda7203f6345b56f77d146a759298dc635gryzor * individuals on behalf of the Apache Software Foundation. For more
0066eddda7203f6345b56f77d146a759298dc635gryzor * information on the Apache Software Foundation, please see
0066eddda7203f6345b56f77d146a759298dc635gryzor * <http://www.apache.org/>.
0066eddda7203f6345b56f77d146a759298dc635gryzor *
0066eddda7203f6345b56f77d146a759298dc635gryzor * Portions of this software are based upon public domain software
0066eddda7203f6345b56f77d146a759298dc635gryzor * originally written at the National Center for Supercomputing Applications,
0066eddda7203f6345b56f77d146a759298dc635gryzor * University of Illinois, Urbana-Champaign.
0066eddda7203f6345b56f77d146a759298dc635gryzor */
0066eddda7203f6345b56f77d146a759298dc635gryzor
0066eddda7203f6345b56f77d146a759298dc635gryzor#ifndef UNIXD_H
cd8142d105a47b208d863bea7cdb540727a5f02digalic#define UNIXD_H
30471a4650391f57975f60bbb6e4a90be7b284bfhumbedooh
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar#include "httpd.h"
0066eddda7203f6345b56f77d146a759298dc635gryzor#include "http_config.h"
e3e52ec6993de04bb0100e098ce0a569c7001382lgentis#ifdef HAVE_SYS_TIME_H
0066eddda7203f6345b56f77d146a759298dc635gryzor#include <sys/time.h>
0066eddda7203f6345b56f77d146a759298dc635gryzor#endif
0066eddda7203f6345b56f77d146a759298dc635gryzor#ifdef HAVE_SYS_RESOURCE_H
0066eddda7203f6345b56f77d146a759298dc635gryzor#include <sys/resource.h>
0066eddda7203f6345b56f77d146a759298dc635gryzor#endif
0066eddda7203f6345b56f77d146a759298dc635gryzor#include "apr_hooks.h"
fed47023e9be04c612b5f6d4a5ee2b8e7c587181rbowen#include "apr_thread_proc.h"
0066eddda7203f6345b56f77d146a759298dc635gryzor
0066eddda7203f6345b56f77d146a759298dc635gryzor#include <pwd.h>
0066eddda7203f6345b56f77d146a759298dc635gryzor#include <grp.h>
cd8142d105a47b208d863bea7cdb540727a5f02digalic#include <sys/types.h>
cd8142d105a47b208d863bea7cdb540727a5f02digalic
cd8142d105a47b208d863bea7cdb540727a5f02digalictypedef struct {
cd8142d105a47b208d863bea7cdb540727a5f02digalic uid_t uid;
cd8142d105a47b208d863bea7cdb540727a5f02digalic gid_t gid;
cd8142d105a47b208d863bea7cdb540727a5f02digalic} ap_unix_identity_t;
0066eddda7203f6345b56f77d146a759298dc635gryzor
20f499565e77defe9dab24dd85c02f38a1175855ndAP_DECLARE_HOOK(ap_unix_identity_t *, get_suexec_identity,(const request_rec *r))
fd5a091eb07540ab440f8ac3a277caa590be46c1humbedooh
0066eddda7203f6345b56f77d146a759298dc635gryzor/* common stuff that unix MPMs will want */
0066eddda7203f6345b56f77d146a759298dc635gryzor
0066eddda7203f6345b56f77d146a759298dc635gryzor/* Default user name and group name. These may be specified as numbers by
e3e52ec6993de04bb0100e098ce0a569c7001382lgentis * placing a # before a number */
0066eddda7203f6345b56f77d146a759298dc635gryzor
0066eddda7203f6345b56f77d146a759298dc635gryzor#ifndef DEFAULT_USER
3eb3e9ec9cf7a169a917d660a28241de54241773rbowen#define DEFAULT_USER "#-1"
0066eddda7203f6345b56f77d146a759298dc635gryzor#endif
fed47023e9be04c612b5f6d4a5ee2b8e7c587181rbowen#ifndef DEFAULT_GROUP
0066eddda7203f6345b56f77d146a759298dc635gryzor#define DEFAULT_GROUP "#-1"
0066eddda7203f6345b56f77d146a759298dc635gryzor#endif
0066eddda7203f6345b56f77d146a759298dc635gryzor
cd8142d105a47b208d863bea7cdb540727a5f02digalictypedef struct {
cd8142d105a47b208d863bea7cdb540727a5f02digalic const char *user_name;
cd8142d105a47b208d863bea7cdb540727a5f02digalic uid_t user_id;
0066eddda7203f6345b56f77d146a759298dc635gryzor gid_t group_id;
20f499565e77defe9dab24dd85c02f38a1175855nd int suexec_enabled;
fd5a091eb07540ab440f8ac3a277caa590be46c1humbedooh} unixd_config_rec;
3eb3e9ec9cf7a169a917d660a28241de54241773rbowenextern unixd_config_rec unixd_config;
3eb3e9ec9cf7a169a917d660a28241de54241773rbowen
3eb3e9ec9cf7a169a917d660a28241de54241773rbowenint unixd_setup_child(void);
3eb3e9ec9cf7a169a917d660a28241de54241773rbowenvoid unixd_pre_config(apr_pool_t *ptemp);
cd8142d105a47b208d863bea7cdb540727a5f02digalicconst char *unixd_set_user(cmd_parms *cmd, void *dummy, const char *arg);
cd8142d105a47b208d863bea7cdb540727a5f02digalicconst char *unixd_set_group(cmd_parms *cmd, void *dummy, const char *arg);
cd8142d105a47b208d863bea7cdb540727a5f02digalic#if defined(RLIMIT_CPU) || defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_NPROC) || defined(RLIMIT_AS)
cd8142d105a47b208d863bea7cdb540727a5f02digalicAP_DECLARE(void) unixd_set_rlimit(cmd_parms *cmd, struct rlimit **plimit,
cd8142d105a47b208d863bea7cdb540727a5f02digalic const char *arg, const char * arg2, int type);
cd8142d105a47b208d863bea7cdb540727a5f02digalic#endif
cd8142d105a47b208d863bea7cdb540727a5f02digalic
a1ceb0cd0152edea3c72f4d9dcb352bae6ef273fjorton
cd8142d105a47b208d863bea7cdb540727a5f02digalic#ifdef HAVE_KILLPG
cd8142d105a47b208d863bea7cdb540727a5f02digalic#define unixd_killpg(x, y) (killpg ((x), (y)))
0066eddda7203f6345b56f77d146a759298dc635gryzor#else /* HAVE_KILLPG */
cd8142d105a47b208d863bea7cdb540727a5f02digalic#define unixd_killpg(x, y) (kill (-(x), (y)))
cd8142d105a47b208d863bea7cdb540727a5f02digalic#endif /* HAVE_KILLPG */
cd8142d105a47b208d863bea7cdb540727a5f02digalic
cd8142d105a47b208d863bea7cdb540727a5f02digalic#define UNIX_DAEMON_COMMANDS \
cd8142d105a47b208d863bea7cdb540727a5f02digalicAP_INIT_TAKE1("User", unixd_set_user, NULL, RSRC_CONF, \
0066eddda7203f6345b56f77d146a759298dc635gryzor "Effective user id for this server"), \
0066eddda7203f6345b56f77d146a759298dc635gryzorAP_INIT_TAKE1("Group", unixd_set_group, NULL, RSRC_CONF, \
e3e52ec6993de04bb0100e098ce0a569c7001382lgentis "Effective group id for this server"),
0066eddda7203f6345b56f77d146a759298dc635gryzor
0066eddda7203f6345b56f77d146a759298dc635gryzor#endif
0066eddda7203f6345b56f77d146a759298dc635gryzor