/* Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * Copyright 2014 Cloud Linux Zug GmbH
 *
 * Licensed under CLOUD LINUX LICENSE AGREEMENT
 * http://cloudlinux.com/docs/LICENSE.TXT
 *
 * The part the support library for lsapi & proxy_lsapi Apache modules
 * author Alexander Demeshko <ademeshko@cloudlinux.com>
 *
 */

#ifndef _SULSPHP_H
#define _SULSPHP_H

#include <ap_config_layout.h>

#define SULSPHP_PROGRAM_NAME "sulsphp"

/*
 * HTTPD_USER -- Define as the username under which Apache normally
 *               runs.  This is the only user allowed to execute
 *               this program.
 */
#ifndef SULSPHP_HTTPD_USER

#ifdef AP_HTTPD_USER
#define SULSPHP_HTTPD_USER AP_HTTPD_USER
#else
#define SULSPHP_HTTPD_USER "nobody"
#endif //AP_HTTPD_USER

#endif //SULSPHP_HTTPD_USER

/*
 * PARENT_NAME -- Define name of Apache process. This is 
 *               the only process allowed to execute
 *               this program.
 */
#ifndef SULSPHP_PARENT_NAME
#define SULSPHP_PARENT_NAME "httpd"
#endif //SULSPHP_PARENT_NAME

/*
 * UID_MIN -- Define this as the lowest UID allowed to be a target user
 *            for sulsphp.  For most systems, 500 or 100 is common.
 */
#ifndef SULSPHP_UID_MIN

#ifdef AP_UID_MIN
#define SULSPHP_UID_MIN AP_UID_MIN
#else
#define SULSPHP_UID_MIN 100
#endif //AP_UID_MIN

#endif //SULSPHP_UID_MIN

/*
 * GID_MIN -- Define this as the lowest GID allowed to be a target group
 *            for sulsphp.  For most systems, 100 is common.
 */
#ifndef SULSPHP_GID_MIN

#ifdef AP_GID_MIN
#define SULSPHP_GID_MIN AP_GID_MIN
#else
#define SULSPHP_GID_MIN 100
#endif //AP_GID_MIN

#endif //SULSPHP_GID_MIN

/*
 * USERDIR_SUFFIX -- Define to be the subdirectory under users'
 *                   home directories where suEXEC access should
 *                   be allowed.  All executables under this directory
 *                   will be executable by suEXEC as the user so
 *                   they should be "safe" programs.  If you are
 *                   using a "simple" UserDir directive (ie. one
 *                   without a "*" in it) this should be set to
 *                   the same value.  suEXEC will not work properly
 *                   in cases where the UserDir directive points to
 *                   a location that is not the same as the user's
 *                   home directory as referenced in the passwd file.
 *
 *                   If you have VirtualHosts with a different
 *                   UserDir for each, you will need to define them to
 *                   all reside in one parent directory; then name that
 *                   parent directory here.  IF THIS IS NOT DEFINED
 *                   PROPERLY, ~USERDIR CGI REQUESTS WILL NOT WORK!
 *                   See the suEXEC documentation for more detailed
 *                   information.
 */
#ifndef SULSPHP_USERDIR_SUFFIX

#ifdef AP_USERDIR_SUFFIX
#define SULSPHP_USERDIR_SUFFIX AP_USERDIR_SUFFIX
#else
#define SULSPHP_USERDIR_SUFFIX "public_html"
#endif //AP_USERDIR_SUFFIX

#endif //SULSPHP_USERDIR_SUFFIX

/*
 * LOG_EXEC -- Define this as a filename if you want all 
 *             transactions and errors logged for auditing and
 *             debugging purposes.
 */
#ifdef SULSPHP_LOG_EXEC
#undef SULSPHP_LOG_EXEC
#endif //SULSPHP_LOG_EXEC
#define SULSPHP_LOG_EXEC DEFAULT_EXP_LOGFILEDIR "/" SULSPHP_PROGRAM_NAME "_log"

/*
 * DOC_ROOT -- Define as the DocumentRoot set for Apache.  This
 *             will be the only hierarchy (aside from UserDirs)
 *             that can be used for su behavior.
 */
#ifndef SULSPHP_DOC_ROOT

#ifdef AP_DOC_ROOT
#define SULSPHP_DOC_ROOT AP_DOC_ROOT
#else
#define SULSPHP_DOC_ROOT "/"
#endif //AP_DOC_ROOT

#endif //SULSPHP_DOC_ROOT

/*
 * SAFE_PATH -- Define a safe PATH environment to pass to executable.
 *
 */
#ifndef SULSPHP_SAFE_PATH

#ifdef AP_SAFE_PATH
#define SULSPHP_SAFE_PATH AP_SAFE_PATH
#else
#define SULSPHP_SAFE_PATH "/usr/local/bin:/usr/bin:/bin"
#endif //AP_SAFE_PATH

#endif //SULSPHP_SAFE_PATH

/*
 * ALLOWED_CMD -- Define the only allowed executable.
 *
 */
#ifndef SULSPHP_ALLOWED_CMD
#define SULSPHP_ALLOWED_CMD "lsphp"
#endif // SULSPHP_ALLOWED_CMD

/*
 * ALLOWED_DIR -- Define a allowable directory.
 *
 */
#ifndef SULSPHP_ALLOWED_DIR
#define SULSPHP_ALLOWED_DIR "/usr/local/bin"
#endif // SULSPHP_ALLOWED_DIR

/*
 * SAFE_DIR -- Define a safe directory.
 *
 */
#ifndef SULSPHP_SAFE_DIR
#define SULSPHP_SAFE_DIR "/opt/alt"
#endif // SULSPHP_SAFE_DIR

int create_listen_socket( const char *sock_name, int backlog );

#endif /* _SULSPHP_H */
