httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ryan Bloom <...@covalent.net>
Subject [PATCH] Remove the Port directive.
Date Thu, 04 Oct 2001 03:24:04 GMT

This patch completely deprectates the Port directive.  The ServerName
directive is now overloaded, so that admins specify the port and name on
the same directive.  It also makes Listen a required directive.  Pay attention
to that.  There are no default ports with this patch.  If your config doesn't have
a Listen directive, the server doesn't start, and it emits an error.

I am a bit hesitant to commit this without some feedback, because it is a pretty
major change.  Before I commit this, I will update all of the docs.

Thoughts?

Ryan

? build.log
? build.err
? modules/httpd-pop3
? srclib/apr/build.log
? srclib/apr/build.err
? srclib/apr/test/build.log
? srclib/apr/test/build.err
Index: docs/conf/httpd-std.conf
===================================================================
RCS file: /home/cvs/httpd-2.0/docs/conf/httpd-std.conf,v
retrieving revision 1.52
diff -u -d -b -w -u -r1.52 httpd-std.conf
--- docs/conf/httpd-std.conf	2001/10/03 18:56:38	1.52
+++ docs/conf/httpd-std.conf	2001/10/04 02:49:00
@@ -231,12 +231,6 @@
 #
 
 #
-# Port: The port to which the standalone server listens. For
-# ports < 1023, you will need httpd to be run as root initially.
-#
-Port @@Port@@
-
-#
 # If you wish httpd to run as a different user or group, you must run
 # httpd as root initially and it will switch.  
 #
@@ -270,7 +264,7 @@
 # You will have to access it by its address (e.g., http://123.45.67.89/)
 # anyway, and this will make redirections work in a sensible way.
 #
-#ServerName new.host.name
+#ServerName new.host.name:80
 
 #
 # DocumentRoot: The directory out of which you will serve your
Index: server/core.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/core.c,v
retrieving revision 1.64
diff -u -d -b -w -u -r1.64 core.c
--- server/core.c	2001/09/29 08:33:02	1.64
+++ server/core.c	2001/10/04 02:49:02
@@ -1603,15 +1603,27 @@
     return NULL;
 }
 
-static const char *server_port(cmd_parms *cmd, void *dummy, const char *arg)
+static const char *server_hostname_port(cmd_parms *cmd, void *dummy, const char *arg)
 {
     const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT);
+    const char *portstr;
+    const char *server;
     int port;
 
     if (err != NULL) {
 	return err;
     }
-    port = atoi(arg);
+    portstr = ap_strchr_c(arg, ':');
+    if (portstr) {
+        cmd->server->server_hostname = apr_pstrndup(cmd->pool, arg, 
+                                                    portstr - arg);
+        portstr++;
+        port = atoi(portstr);
+    }
+    else {
+        cmd->server->server_hostname = apr_pstrdup(cmd->pool, arg);
+        port = 80;
+    }
     if (port <= 0 || port >= 65536) { /* 65536 == 1<<16 */
 	return apr_pstrcat(cmd->temp_pool, "The port number \"", arg, 
 			  "\" is outside the appropriate range "
@@ -2411,7 +2423,8 @@
 
 /* Old server config file commands */
 
-AP_INIT_TAKE1("Port", server_port, NULL, RSRC_CONF, "A TCP port number"),
+AP_INIT_TAKE1("Port", ap_set_deprecated, NULL, RSRC_CONF, 
+  "Port was replaced with Listen in Apache 2.0"),
 AP_INIT_TAKE1("HostnameLookups", set_hostname_lookups, NULL,
   ACCESS_CONF|RSRC_CONF,
   "\"on\" to enable, \"off\" to disable reverse DNS lookups, or \"double\" to "
@@ -2419,9 +2432,8 @@
 AP_INIT_TAKE1("ServerAdmin", set_server_string_slot,
   (void *)APR_XtOffsetOf (server_rec, server_admin), RSRC_CONF,
   "The email address of the server administrator"),
-AP_INIT_TAKE1("ServerName", set_server_string_slot,
-  (void *)APR_XtOffsetOf (server_rec, server_hostname), RSRC_CONF,
-  "The hostname of the server"),
+AP_INIT_TAKE1("ServerName", server_hostname_port, NULL, RSRC_CONF,
+  "The hostname and port of the server"),
 AP_INIT_TAKE1("ServerSignature", set_signature_flag, NULL, OR_ALL,
   "En-/disable server signature (on|off|email)"),
 AP_INIT_TAKE1("ServerRoot", set_server_root, NULL, RSRC_CONF,
Index: server/listen.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/listen.c,v
retrieving revision 1.61
diff -u -d -b -w -u -r1.61 listen.c
--- server/listen.c	2001/08/13 04:57:34	1.61
+++ server/listen.c	2001/10/04 02:49:03
@@ -273,11 +273,10 @@
     ap_listen_rec *next;
     int num_open;
 
-    /* allocate a default listener if necessary */
-    if (ap_listeners == NULL) {
-	alloc_listener(process, NULL, (apr_port_t)(port ? port : DEFAULT_HTTP_PORT));
-    }
-
+    /* Don't allocate a default listener.  If we need to listen to a
+     * port, then the user needs to have a Listen directive in their
+     * config file.
+     */
     num_open = 0;
     for (lr = ap_listeners; lr; lr = lr->next) {
 	if (lr->active) {


______________________________________________________________
Ryan Bloom				rbb@apache.org
Covalent Technologies			rbb@covalent.net
--------------------------------------------------------------

Mime
View raw message