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