]> granicus.if.org Git - apache/commitdiff
Add server tokens back to 2.0. Also bring forward the change to allow
authorRyan Bloom <rbb@apache.org>
Mon, 5 Jun 2000 19:44:02 +0000 (19:44 +0000)
committerRyan Bloom <rbb@apache.org>
Mon, 5 Jun 2000 19:44:02 +0000 (19:44 +0000)
the PRODUCT_ONLY value for ServerTokens.  This is relatively clean,
all of the code lives in http_core, and when a module wants to add a token,
they just call ap_add_version_component from the post_config hook.  Actually
ap_add_version_component can be done anytime after the config has been
parsed, it just makes the most sense to do it in post_config IMHO.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@85426 13f79535-47bb-0310-9956-ffa450edef68

STATUS
include/httpd.h
modules/http/http_core.c
server/mpm/dexter/dexter.c
server/mpm/mpmt_beos/mpmt_beos.c
server/mpm/mpmt_pthread/mpmt_pthread.c

diff --git a/STATUS b/STATUS
index 1a615256a82d33a7dbe0ffeafda8731af1b9bcef..b8c2b38072bbdc8d1640f6c241d37784dcc1e1b1 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -1,5 +1,5 @@
 Apache 2.0 STATUS:
-Last modified at [$Date: 2000/06/02 19:45:40 $]
+Last modified at [$Date: 2000/06/05 19:43:57 $]
 
 Release:
 
@@ -9,8 +9,6 @@ Release:
     2.0a1   : released March 10, 2000
 
 RELEASE SHOWSTOPPERS:
-    * Reimplement the server tokens
-
     * Win32: Get mod_auth_digest working under win32
       - APR_HAS_RANDOM should be defined on windows and there is a 
       lib/apr/misc/win32/rand.c which is basically a copy of what
index f820fc2c7647407402104d901ec69e140d1c5518..33ee09100be7487e0321469fa95825d414e23790 100644 (file)
@@ -365,24 +365,15 @@ extern "C" {
 #define APEXIT_CHILDINIT       0x3
 #define APEXIT_CHILDFATAL      0xf
 
-/* TODO: re-implement the server token/version stuff -- it's part of http_core
- * it should be possible to do without touching http_main at all. (or else
- * we haven't got enough module hooks)
- */
-
 enum server_token_type {
     SrvTk_MIN,         /* eg: Apache/1.3.0 */
     SrvTk_OS,          /* eg: Apache/1.3.0 (UNIX) */
-    SrvTk_FULL         /* eg: Apache/1.3.0 (UNIX) PHP/3.0 FooBar/1.2b */
+    SrvTk_FULL,                /* eg: Apache/1.3.0 (UNIX) PHP/3.0 FooBar/1.2b */
+    SrvTk_PRODUCT_ONLY /* eg: Apache */
 };
 
-#if 0
 API_EXPORT(const char *) ap_get_server_version(void);
-API_EXPORT(void) ap_add_version_component(const char *component);
-#else
-#define ap_get_server_version()        (AP_SERVER_BASEVERSION)
-#define ap_add_version_component(x) ((void)0)
-#endif
+API_EXPORT(void) ap_add_version_component(ap_pool_t pconf, const char *component);
 API_EXPORT(const char *) ap_get_server_built(void);
 
 /* Numeric release version identifier: MMNNFFRBB: major minor fix final beta
index 4a948e296ab051691fe01c73aa1313647ef18193..460c3a2f3a9b6c57fac4e3e5411a702883f6deff 100644 (file)
@@ -2040,6 +2040,70 @@ static const char *set_bs2000_account(cmd_parms *cmd, void *dummy, char *name)
  * string.
  */
 
+static char *server_version = NULL;
+static int version_locked = 0; 
+static enum server_token_type ap_server_tokens = SrvTk_FULL;
+
+static ap_status_t reset_version(void *dummy)
+{
+    version_locked = 0;
+    ap_server_tokens = SrvTk_FULL;
+    server_version = NULL;
+}
+
+API_EXPORT(const char *) ap_get_server_version(void)
+{
+    return (server_version ? server_version : AP_SERVER_BASEVERSION);
+}
+
+API_EXPORT(void) ap_add_version_component(ap_pool_t *pconf, const char *component)
+{
+    if (! version_locked) {
+        /*
+         * If the version string is null, register our cleanup to reset the
+         * 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, reset_version,
+                                ap_null_cleanup);
+            server_version = ap_pstrdup(pconf, component);
+        }
+        else {
+            /*
+             * Tack the given component identifier to the end of
+             * the existing string.
+             */
+            server_version = ap_pstrcat(pconf, server_version, " ",
+                                        component, NULL);
+        }
+    }
+}
+
+/*
+ * This routine adds the real server base identity to the version string,
+ * and then locks out changes until the next reconfig.
+ */
+static void ap_set_version(ap_pool_t *pconf)
+{
+    if (ap_server_tokens == SrvTk_PRODUCT_ONLY) {
+        ap_add_version_component(pconf, AP_SERVER_BASEPRODUCT);
+    }
+    else if (ap_server_tokens == SrvTk_MIN) {
+        ap_add_version_component(pconf, AP_SERVER_BASEVERSION);
+    }
+    else {
+        ap_add_version_component(pconf, AP_SERVER_BASEVERSION " (" PLATFORM ")");
+    }
+    /*
+     * Lock the server_version string if we're not displaying
+     * the full set of tokens
+     */
+    if (ap_server_tokens != SrvTk_FULL) {
+        version_locked++;
+    }
+}
+
 static const char *set_serv_tokens(cmd_parms *cmd, void *dummy, char *arg) 
 {
     const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
@@ -2047,18 +2111,18 @@ static const char *set_serv_tokens(cmd_parms *cmd, void *dummy, char *arg)
         return err;
     }
 
-    /* TODO: reimplement the server token stuff. */
-#if 0
     if (!strcasecmp(arg, "OS")) {
         ap_server_tokens = SrvTk_OS;
     }
     else if (!strcasecmp(arg, "Min") || !strcasecmp(arg, "Minimal")) {
         ap_server_tokens = SrvTk_MIN;
     }
+    else if (!strcasecmp(arg, "Prod") || !strcasecmp(arg, "ProductOnly")) {
+        ap_server_tokens = SrvTk_PRODUCT_ONLY;
+    }
     else {
         ap_server_tokens = SrvTk_FULL;
     }
-#endif
     return NULL;
 }
 
@@ -2532,6 +2596,11 @@ static const handler_rec core_handlers[] = {
 { NULL, NULL }
 };
 
+static void core_post_config(ap_pool_t *pconf, ap_pool_t *plog, ap_pool_t *ptemp, server_rec *s)
+{
+    ap_set_version(pconf);
+}
+
 static void core_open_logs(ap_pool_t *pconf, ap_pool_t *plog, ap_pool_t *ptemp, server_rec *s)
 {
     ap_open_logs(s, pconf);
@@ -2545,6 +2614,7 @@ static unsigned short core_port(const request_rec *r)
 
 static void register_hooks(void)
 {
+    ap_hook_post_config(core_post_config,NULL,NULL,AP_HOOK_REALLY_FIRST);
     ap_hook_translate_name(core_translate,NULL,NULL,AP_HOOK_REALLY_LAST);
     ap_hook_process_connection(ap_process_http_connection,NULL,NULL,
                               AP_HOOK_REALLY_LAST);
index f360585e12b96a8ad9c7ac8c4e8cee5c5bbaf195..aadc7cf00f857a49e23db734e34a607538864482 100644 (file)
@@ -164,9 +164,6 @@ static ap_lock_t *process_accept_mutex;
 static char *lock_fname;
 static pthread_mutex_t thread_accept_mutex = PTHREAD_MUTEX_INITIALIZER;
 
-/* Global, alas, so http_core can talk to us */
-enum server_token_type ap_server_tokens = SrvTk_FULL;
-
 API_EXPORT(const server_rec *) ap_get_server_conf(void)
 {
     return (ap_server_conf);
index c7e5b8014562cf4480c26d2098ae60b9279e7a1d..2e8229c5a0c00999f09d544ccd9bbe28dd4b94be 100644 (file)
@@ -139,9 +139,6 @@ static int one_process = 0;
 int raise_sigstop_flags;
 #endif
 
-/* Global, alas, so http_core can talk to us */
-enum server_token_type ap_server_tokens = SrvTk_FULL;
-
 API_EXPORT(const server_rec *) ap_get_server_conf(void)
 {
     return (ap_server_conf);
index cb1278e9906391d8955a459e013a26bd6e650b74..94bbed9c2c36ccc34e4e3bdec7fdd55154f1bf7b 100644 (file)
@@ -161,10 +161,6 @@ static char *lock_fname;
 #define SAFE_ACCEPT(stmt) (stmt)
 #endif
 
-
-/* Global, alas, so http_core can talk to us */
-enum server_token_type ap_server_tokens = SrvTk_FULL;
-
 API_EXPORT(const server_rec *) ap_get_server_conf(void)
 {
     return (ap_server_conf);