summaryrefslogtreecommitdiff
path: root/support/suexec.c
diff options
context:
space:
mode:
authorStefan Fritsch <sf@apache.org>2009-10-04 07:57:32 +0000
committerStefan Fritsch <sf@apache.org>2009-10-04 07:57:32 +0000
commit3e9367c8d2a3b7d1d4c948056a0aa32070226a60 (patch)
treef451f45193106efe9d8fd1815d940ea0eea2cf40 /support/suexec.c
parentfbdde88b36bc806e4f79113f6d171d170af27849 (diff)
downloadhttpd-3e9367c8d2a3b7d1d4c948056a0aa32070226a60.tar.gz
Only use fcntl() if we have fcntl.h
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@821475 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'support/suexec.c')
-rw-r--r--support/suexec.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/support/suexec.c b/support/suexec.c
index 1ef4e0928f..e4c4ecb4bf 100644
--- a/support/suexec.c
+++ b/support/suexec.c
@@ -46,7 +46,9 @@
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
+#if APR_HAVE_FCNTL_H
#include <fcntl.h>
+#endif
#ifdef HAVE_PWD_H
#include <pwd.h>
@@ -575,17 +577,27 @@ int main(int argc, char *argv[])
umask(AP_SUEXEC_UMASK);
#endif /* AP_SUEXEC_UMASK */
- /*
- * ask fcntl(2) to set the FD_CLOEXEC flag on the log file,
- * so it'll be automagically closed if the exec() call succeeds.
- */
+ /* Be sure to close the log file so the CGI can't mess with it. */
if (log != NULL) {
+#if APR_HAVE_FCNTL_H
+ /*
+ * ask fcntl(2) to set the FD_CLOEXEC flag on the log file,
+ * so it'll be automagically closed if the exec() call succeeds.
+ */
fflush(log);
- setbuf(log,NULL);
+ setbuf(log, NULL);
if ((fcntl(fileno(log), F_SETFD, FD_CLOEXEC) == -1)) {
log_err("error: can't set close-on-exec flag");
exit(122);
}
+#else
+ /*
+ * In this case, exec() errors won't be logged because we have already
+ * dropped privileges and won't be able to reopen the log file.
+ */
+ fclose(log);
+ log = NULL;
+#endif
}
/*