suexec.html.en revision 19737f4fbef1805f9c3e9e045bb6d710a1e5e10f
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd<?xml version="1.0" encoding="ISO-8859-1"?>
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd This file is generated from xml source: DO NOT EDIT
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd -->
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd<title>suEXEC Support - Apache HTTP Server</title>
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd<link href="/style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd<link href="/style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen<link href="/style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="/style/css/prettify.css" />
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen<script src="/style/scripts/prettify.js" type="text/javascript">
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen</script>
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd<link href="/images/favicon.ico" rel="shortcut icon" /></head>
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd<body id="manual-page"><div id="page-header">
af33a4994ae2ff15bc67d19ff1a7feb906745bf8rbowen<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="/glossary.html">Glossary</a> | <a href="/sitemap.html">Sitemap</a></p>
3f08db06526d6901aa08c110b5bc7dde6bc39905nd<p class="apache">Apache HTTP Server Version 2.5</p>
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd<img alt="" src="/images/feather.gif" /></div>
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd<div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="/images/left.gif" /></a></div>
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd<div id="path">
3f08db06526d6901aa08c110b5bc7dde6bc39905nd<a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">HTTP Server</a> &gt; <a href="http://httpd.apache.org/docs/">Documentation</a> &gt; <a href="./">Version 2.5</a></div><div id="page-content"><div id="preamble"><h1>suEXEC Support</h1>
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd<div class="toplang">
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd<p><span>Available Languages: </span><a href="/en/suexec.html" title="English">&nbsp;en&nbsp;</a> |
1c8f2418892d98febb00a06b9a4f45f8bcfd80a3nd<a href="/fr/suexec.html" hreflang="fr" rel="alternate" title="Fran�ais">&nbsp;fr&nbsp;</a> |
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd<a href="/ja/suexec.html" hreflang="ja" rel="alternate" title="Japanese">&nbsp;ja&nbsp;</a> |
bf7fcf0c216a914407c0877aa37894fd9aecc219nilgun<a href="/ko/suexec.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a> |
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjung<a href="/tr/suexec.html" hreflang="tr" rel="alternate" title="T�rk�e">&nbsp;tr&nbsp;</a></p>
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd</div>
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf
4b575a6b6704b516f22d65a3ad35696d7b9ba372rpluem <p>The <strong>suEXEC</strong> feature provides users of the Apache
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd HTTP Server the ability
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd to run <strong>CGI</strong> and <strong>SSI</strong> programs
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd under user IDs different from the user ID of the calling
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd web server. Normally, when a CGI or SSI program executes, it
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd runs as the same user who is running the web server.</p>
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd <p>Used properly, this feature can reduce
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd considerably the security risks involved with allowing users to
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd develop and run private CGI or SSI programs. However, if suEXEC
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd is improperly configured, it can cause any number of problems
30471a4650391f57975f60bbb6e4a90be7b284bfhumbedooh and possibly create new holes in your computer's security. If
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd you aren't familiar with managing <em>setuid root</em> programs
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd and the security issues they present, we highly recommend that
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd you not consider using suEXEC.</p>
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd </div>
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd<div id="quickview"><ul id="toc"><li><img alt="" src="/images/down.gif" /> <a href="#before">Before we begin</a></li>
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd<li><img alt="" src="/images/down.gif" /> <a href="#model">suEXEC Security Model</a></li>
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd<li><img alt="" src="/images/down.gif" /> <a href="#install">Configuring &amp; Installing
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd suEXEC</a></li>
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd<li><img alt="" src="/images/down.gif" /> <a href="#enable">Enabling &amp; Disabling
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd suEXEC</a></li>
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd<li><img alt="" src="/images/down.gif" /> <a href="#usage">Using suEXEC</a></li>
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd<li><img alt="" src="/images/down.gif" /> <a href="#debug">Debugging suEXEC</a></li>
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd<li><img alt="" src="/images/down.gif" /> <a href="#jabberwock">Beware the Jabberwock:
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd Warnings &amp; Examples</a></li>
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd</ul><ul class="seealso"><li><a href="#comments_section">Comments</a></li></ul></div>
5effc8b39fae5cd169d17f342bfc265705840014rbowen<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd<div class="section">
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd<h2><a name="before" id="before">Before we begin</a></h2>
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd <p>Before jumping head-first into this document,
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd you should be aware that certain assumptions are made about you and
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd the environment in which you will be using suexec.</p>
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd <p>First, it is assumed that you are using a UNIX
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd derivative operating system that is capable of
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd <strong>setuid</strong> and <strong>setgid</strong> operations.
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd All command examples are given in this regard. Other platforms,
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd if they are capable of supporting suEXEC, may differ in their
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd configuration.</p>
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd <p>Second, it is assumed you are familiar with
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd some basic concepts of your computer's security and its
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd administration. This involves an understanding of
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd <strong>setuid/setgid</strong> operations and the various
f5a398cc8880978754903f9ece8e4beb63a81cedrbowen effects they may have on your system and its level of
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd security.</p>
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd <p>Third, it is assumed that you are using an
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd <strong>unmodified</strong> version of suEXEC code. All code
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd for suEXEC has been carefully scrutinized and tested by the
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd developers as well as numerous beta testers. Every precaution
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd has been taken to ensure a simple yet solidly safe base of
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd code. Altering this code can cause unexpected problems and new
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd security risks. It is <strong>highly</strong> recommended you
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd not alter the suEXEC code unless you are well versed in the
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd particulars of security programming and are willing to share
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd your work with the Apache HTTP Server development team for consideration.</p>
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd <p>Fourth, and last, it has been the decision of
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd the Apache HTTP Server development team to <strong>NOT</strong> make suEXEC part of
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd the default installation of Apache httpd. To this end, suEXEC
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd configuration requires of the administrator careful attention
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd to details. After due consideration has been given to the
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd various settings for suEXEC, the administrator may install
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd suEXEC through normal installation methods. The values for
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd these settings need to be carefully determined and specified by
ec878843fb39a84bac1e1c2e1a2b821b1b7882fend the administrator to properly maintain system security during
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd the use of suEXEC functionality. It is through this detailed
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd process that we hope to limit suEXEC
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd installation only to those who are careful and determined
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd enough to use it.</p>
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd <p>Still with us? Yes? Good. Let's move on!</p>
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd<div class="section">
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd<h2><a name="model" id="model">suEXEC Security Model</a></h2>
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd <p>Before we begin configuring and installing
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd suEXEC, we will first discuss the security model you are about
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd to implement. By doing so, you may better understand what
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd exactly is going on inside suEXEC and what precautions are
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd taken to ensure your system's security.</p>
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd <p><strong>suEXEC</strong> is based on a setuid
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd "wrapper" program that is called by the main Apache HTTP Server.
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd This wrapper is called when an HTTP request is made for a CGI
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd or SSI program that the administrator has designated to run as
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd a userid other than that of the main server. When such a
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd request is made, Apache httpd provides the suEXEC wrapper with the
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd program's name and the user and group IDs under which the
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd program is to execute.</p>
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd <p>The wrapper then employs the following process
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd to determine success or failure -- if any one of these
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd conditions fail, the program logs the failure and exits with an
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd error, otherwise it will continue:</p>
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd <ol>
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd <li>
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd <strong>Is the user executing this wrapper a valid user of
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd this system?</strong>
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd
1c8f2418892d98febb00a06b9a4f45f8bcfd80a3nd <p class="indent">
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd This is to ensure that the user executing the wrapper is
bf7fcf0c216a914407c0877aa37894fd9aecc219nilgun truly a user of the system.
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjung </p>
727872d18412fc021f03969b8641810d8896820bhumbedooh </li>
0d0ba3a410038e179b695446bb149cce6264e0abnd
727872d18412fc021f03969b8641810d8896820bhumbedooh <li>
cc7e1025de9ac63bd4db6fe7f71c158b2cf09fe4humbedooh <strong>Was the wrapper called with the proper number of
0d0ba3a410038e179b695446bb149cce6264e0abnd arguments?</strong>
cc7e1025de9ac63bd4db6fe7f71c158b2cf09fe4humbedooh
727872d18412fc021f03969b8641810d8896820bhumbedooh <p class="indent">
0d0ba3a410038e179b695446bb149cce6264e0abnd The wrapper will only execute if it is given the proper
0d0ba3a410038e179b695446bb149cce6264e0abnd number of arguments. The proper argument format is known
0d0ba3a410038e179b695446bb149cce6264e0abnd to the Apache HTTP Server. If the wrapper is not receiving
ac082aefa89416cbdc9a1836eaf3bed9698201c8humbedooh the proper number of arguments, it is either being
0d0ba3a410038e179b695446bb149cce6264e0abnd hacked, or there is something wrong with the suEXEC
0d0ba3a410038e179b695446bb149cce6264e0abnd portion of your Apache httpd binary.
0d0ba3a410038e179b695446bb149cce6264e0abnd </p>
727872d18412fc021f03969b8641810d8896820bhumbedooh </li>
0d0ba3a410038e179b695446bb149cce6264e0abnd
0d0ba3a410038e179b695446bb149cce6264e0abnd <li>
30471a4650391f57975f60bbb6e4a90be7b284bfhumbedooh <strong>Is this valid user allowed to run the
1a1356f375e36db7bee379ea0684ab389579f798rbowen wrapper?</strong>
af33a4994ae2ff15bc67d19ff1a7feb906745bf8rbowen
0d0ba3a410038e179b695446bb149cce6264e0abnd <p class="indent">
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd Is this user the user allowed to run this wrapper? Only
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd one user (the Apache user) is allowed to execute this
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd program.
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd </p>
</li>
<li>
<strong>Does the target CGI or SSI program have an unsafe
hierarchical reference?</strong>
<p class="indent">
Does the target CGI or SSI program's path contain a leading
'/' or have a '..' backreference? These are not allowed; the
target CGI/SSI program must reside within suEXEC's document
root (see <code>--with-suexec-docroot=<em>DIR</em></code>
below).
</p>
</li>
<li>
<strong>Is the target user name valid?</strong>
<p class="indent">
Does the target user exist?
</p>
</li>
<li>
<strong>Is the target group name valid?</strong>
<p class="indent">
Does the target group exist?
</p>
</li>
<li>
<strong>Is the target user <em>NOT</em> superuser?</strong>
<p class="indent">
suEXEC does not allow <code><em>root</em></code>
to execute CGI/SSI programs.
</p>
</li>
<li>
<strong>Is the target userid <em>ABOVE</em> the minimum ID
number?</strong>
<p class="indent">
The minimum user ID number is specified during
configuration. This allows you to set the lowest possible
userid that will be allowed to execute CGI/SSI programs.
This is useful to block out "system" accounts.
</p>
</li>
<li>
<strong>Is the target group <em>NOT</em> the superuser
group?</strong>
<p class="indent">
Presently, suEXEC does not allow the <code><em>root</em></code>
group to execute CGI/SSI programs.
</p>
</li>
<li>
<strong>Is the target groupid <em>ABOVE</em> the minimum ID
number?</strong>
<p class="indent">
The minimum group ID number is specified during
configuration. This allows you to set the lowest possible
groupid that will be allowed to execute CGI/SSI programs.
This is useful to block out "system" groups.
</p>
</li>
<li>
<strong>Can the wrapper successfully become the target user
and group?</strong>
<p class="indent">
Here is where the program becomes the target user and
group via setuid and setgid calls. The group access list
is also initialized with all of the groups of which the
user is a member.
</p>
</li>
<li>
<strong>Can we change directory to the one in which the target
CGI/SSI program resides?</strong>
<p class="indent">
If it doesn't exist, it can't very well contain files. If we
can't change directory to it, it might as well not exist.
</p>
</li>
<li>
<strong>Is the directory within the httpd webspace?</strong>
<p class="indent">
If the request is for a regular portion of the server, is
the requested directory within suEXEC's document root? If
the request is for a <code class="directive"><a href="/mod/mod_userdir.html#userdir">UserDir</a></code>, is the requested directory
within the directory configured as suEXEC's userdir (see
<a href="#install">suEXEC's configuration options</a>)?
</p>
</li>
<li>
<strong>Is the directory <em>NOT</em> writable by anyone
else?</strong>
<p class="indent">
We don't want to open up the directory to others; only
the owner user may be able to alter this directories
contents.
</p>
</li>
<li>
<strong>Does the target CGI/SSI program exist?</strong>
<p class="indent">
If it doesn't exists, it can't very well be executed.
</p>
</li>
<li>
<strong>Is the target CGI/SSI program <em>NOT</em> writable
by anyone else?</strong>
<p class="indent">
We don't want to give anyone other than the owner the
ability to change the CGI/SSI program.
</p>
</li>
<li>
<strong>Is the target CGI/SSI program <em>NOT</em> setuid or
setgid?</strong>
<p class="indent">
We do not want to execute programs that will then change
our UID/GID again.
</p>
</li>
<li>
<strong>Is the target user/group the same as the program's
user/group?</strong>
<p class="indent">
Is the user the owner of the file?
</p>
</li>
<li>
<strong>Can we successfully clean the process environment
to ensure safe operations?</strong>
<p class="indent">
suEXEC cleans the process' environment by establishing a
safe execution PATH (defined during configuration), as
well as only passing through those variables whose names
are listed in the safe environment list (also created
during configuration).
</p>
</li>
<li>
<strong>Can we successfully become the target CGI/SSI program
and execute?</strong>
<p class="indent">
Here is where suEXEC ends and the target CGI/SSI program begins.
</p>
</li>
</ol>
<p>This is the standard operation of the
suEXEC wrapper's security model. It is somewhat stringent and
can impose new limitations and guidelines for CGI/SSI design,
but it was developed carefully step-by-step with security in
mind.</p>
<p>For more information as to how this security
model can limit your possibilities in regards to server
configuration, as well as what security risks can be avoided
with a proper suEXEC setup, see the <a href="#jabberwock">"Beware the Jabberwock"</a> section of this
document.</p>
</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
<div class="section">
<h2><a name="install" id="install">Configuring &amp; Installing
suEXEC</a></h2>
<p>Here's where we begin the fun.</p>
<p><strong>suEXEC configuration
options</strong><br />
</p>
<dl>
<dt><code>--enable-suexec</code></dt>
<dd>This option enables the suEXEC feature which is never
installed or activated by default. At least one
<code>--with-suexec-xxxxx</code> option has to be provided
together with the <code>--enable-suexec</code> option to let
APACI accept your request for using the suEXEC feature.</dd>
<dt><code>--with-suexec-bin=<em>PATH</em></code></dt>
<dd>The path to the <code>suexec</code> binary must be hard-coded
in the server for security reasons. Use this option to override
the default path. <em>e.g.</em>
<code>--with-suexec-bin=/usr/sbin/suexec</code></dd>
<dt><code>--with-suexec-caller=<em>UID</em></code></dt>
<dd>The <a href="mod/mpm_common.html#user">username</a> under which
httpd normally runs. This is the only user allowed to
execute the suEXEC wrapper.</dd>
<dt><code>--with-suexec-userdir=<em>DIR</em></code></dt>
<dd>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" <code class="directive"><a href="/mod/mod_userdir.html#userdir">UserDir</a></code>
directive (ie. one without a "*" in it) this should be set to the same
value. suEXEC will not work properly in cases where the <code class="directive"><a href="/mod/mod_userdir.html#userdir">UserDir</a></code> directive points to
a location that is not the same as the user's home directory
as referenced in the <code>passwd</code> file. Default value is
"<code>public_html</code>".<br />
If you have virtual hosts with a different <code class="directive"><a href="/mod/mod_userdir.html#userdir">UserDir</a></code> for each,
you will need to define them to all reside in one parent
directory; then name that parent directory here. <strong>If
this is not defined properly, "~userdir" cgi requests will
not work!</strong></dd>
<dt><code>--with-suexec-docroot=<em>DIR</em></code></dt>
<dd>Define as the DocumentRoot set for httpd. This will be
the only hierarchy (aside from <code class="directive"><a href="/mod/mod_userdir.html#userdir">UserDir</a></code>s) that can be used for suEXEC behavior. The
default directory is the <code>--datadir</code> value with the suffix
"<code>/htdocs</code>", <em>e.g.</em> if you configure with
"<code>--datadir=/home/apache</code>" the directory
"<code>/home/apache/htdocs</code>" is used as document root for the
suEXEC wrapper.</dd>
<dt><code>--with-suexec-uidmin=<em>UID</em></code></dt>
<dd>Define this as the lowest UID allowed to be a target user
for suEXEC. For most systems, 500 or 100 is common. Default
value is 100.</dd>
<dt><code>--with-suexec-gidmin=<em>GID</em></code></dt>
<dd>Define this as the lowest GID allowed to be a target
group for suEXEC. For most systems, 100 is common and
therefore used as default value.</dd>
<dt><code>--with-suexec-logfile=<em>FILE</em></code></dt>
<dd>This defines the filename to which all suEXEC
transactions and errors are logged (useful for auditing and
debugging purposes). By default the logfile is named
"<code>suexec_log</code>" and located in your standard logfile
directory (<code>--logfiledir</code>).</dd>
<dt><code>--with-suexec-safepath=<em>PATH</em></code></dt>
<dd>Define a safe PATH environment to pass to CGI
executables. Default value is
"<code>/usr/local/bin:/usr/bin:/bin</code>".</dd>
</dl>
<h3>Compiling and installing the suEXEC wrapper</h3>
<p>If you have enabled the suEXEC feature with the
<code>--enable-suexec</code> option the <code>suexec</code> binary
(together with httpd itself) is automatically built if you execute
the <code>make</code> command.</p>
<p>After all components have been built you can execute the
command <code>make install</code> to install them. The binary image
<code>suexec</code> is installed in the directory defined by the
<code>--sbindir</code> option. The default location is
"/usr/local/apache2/bin/suexec".</p>
<p>Please note that you need <strong><em>root
privileges</em></strong> for the installation step. In order
for the wrapper to set the user ID, it must be installed as
owner <code><em>root</em></code> and must have the setuserid
execution bit set for file modes.</p>
<h3>Setting paranoid permissions</h3>
<p>Although the suEXEC wrapper will check to ensure that its
caller is the correct user as specified with the
<code>--with-suexec-caller</code> <code class="program"><a href="/programs/configure.html">configure</a></code>
option, there is
always the possibility that a system or library call suEXEC uses
before this check may be exploitable on your system. To counter
this, and because it is best-practise in general, you should use
filesystem permissions to ensure that only the group httpd
runs as may execute suEXEC.</p>
<p>If for example, your web server is configured to run as:</p>
<pre class="prettyprint lang-config">
User www
Group webgroup
</pre>
<p>and <code class="program"><a href="/programs/suexec.html">suexec</a></code> is installed at
"/usr/local/apache2/bin/suexec", you should run:</p>
<div class="example"><p><code>
chgrp webgroup /usr/local/apache2/bin/suexec<br />
chmod 4750 /usr/local/apache2/bin/suexec<br />
</code></p></div>
<p>This will ensure that only the group httpd runs as can even
execute the suEXEC wrapper.</p>
</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
<div class="section">
<h2><a name="enable" id="enable">Enabling &amp; Disabling
suEXEC</a></h2>
<p>Upon startup of httpd, it looks for the file
<code class="program"><a href="/programs/suexec.html">suexec</a></code> in the directory defined by the
<code>--sbindir</code> option (default is
"/usr/local/apache/sbin/suexec"). If httpd finds a properly
configured suEXEC wrapper, it will print the following message
to the error log:</p>
<div class="example"><p><code>
[notice] suEXEC mechanism enabled (wrapper: <var>/path/to/suexec</var>)
</code></p></div>
<p>If you don't see this message at server startup, the server is
most likely not finding the wrapper program where it expects
it, or the executable is not installed <em>setuid root</em>.</p>
<p>If you want to enable the suEXEC mechanism for the first time
and an Apache HTTP Server is already running you must kill and
restart httpd. Restarting it with a simple HUP or USR1 signal
will not be enough. </p>
<p>If you want to disable suEXEC you should kill and restart
httpd after you have removed the <code class="program"><a href="/programs/suexec.html">suexec</a></code> file.</p>
</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
<div class="section">
<h2><a name="usage" id="usage">Using suEXEC</a></h2>
<p>Requests for CGI programs will call the suEXEC wrapper only if
they are for a virtual host containing a <code class="directive"><a href="/mod/mod_suexec.html#suexecusergroup">SuexecUserGroup</a></code> directive or if
they are processed by <code class="module"><a href="/mod/mod_userdir.html">mod_userdir</a></code>.</p>
<p><strong>Virtual Hosts:</strong><br /> One way to use the suEXEC
wrapper is through the <code class="directive"><a href="/mod/mod_suexec.html#suexecusergroup">SuexecUserGroup</a></code> directive in
<code class="directive"><a href="/mod/core.html#virtualhost">VirtualHost</a></code> definitions. By
setting this directive to values different from the main server
user ID, all requests for CGI resources will be executed as the
<em>User</em> and <em>Group</em> defined for that <code class="directive"><a href="/mod/core.html#virtualhost">&lt;VirtualHost&gt;</a></code>. If this
directive is not specified for a <code class="directive"><a href="/mod/core.html#virtualhost">&lt;VirtualHost&gt;</a></code> then the main server userid
is assumed.</p>
<p><strong>User directories:</strong><br /> Requests that are
processed by <code class="module"><a href="/mod/mod_userdir.html">mod_userdir</a></code> will call the suEXEC
wrapper to execute CGI programs under the userid of the requested
user directory. The only requirement needed for this feature to
work is for CGI execution to be enabled for the user and that the
script must meet the scrutiny of the <a href="#model">security
checks</a> above. See also the
<code>--with-suexec-userdir</code> <a href="#install">compile
time option</a>.</p> </div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
<div class="section">
<h2><a name="debug" id="debug">Debugging suEXEC</a></h2>
<p>The suEXEC wrapper will write log information
to the file defined with the <code>--with-suexec-logfile</code>
option as indicated above. If you feel you have configured and
installed the wrapper properly, have a look at this log and the
error_log for the server to see where you may have gone astray.</p>
</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
<div class="section">
<h2><a name="jabberwock" id="jabberwock">Beware the Jabberwock:
Warnings &amp; Examples</a></h2>
<p><strong>NOTE!</strong> This section may not be
complete. For the latest revision of this section of the
documentation, see the <a href="http://httpd.apache.org/docs/trunk/suexec.html">Online
Documentation</a> version.</p>
<p>There are a few points of interest regarding
the wrapper that can cause limitations on server setup. Please
review these before submitting any "bugs" regarding suEXEC.</p>
<ul>
<li><strong>suEXEC Points Of Interest</strong></li>
<li>
Hierarchy limitations
<p class="indent">
For security and efficiency reasons, all suEXEC requests
must remain within either a top-level document root for
virtual host requests, or one top-level personal document
root for userdir requests. For example, if you have four
VirtualHosts configured, you would need to structure all
of your VHosts' document roots off of one main httpd
document hierarchy to take advantage of suEXEC for
VirtualHosts. (Example forthcoming.)
</p>
</li>
<li>
suEXEC's PATH environment variable
<p class="indent">
This can be a dangerous thing to change. Make certain
every path you include in this define is a
<strong>trusted</strong> directory. You don't want to
open people up to having someone from across the world
running a trojan horse on them.
</p>
</li>
<li>
Altering the suEXEC code
<p class="indent">
Again, this can cause <strong>Big Trouble</strong> if you
try this without knowing what you are doing. Stay away
from it if at all possible.
</p>
</li>
</ul>
</div></div>
<div class="bottomlang">
<p><span>Available Languages: </span><a href="/en/suexec.html" title="English">&nbsp;en&nbsp;</a> |
<a href="/fr/suexec.html" hreflang="fr" rel="alternate" title="Fran�ais">&nbsp;fr&nbsp;</a> |
<a href="/ja/suexec.html" hreflang="ja" rel="alternate" title="Japanese">&nbsp;ja&nbsp;</a> |
<a href="/ko/suexec.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a> |
<a href="/tr/suexec.html" hreflang="tr" rel="alternate" title="T�rk�e">&nbsp;tr&nbsp;</a></p>
</div><div class="top"><a href="#page-header"><img src="/images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">Comments</a></h2><div class="warning"><strong>This section is experimental!</strong><br />Comments placed here should not be expected
to last beyond the testing phase of this system, nor do we in any way guarantee that we'll read them.</div>
<script type="text/javascript"><!--//--><![CDATA[//><!--
var lang = 'en';
var disqus_shortname = 'httpd';
var disqus_identifier = window.location.href.replace(/(current|trunk)/, "2.4").replace(/\/[a-z]{2}\//, "/").replace(window.location.protocol, "http:") + '.' + lang;
if (disqus_identifier.indexOf("httpd.apache.org") == -1) {
document.write('<div id="disqus_thread">\n</div>');
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = window.location.protocol + '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
} else {
document.write("Comments have been disabled for offline viewing.");
}
//--><!]]></script></div><div id="footer">
<p class="apache">Copyright 2012 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="/glossary.html">Glossary</a> | <a href="/sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!--
if (typeof(prettyPrint) !== undefined) {
prettyPrint();
}
//--><!]]></script>
</body></html>