httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rodent of Unusual Size <Ken.C...@Golux.Com>
Subject Re: Adding the OS type
Date Wed, 06 May 1998 12:24:29 GMT
Okey, here's a complete patch.  It lets the os.h file set the platform
name (that's generic enough, eh?).  I'm not sure about the BS2000 and
OS/2 values - they seem rather specific.

I had to introduce a global cell after all, in order for http_core (which
deals with the platform directive) to communicate with http_main (which
sets the string).  The point is to have the platform name, if present,
appear immediately following the SERVER_BASEVERSION setting.

This unsupports SERVER_SUBVERSION, allowing the Webmaster to set the
equivalent value at run-time (more shared-module friendly).  I haven't
nuked the SUBVERSION references yet; I figure that can wait.

Tested.. votes?  Possible for 1.3, Brian?  MMN will need to be bumped
if/when committed..

#ken	P-)}

Ken Coar                    <http://Web.Golux.Com/coar/>
Apache Group member         <http://www.apache.org/>
"Apache Server for Dummies" <http://Web.Golux.Com/coar/ASFD/>

Index: buildmark.c
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/buildmark.c,v
retrieving revision 1.6
diff -u -r1.6 buildmark.c
--- buildmark.c 1998/04/11 12:00:16     1.6
+++ buildmark.c 1998/05/06 12:13:47
@@ -63,14 +63,8 @@
 #else
 static const char server_built[] = "unknown";
 #endif
-static const char server_version[] = SERVER_VERSION;
 
 API_EXPORT(const char *) ap_get_server_built()
 {
     return server_built;
-}
-
-API_EXPORT(const char *) ap_get_server_version()
-{
-    return server_version;
 }
Index: include/http_conf_globals.h
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/include/http_conf_globals.h,v
retrieving revision 1.29
diff -u -r1.29 http_conf_globals.h
--- http_conf_globals.h 1998/05/03 17:31:08     1.29
+++ http_conf_globals.h 1998/05/06 12:13:54
@@ -91,6 +91,8 @@
 extern char *ap_lock_fname;
 extern MODULE_VAR_EXPORT char *ap_server_argv0;
 
+extern int ap_note_platform;
+
 /* 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
  * when pconf gets cleared?  Better to just allocate a little space
Index: include/httpd.h
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/include/httpd.h,v
retrieving revision 1.209
diff -u -r1.209 httpd.h
--- httpd.h     1998/05/04 17:19:54     1.209
+++ httpd.h     1998/05/06 12:14:00
@@ -395,6 +395,7 @@
 #endif
 
 API_EXPORT(const char *) ap_get_server_version(void);
+API_EXPORT(void) ap_add_version_component(const char *component);
 API_EXPORT(const char *) ap_get_server_built(void);
 
 /* Numeric release version identifier: major minor bugfix betaseq
Index: main/http_core.c
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/main/http_core.c,v
retrieving revision 1.192
diff -u -r1.192 http_core.c
--- http_core.c 1998/05/05 04:48:05     1.192
+++ http_core.c 1998/05/06 12:14:07
@@ -1871,6 +1871,31 @@
 }
 #endif /*_OSD_POSIX*/
 
+/*
+ * Handle a request to add an arbitrary string to the Server-Version response
+ * header field (the AddVersionComponent directive).
+ */
+
+static const char *add_component(cmd_parms *cmd, void *mconfig, char *word1)
+{
+    ap_add_version_component((const char *)word1);
+    return NULL;
+}
+
+/*
+ * Handle a request to include the server's OS platform in the Server-Version
+ * response header field (the AddVersionPlatform directive).  Unfortunately
+ * this requires a new global in order to communicate the setting back to
+ * http_main so it can insert the information in the right place in the
+ * string.
+ */
+
+static const char *add_platform(cmd_parms *cmd, void *mconfig, int bool)
+{
+    ap_note_platform = bool;
+    return NULL;
+}
+
 /* Note --- ErrorDocument will now work from .htaccess files.  
  * The AllowOverride of Fileinfo allows webmasters to turn it off
  */
@@ -1879,7 +1904,9 @@
 
 /* Old access config file commands */
 
-{ "<Directory", dirsection, NULL, RSRC_CONF, RAW_ARGS, "Container for
directive
s affecting resources located in the specified directories" },
+{ "<Directory", dirsection, NULL, RSRC_CONF, RAW_ARGS,
+  "Container for directives affecting resources located in the specified "
+  "directories" },
 { end_directory_section, end_nested_section, NULL, ACCESS_CONF, NO_ARGS,
"Marks
 end of <Directory>" },
 { "<Location", urlsection, NULL, RSRC_CONF, RAW_ARGS, "Container for
directives
 affecting resources accessed through the specified URL paths" },
 { end_location_section, end_nested_section, NULL, ACCESS_CONF, NO_ARGS,
"Marks 
end of <Location>" },
@@ -2006,6 +2033,10 @@
 { "BS2000AuthFile", set_bs2000_authfile, NULL, RSRC_CONF, TAKE1,
   "server User's bs2000 logon password file (read-protected)" },
 #endif
+{ "AddVersionComponent", add_component, NULL, RSRC_CONF, TAKE1,
+  "String to be added to the Server-Version text" },
+{ "AddVersionPlatform", add_platform, NULL, RSRC_CONF, FLAG,
+  "Set to 'on' to include server OS platform in Server-Version text" },
 { NULL },
 };
 
Index: main/http_main.c
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/main/http_main.c,v
retrieving revision 1.330
diff -u -r1.330 http_main.c
--- http_main.c 1998/05/04 16:46:40     1.330
+++ http_main.c 1998/05/06 12:14:15
@@ -329,13 +329,76 @@
 static pool *pchild;           /* Pool for httpd child stuff */
 static pool *pcommands;        /* Pool for -C and -c switches */
 
-static int APACHE_TLS my_pid;          /* it seems silly to call getpid all
the
 time */
+static int APACHE_TLS my_pid;  /* it seems silly to call getpid all the time
*/
 #ifndef MULTITHREAD
 static int my_child_num;
 #endif
 
 scoreboard *ap_scoreboard_image = NULL;
 
+/*
+ * Pieces for managing the contents of the Server-Version response header
+ * field.
+ */
+static char *server_version = NULL;
+static int version_locked = 0;
+
+int ap_note_platform = 0;  /* Global, alas, so http_core can talk to us */
+
+/*
+ * This routine is called when the pconf pool is vacuumed.  It resets the
+ * server version string to a known value and [re]enables modifications
+ * (which are disabled by configuration completion).
+ */
+static void reset_version()
+{
+    version_locked = 0;
+    ap_note_platform = 0;
+    server_version = NULL;
+}
+
+API_EXPORT(const char *) ap_get_server_version()
+{
+    return server_version;
+}
+
+API_EXPORT(void) ap_add_version_component(const char *component)
+{
+    if (! version_locked) {
+        /*
+         * If the version string is null, register our cleanup to reset the
+         * pointer on pool destruction.
+         */
+        if (server_version == NULL) {
+           ap_register_cleanup(pconf, NULL, (void (*)(void *))reset_version, 
+                               NULL);
+           server_version = ap_pstrdup(pconf, component);
+       }
+       else {
+           /*
+            * Prepend the given component identifier to the existing string
+            */
+           server_version = ap_pstrcat(pconf, component, " ", server_version,
+                                   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()
+{
+    if (ap_note_platform) {
+        ap_add_version_component(SERVER_BASEVERSION " (" PLATFORM ")");
+    }
+    else {
+        ap_add_version_component(SERVER_BASEVERSION);
+    }
+    version_locked++;
+}
+
 static APACHE_TLS int volatile exit_after_unblock = 0;
 
 /* a clean exit from a child with proper cleanup */
@@ -3772,6 +3835,7 @@
        ap_open_logs(server_conf, pconf);
        ap_log_pid(pconf, ap_pid_fname);
        ap_init_modules(pconf, server_conf);
+       ap_set_version();
        SAFE_ACCEPT(accept_mutex_init(pconf));
        if (!is_graceful) {
            reinit_scoreboard(pconf);
@@ -4057,6 +4121,7 @@
     if (ap_standalone) {
        ap_open_logs(server_conf, pconf);
        ap_init_modules(pconf, server_conf);
+       ap_set_version();
        STANDALONE_MAIN(argc, argv);
     }
     else {
@@ -4928,6 +4993,7 @@
        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();
        if (!is_graceful)
            reinit_scoreboard(pconf);
 
@@ -5163,6 +5229,7 @@
     ap_log_pid(pconf, ap_pid_fname);
     ap_init_modules(pconf, server_conf);
     ap_suexec_enabled = init_suexec();
+    ap_set_version();
     ap_open_logs(server_conf, pconf);
     set_group_privs();
 
Index: os/bs2000/os.h
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/os/bs2000/os.h,v
retrieving revision 1.7
diff -u -r1.7 os.h
--- os.h        1998/04/13 18:05:17     1.7
+++ os.h        1998/05/06 12:14:22
@@ -1,5 +1,8 @@
-#ifndef AP_OS_BS2000_OS_H
-#define AP_OS_BS2000_OS_H
+#ifndef APACHE_OS_H
+#define APACHE_OS_H
+
+#define PLATFORM "BS2000"
+
 /*
  * This file in included in all Apache source code. It contains definitions
  * of facilities available on _this_ operating system (HAVE_* macros),
@@ -27,4 +30,5 @@
  * to use request_rec here... */
 struct request_rec;
 extern int ap_checkconv(struct request_rec *r);
-#endif /*AP_OS_BS2000_OS_H*/
+
+#endif /*! APACHE_OS_H*/
Index: os/emx/os.h
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/os/emx/os.h,v
retrieving revision 1.4
diff -u -r1.4 os.h
--- os.h        1998/04/13 18:05:18     1.4
+++ os.h        1998/05/06 12:14:27
@@ -1,3 +1,8 @@
+#ifndef APACHE_OS_H
+#define APACHE_OS_H
+
+#define PLATFORM "OS/2"
+
 /*
  * This file in included in all Apache source code. It contains definitions
  * of facilities available on _this_ operating system (HAVE_* macros),
@@ -21,3 +26,5 @@
 
 /* OS/2 doesn't have symlinks so S_ISLNK is always false */
 #define S_ISLNK(m) 0
+
+#endif   /* ! APACHE_OS_H */
Index: os/unix/os.h
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/os/unix/os.h,v
retrieving revision 1.22
diff -u -r1.22 os.h
--- os.h        1998/04/30 11:27:04     1.22
+++ os.h        1998/05/06 12:14:33
@@ -58,6 +58,8 @@
 #ifndef APACHE_OS_H
 #define APACHE_OS_H
 
+#define PLATFORM "UNIX"
+
 /*
  * This file in included in all Apache source code. It contains definitions
  * of facilities available on _this_ operating system (HAVE_* macros),
Index: os/win32/os.h
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/os/win32/os.h,v
retrieving revision 1.17
diff -u -r1.17 os.h
--- os.h        1998/04/13 18:05:20     1.17
+++ os.h        1998/05/06 12:14:38
@@ -1,3 +1,8 @@
+#ifndef APACHE_OS_H
+#define APACHE_OS_H
+
+#define PLATFORM "Win32"
+
 /*
  * This file in included in all Apache source code. It contains definitions
  * of facilities available on _this_ operating system (HAVE_* macros),
@@ -106,3 +111,5 @@
 #define ap_os_dso_unload(l) FreeLibrary(l)
 #define ap_os_dso_sym(h,s)  GetProcAddress(h,s)
 #define ap_os_dso_error()   "" /* for now */
+
+#endif   /* ! APACHE_OS_H */

Mime
View raw message