You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by "Ralf S. Engelschall" <rs...@engelschall.com> on 1998/06/09 19:15:12 UTC
[PATCH] Config check option (PR#2393)
The above patch is my configcheckoption patch enhanced to also solve the
problem of PR#2393. It adds an httpd -t option which can be used both by the
user manually and is automatically used by apachectl before restarts to make
sure the config files are not broken.
Votes for 1.3.1-dev?
Ralf S. Engelschall
rse@engelschall.com
www.engelschall.com
Index: src/CHANGES
===================================================================
RCS file: /e/apache/REPOS/apache-1.3/src/CHANGES,v
retrieving revision 1.904
diff -u -r1.904 CHANGES
--- CHANGES 1998/06/09 12:59:18 1.904
+++ CHANGES 1998/06/09 17:06:23
@@ -1,5 +1,13 @@
Changes with Apache 1.3.1
+ *) Add httpd -t option for running configuration checks only. If something
+ is broken it complains and exits with a return code non-equal to 0. This
+ can be used manually to check a configuration after editing and is
+ automatically used by apachectl on restart and graceful restart commands
+ to make sure Apache doesn't die on restarts because of a broken
+ configuration.
+ [Ralf S. Engelschall] PR#2393
+
*) Make sure the DSO emulation code for HPUX finds the proprietary shl_xxx()
functions which are in libdld under HPUX 9/10.
[Ralf S. Engelschall] PR#2378
Index: src/main/http_main.c
===================================================================
RCS file: /e/apache/REPOS/apache-1.3/src/main/http_main.c,v
retrieving revision 1.362
diff -u -r1.362 http_main.c
--- http_main.c 1998/06/08 20:32:16 1.362
+++ http_main.c 1998/06/09 16:59:22
@@ -877,7 +877,7 @@
fprintf(stderr, "Usage: %s [-d directory] [-f file]\n", bin);
#endif
fprintf(stderr, " %s [-C \"directive\"] [-c \"directive\"]\n", pad);
- fprintf(stderr, " %s [-v] [-V] [-h] [-l] [-S]\n", pad);
+ fprintf(stderr, " %s [-v] [-V] [-h] [-l] [-S] [-t]\n", pad);
fprintf(stderr, "Options:\n");
#ifdef SHARED_CORE
fprintf(stderr, " -L directory : specify an alternate location for shared object files\n");
@@ -891,6 +891,7 @@
fprintf(stderr, " -h : list available configuration directives\n");
fprintf(stderr, " -l : list compiled-in modules\n");
fprintf(stderr, " -S : show parsed settings (currently only vhost settings)\n");
+ fprintf(stderr, " -t : run syntax test for configuration files only\n");
exit(1);
}
@@ -4201,6 +4202,7 @@
int REALMAIN(int argc, char *argv[])
{
int c;
+ int configtestonly = 0;
#ifdef SecureWare
if (set_auth_parameters(argc, argv) < 0)
@@ -4227,7 +4229,7 @@
ap_setup_prelinked_modules();
while ((c = getopt(argc, argv,
- "C:c:Xd:f:vVhlL:S"
+ "C:c:Xd:f:vVhlL:St"
#ifdef DEBUG_SIGSTOP
"Z:"
#endif
@@ -4283,6 +4285,9 @@
case 'S':
ap_dump_settings = 1;
break;
+ case 't':
+ configtestonly = 1;
+ break;
case '?':
usage(argv[0]);
}
@@ -4291,6 +4296,11 @@
ap_suexec_enabled = init_suexec();
server_conf = ap_read_config(pconf, ptrans, ap_server_confname);
+ if (configtestonly) {
+ fprintf(stderr, "Syntax OK\n");
+ exit(0);
+ }
+
child_timeouts = !ap_standalone || one_process;
if (ap_standalone) {
@@ -5356,6 +5366,7 @@
char *cp;
int run_as_service = 1;
int install = 0;
+ int configtestonly = 0;
common_init();
@@ -5380,7 +5391,7 @@
ap_setup_prelinked_modules();
- while ((c = getopt(argc, argv, "C:c:Xd:f:vVhlZ:iusS")) != -1) {
+ while ((c = getopt(argc, argv, "C:c:Xd:f:vVhlZ:iusSt")) != -1) {
char **new;
switch (c) {
case 'c':
@@ -5438,6 +5449,9 @@
case 'X':
++one_process; /* Weird debugging mode. */
break;
+ case 't':
+ configtestonly = 1;
+ break;
case '?':
usage(argv[0]);
}
@@ -5448,6 +5462,12 @@
}
server_conf = ap_read_config(pconf, ptrans, ap_server_confname);
+
+ if (configtestonly) {
+ fprintf(stderr, "Syntax OK\n");
+ exit(0);
+ }
+
if (!child) {
ap_log_pid(pconf, ap_pid_fname);
}
Index: src/support/apachectl
===================================================================
RCS file: /e/apache/REPOS/apache-1.3/src/support/apachectl,v
retrieving revision 1.6
diff -u -r1.6 apachectl
--- apachectl 1998/03/31 12:53:46 1.6
+++ apachectl 1998/06/09 17:11:23
@@ -97,11 +97,16 @@
ERROR=5
fi
else
- if kill -HUP $PID ; then
- echo "$0 $ARG: httpd restarted"
+ if ! $HTTPD -t >/dev/null 2>&1; then
+ echo "$0 $ARG: configuration broken -- ignoring restart command"
+ ERROR=7
else
- echo "$0 $ARG: httpd could not be restarted"
- ERROR=6
+ if kill -HUP $PID ; then
+ echo "$0 $ARG: httpd restarted"
+ else
+ echo "$0 $ARG: httpd could not be restarted"
+ ERROR=6
+ fi
fi
fi
;;
@@ -115,11 +120,16 @@
ERROR=5
fi
else
- if kill -USR1 $PID ; then
- echo "$0 $ARG: httpd gracefully restarted"
- else
- echo "$0 $ARG: httpd could not be restarted"
+ if ! $HTTPD -t >/dev/null 2>&1; then
+ echo "$0 $ARG: configuration broken -- ignoring restart command"
ERROR=7
+ else
+ if kill -USR1 $PID ; then
+ echo "$0 $ARG: httpd gracefully restarted"
+ else
+ echo "$0 $ARG: httpd could not be restarted"
+ ERROR=7
+ fi
fi
fi
;;
Index: src/support/httpd.8
===================================================================
RCS file: /e/apache/REPOS/apache-1.3/src/support/httpd.8,v
retrieving revision 1.9
diff -u -r1.9 httpd.8
--- httpd.8 1998/05/12 11:14:31 1.9
+++ httpd.8 1998/05/12 12:21:05
@@ -149,6 +149,11 @@
Show the settings as parsed from the config file (currently only shows the
virtualhost settings).
.TP
+.B \-t
+Run syntax checks for configuration files only. The program immediately exits
+after these checks with either a return code of 0 (Syntax OK) or return code
+not equal to 0 (Syntax Error).
+.TP
.B \-X
Run in single-process mode, for internal debugging purposes only; the daemon
does not detach from the terminal or fork any children. Do NOT use this mode
Re: [PATCH] Config check option (PR#2393)
Posted by Martin Kraemer <Ma...@mch.sni.de>.
On Tue, Jun 09, 1998 at 08:15:12PM +0200, Ralf S. Engelschall wrote:
> [...] It adds an httpd -t option which can be used both by the
> user manually and is automatically used by apachectl before restarts to make
> sure the config files are not broken.
>
> Votes for 1.3.1-dev?
Absolutely +1! Ten-Four!
Though untested, the change looks uncritical enough.
Martin
--
| S I E M E N S | <Ma...@mch.sni.de> | Siemens Nixdorf
| ------------- | Voice: +49-89-636-46021 | Informationssysteme AG
| N I X D O R F | FAX: +49-89-636-44994 | 81730 Munich, Germany
~~~~~~~~~~~~~~~~My opinions only, of course; pgp key available on request
Re: [PATCH] Config check option (PR#2393)
Posted by Rasmus Lerdorf <ra...@lerdorf.on.ca>.
> +1 cool, I've wanted this for ages.
Me too. So why haven't we added it? Dunno, waiting for Ralf to do it, I
guess.
-Rasmus
Re: [PATCH] Config check option (PR#2393)
Posted by Dean Gaudet <dg...@arctic.org>.
+1 cool, I've wanted this for ages.
Dean
On Tue, 9 Jun 1998, Ralf S. Engelschall wrote:
>
> The above patch is my configcheckoption patch enhanced to also solve the
> problem of PR#2393. It adds an httpd -t option which can be used both by the
> user manually and is automatically used by apachectl before restarts to make
> sure the config files are not broken.
>
> Votes for 1.3.1-dev?
> Ralf S. Engelschall
> rse@engelschall.com
> www.engelschall.com
>
> Index: src/CHANGES
> ===================================================================
> RCS file: /e/apache/REPOS/apache-1.3/src/CHANGES,v
> retrieving revision 1.904
> diff -u -r1.904 CHANGES
> --- CHANGES 1998/06/09 12:59:18 1.904
> +++ CHANGES 1998/06/09 17:06:23
> @@ -1,5 +1,13 @@
> Changes with Apache 1.3.1
>
> + *) Add httpd -t option for running configuration checks only. If something
> + is broken it complains and exits with a return code non-equal to 0. This
> + can be used manually to check a configuration after editing and is
> + automatically used by apachectl on restart and graceful restart commands
> + to make sure Apache doesn't die on restarts because of a broken
> + configuration.
> + [Ralf S. Engelschall] PR#2393
> +
> *) Make sure the DSO emulation code for HPUX finds the proprietary shl_xxx()
> functions which are in libdld under HPUX 9/10.
> [Ralf S. Engelschall] PR#2378
> Index: src/main/http_main.c
> ===================================================================
> RCS file: /e/apache/REPOS/apache-1.3/src/main/http_main.c,v
> retrieving revision 1.362
> diff -u -r1.362 http_main.c
> --- http_main.c 1998/06/08 20:32:16 1.362
> +++ http_main.c 1998/06/09 16:59:22
> @@ -877,7 +877,7 @@
> fprintf(stderr, "Usage: %s [-d directory] [-f file]\n", bin);
> #endif
> fprintf(stderr, " %s [-C \"directive\"] [-c \"directive\"]\n", pad);
> - fprintf(stderr, " %s [-v] [-V] [-h] [-l] [-S]\n", pad);
> + fprintf(stderr, " %s [-v] [-V] [-h] [-l] [-S] [-t]\n", pad);
> fprintf(stderr, "Options:\n");
> #ifdef SHARED_CORE
> fprintf(stderr, " -L directory : specify an alternate location for shared object files\n");
> @@ -891,6 +891,7 @@
> fprintf(stderr, " -h : list available configuration directives\n");
> fprintf(stderr, " -l : list compiled-in modules\n");
> fprintf(stderr, " -S : show parsed settings (currently only vhost settings)\n");
> + fprintf(stderr, " -t : run syntax test for configuration files only\n");
> exit(1);
> }
>
> @@ -4201,6 +4202,7 @@
> int REALMAIN(int argc, char *argv[])
> {
> int c;
> + int configtestonly = 0;
>
> #ifdef SecureWare
> if (set_auth_parameters(argc, argv) < 0)
> @@ -4227,7 +4229,7 @@
> ap_setup_prelinked_modules();
>
> while ((c = getopt(argc, argv,
> - "C:c:Xd:f:vVhlL:S"
> + "C:c:Xd:f:vVhlL:St"
> #ifdef DEBUG_SIGSTOP
> "Z:"
> #endif
> @@ -4283,6 +4285,9 @@
> case 'S':
> ap_dump_settings = 1;
> break;
> + case 't':
> + configtestonly = 1;
> + break;
> case '?':
> usage(argv[0]);
> }
> @@ -4291,6 +4296,11 @@
> ap_suexec_enabled = init_suexec();
> server_conf = ap_read_config(pconf, ptrans, ap_server_confname);
>
> + if (configtestonly) {
> + fprintf(stderr, "Syntax OK\n");
> + exit(0);
> + }
> +
> child_timeouts = !ap_standalone || one_process;
>
> if (ap_standalone) {
> @@ -5356,6 +5366,7 @@
> char *cp;
> int run_as_service = 1;
> int install = 0;
> + int configtestonly = 0;
>
> common_init();
>
> @@ -5380,7 +5391,7 @@
>
> ap_setup_prelinked_modules();
>
> - while ((c = getopt(argc, argv, "C:c:Xd:f:vVhlZ:iusS")) != -1) {
> + while ((c = getopt(argc, argv, "C:c:Xd:f:vVhlZ:iusSt")) != -1) {
> char **new;
> switch (c) {
> case 'c':
> @@ -5438,6 +5449,9 @@
> case 'X':
> ++one_process; /* Weird debugging mode. */
> break;
> + case 't':
> + configtestonly = 1;
> + break;
> case '?':
> usage(argv[0]);
> }
> @@ -5448,6 +5462,12 @@
> }
>
> server_conf = ap_read_config(pconf, ptrans, ap_server_confname);
> +
> + if (configtestonly) {
> + fprintf(stderr, "Syntax OK\n");
> + exit(0);
> + }
> +
> if (!child) {
> ap_log_pid(pconf, ap_pid_fname);
> }
> Index: src/support/apachectl
> ===================================================================
> RCS file: /e/apache/REPOS/apache-1.3/src/support/apachectl,v
> retrieving revision 1.6
> diff -u -r1.6 apachectl
> --- apachectl 1998/03/31 12:53:46 1.6
> +++ apachectl 1998/06/09 17:11:23
> @@ -97,11 +97,16 @@
> ERROR=5
> fi
> else
> - if kill -HUP $PID ; then
> - echo "$0 $ARG: httpd restarted"
> + if ! $HTTPD -t >/dev/null 2>&1; then
> + echo "$0 $ARG: configuration broken -- ignoring restart command"
> + ERROR=7
> else
> - echo "$0 $ARG: httpd could not be restarted"
> - ERROR=6
> + if kill -HUP $PID ; then
> + echo "$0 $ARG: httpd restarted"
> + else
> + echo "$0 $ARG: httpd could not be restarted"
> + ERROR=6
> + fi
> fi
> fi
> ;;
> @@ -115,11 +120,16 @@
> ERROR=5
> fi
> else
> - if kill -USR1 $PID ; then
> - echo "$0 $ARG: httpd gracefully restarted"
> - else
> - echo "$0 $ARG: httpd could not be restarted"
> + if ! $HTTPD -t >/dev/null 2>&1; then
> + echo "$0 $ARG: configuration broken -- ignoring restart command"
> ERROR=7
> + else
> + if kill -USR1 $PID ; then
> + echo "$0 $ARG: httpd gracefully restarted"
> + else
> + echo "$0 $ARG: httpd could not be restarted"
> + ERROR=7
> + fi
> fi
> fi
> ;;
> Index: src/support/httpd.8
> ===================================================================
> RCS file: /e/apache/REPOS/apache-1.3/src/support/httpd.8,v
> retrieving revision 1.9
> diff -u -r1.9 httpd.8
> --- httpd.8 1998/05/12 11:14:31 1.9
> +++ httpd.8 1998/05/12 12:21:05
> @@ -149,6 +149,11 @@
> Show the settings as parsed from the config file (currently only shows the
> virtualhost settings).
> .TP
> +.B \-t
> +Run syntax checks for configuration files only. The program immediately exits
> +after these checks with either a return code of 0 (Syntax OK) or return code
> +not equal to 0 (Syntax Error).
> +.TP
> .B \-X
> Run in single-process mode, for internal debugging purposes only; the daemon
> does not detach from the terminal or fork any children. Do NOT use this mode
>
Re: [PATCH] Config check option (PR#2393)
Posted by Brian Behlendorf <br...@hyperreal.org>.
At 07:15 PM 6/9/98 +0200, Ralf S. Engelschall wrote:
>
>The above patch is my configcheckoption patch enhanced to also solve the
>problem of PR#2393. It adds an httpd -t option which can be used both by the
>user manually and is automatically used by apachectl before restarts to make
>sure the config files are not broken.
>
>Votes for 1.3.1-dev?
Untested, but definitely +1 on the idea, and the patch looks clean upon
inspection.
Brian
--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--
pure chewing satisfaction brian@apache.org
brian@hyperreal.org