httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim Jagielski <...@jaguNET.com>
Subject [PATCH] Server: header and tokens
Date Sun, 10 May 1998 16:50:38 GMT
This is my 1st draft of the whole Server: header line debate. Basically
it changes the AddVersionPlatform directive to ServerTokens which can
be either 'Orig' 'OS' or 'Full' where:

   Orig:	Apache/1.3.0
   OS:		Apache/1.3.0 (UNIX)
   Full:	Apache/1.3.0 (UNIX) PHP/3.0

(the default is Full).

It also adjusts things so that the order of the tokens is the
order they were added by the modules... Finally, it removes
SERVER_SUBVERSION.

Compiles and passes low-level testing. Comments and Feedback please :)
(Docs still need to be updated)


Index: include/http_conf_globals.h
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/include/http_conf_globals.h,v
retrieving revision 1.30
diff -u -r1.30 http_conf_globals.h
--- http_conf_globals.h	1998/05/07 12:24:24	1.30
+++ http_conf_globals.h	1998/05/10 16:45:23
@@ -91,7 +91,7 @@
 extern char *ap_lock_fname;
 extern MODULE_VAR_EXPORT char *ap_server_argv0;
 
-extern int ap_note_platform;
+extern enum server_token_type ap_server_tokens;
 
 /* Trying to allocate these in the config pool gets us into some *nasty*
  * chicken-and-egg problems in http_main.c --- where do you stick them
Index: include/httpd.h
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/include/httpd.h,v
retrieving revision 1.211
diff -u -r1.211 httpd.h
--- httpd.h	1998/05/09 14:27:26	1.211
+++ httpd.h	1998/05/10 16:45:24
@@ -369,15 +369,10 @@
 #define DEFAULT_LISTENBACKLOG 511
 #endif
 
-/* If you have altered Apache and wish to change the SERVER_VERSION
- * identifier below, please keep to the HTTP specification.  This states that
- * the identification string should consist of product tokens with an optional
- * slash and version designator.  Sub-products which form a significant part 
- * of the application can be listed, separated by whitespace, by adding
- * their product tokens to EXTRA_CFLAGS in the Configuration file like so.
+/*
+ * The below defines the base string of the Server: header. Additional
+ * tokens can be added via the ap_add_version_component() API call.
  *
- * EXTRA_CFLAGS="-DSERVER_SUBVERSION="MrWidget/0.1-alpha"
- *
  * The tokens are listed in order of their significance for identifying the
  * application.
  *
@@ -388,11 +383,12 @@
  */
 
 #define SERVER_BASEVERSION "Apache/1.3b7-dev"	/* SEE COMMENTS ABOVE */
-#ifdef SERVER_SUBVERSION
-#define SERVER_VERSION	SERVER_BASEVERSION " " SERVER_SUBVERSION
-#else
-#define SERVER_VERSION	SERVER_BASEVERSION
-#endif
+#define SERVER_VERSION  SERVER_BASEVERSION
+enum server_token_type {
+    ORIG,	/* eg: Apache/1.3.0 */
+    OS,		/* eg: Apache/1.3.0 (UNIX) */
+    FULL	/* eg: Apache/1.3.0 (UNIX) PHP/3.0 FooBar/1.2b */
+};
 
 API_EXPORT(const char *) ap_get_server_version(void);
 API_EXPORT(void) ap_add_version_component(const char *component);
Index: main/http_core.c
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/main/http_core.c,v
retrieving revision 1.199
diff -u -r1.199 http_core.c
--- http_core.c	1998/05/09 15:49:33	1.199
+++ http_core.c	1998/05/10 16:45:25
@@ -1879,13 +1879,17 @@
  * string.
  */
 
-static const char *enable_platform_announcement(cmd_parms *cmd, void *mconfig,
-						int flag)
+static const char *set_serv_tokens (cmd_parms *cmd, void *dummy, char *arg) 
 {
     const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
     if (err != NULL) return err;
 
-    ap_note_platform = flag;
+    if (!strcasecmp(arg,"OS"))
+        ap_server_tokens = OS;
+    else if (!strcasecmp(arg,"Orig"))
+        ap_server_tokens = ORIG;
+    else
+        ap_server_tokens = FULL;
     return NULL;
 }
 
@@ -2026,8 +2030,8 @@
 { "BS2000AuthFile", set_bs2000_authfile, NULL, RSRC_CONF, TAKE1,
   "server User's bs2000 logon password file (read-protected)" },
 #endif
-{ "AddVersionPlatform", enable_platform_announcement, NULL, RSRC_CONF, FLAG,
-  "Set to 'off' to not include server OS platform in Server identity text" },
+{ "ServerTokens", set_serv_tokens, NULL, RSRC_CONF, TAKE1,
+  "Determine tokens displayed in the Server: header - Orig, OS or Full" },
 { NULL },
 };
 
Index: main/http_main.c
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/main/http_main.c,v
retrieving revision 1.350
diff -u -r1.350 http_main.c
--- http_main.c	1998/05/09 23:48:02	1.350
+++ http_main.c	1998/05/10 16:45:31
@@ -343,7 +343,8 @@
 static char *server_version = NULL;
 static int version_locked = 0;
 
-int ap_note_platform = 1;  /* Global, alas, so http_core can talk to us */
+/* Global, alas, so http_core can talk to us */
+enum server_token_type ap_server_tokens = FULL;
 
 /*
  * This routine is called when the pconf pool is vacuumed.  It resets the
@@ -353,13 +354,13 @@
 static void reset_version(void *dummy)
 {
     version_locked = 0;
-    ap_note_platform = 1;
+    ap_server_tokens = FULL;
     server_version = NULL;
 }
 
 API_EXPORT(const char *) ap_get_server_version()
 {
-    return server_version;
+    return (server_version ? server_version : SERVER_BASEVERSION);
 }
 
 API_EXPORT(void) ap_add_version_component(const char *component)
@@ -367,19 +368,23 @@
     if (! version_locked) {
         /*
          * If the version string is null, register our cleanup to reset the
-         * pointer on pool destruction.
+         * pointer on pool destruction. We also know that, if NULL,
+	 * we are adding the original SERVER_BASEVERSION string.
          */
         if (server_version == NULL) {
 	    ap_register_cleanup(pconf, NULL, (void (*)(void *))reset_version, 
 				ap_null_cleanup);
 	    server_version = ap_pstrdup(pconf, component);
 	}
-	else {
+	else if (ap_server_tokens == FULL) {
 	    /*
-	     * Prepend the given component identifier to the existing string
+	     * Tack the given component identifier to the end of
+	     * the existing string. We only do this to the global
+	     * server_version string if we'll be displaying the
+	     * "extra" tokens
 	     */
-	    server_version = ap_pstrcat(pconf, component, " ", server_version,
-					NULL);
+	    server_version = ap_pstrcat(pconf, server_version, " ",
+					component, NULL);
 	}
     }
 }
@@ -390,16 +395,12 @@
  */
 static void ap_set_version()
 {
-#ifdef SERVER_SUBVERSION
-    ap_add_version_component(SERVER_SUBVERSION);
-#endif
-    if (ap_note_platform) {
-        ap_add_version_component(SERVER_BASEVERSION " (" PLATFORM ")");
+    if (ap_server_tokens == ORIG) {
+        ap_add_version_component(SERVER_BASEVERSION);
     }
     else {
-        ap_add_version_component(SERVER_BASEVERSION);
+        ap_add_version_component(SERVER_BASEVERSION " (" PLATFORM ")");
     }
-    version_locked++;
 }
 
 static APACHE_TLS int volatile exit_after_unblock = 0;
@@ -3120,12 +3121,8 @@
 
 static void show_compile_settings(void)
 {
-    printf("Server base version: %s\n", SERVER_BASEVERSION);
-#ifdef SERVER_SUBVERSION
-    printf("Server sub-version:  %s\n", SERVER_SUBVERSION);
-#endif
-    printf("Server Full version: %s\n", ap_get_server_version());
-    printf("Server built:        %s\n", ap_get_server_built());
+    printf("Server version: %s\n", SERVER_BASEVERSION);
+    printf("Server built:   %s\n", ap_get_server_built());
     printf("Server's Module Magic Number: %u\n", MODULE_MAGIC_NUMBER);
     printf("Server compiled with....\n");
 #ifdef BIG_SECURITY_HOLE
@@ -3997,8 +3994,9 @@
 	setup_listeners(pconf);
 	ap_open_logs(server_conf, pconf);
 	ap_log_pid(pconf, ap_pid_fname);
+	ap_set_version();	/* create our server_version string */
 	ap_init_modules(pconf, server_conf);
-	ap_set_version();
+	version_locked++;	/* no more changes to server_version */
 	SAFE_ACCEPT(accept_mutex_init(pconf));
 	if (!is_graceful) {
 	    reinit_scoreboard(pconf);
@@ -4269,8 +4267,9 @@
 
     if (ap_standalone) {
 	ap_open_logs(server_conf, pconf);
-	ap_init_modules(pconf, server_conf);
 	ap_set_version();
+	ap_init_modules(pconf, server_conf);
+	version_locked++;
 	STANDALONE_MAIN(argc, argv);
     }
     else {
@@ -5186,8 +5185,9 @@
 
 	server_conf = ap_read_config(pconf, pparent, ap_server_confname);
 	ap_open_logs(server_conf, pconf);
-	ap_init_modules(pconf, server_conf);
 	ap_set_version();
+	ap_init_modules(pconf, server_conf);
+	version_locked++;
 	if (!is_graceful)
 	    reinit_scoreboard(pconf);
 
@@ -5422,9 +5422,10 @@
     if (!child) {
 	ap_log_pid(pconf, ap_pid_fname);
     }
+    ap_set_version();
     ap_init_modules(pconf, server_conf);
     ap_suexec_enabled = init_suexec();
-    ap_set_version();
+    version_locked++;
     ap_open_logs(server_conf, pconf);
     set_group_privs();
 
-- 
===========================================================================
   Jim Jagielski   |||   jim@jaguNET.com   |||   http://www.jaguNET.com/
            "That's no ordinary rabbit... that's the most foul,
            cruel and bad-tempered rodent you ever laid eyes on"

Mime
View raw message