You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Jim Jagielski <ji...@jaguNET.com> on 1998/05/10 18:50:38 UTC
[PATCH] Server: header and tokens
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"
Re: [PATCH] Server: header and tokens
Posted by Martin Kraemer <Ma...@mch.sni.de>.
On Mon, May 11, 1998 at 09:03:08AM -0400, Jim Jagielski wrote:
> It's easy to have the OS added, but having the modules add their
> tokens requires that the modules actually do their init sequence,
> which they don't get to with -V :(
Yeah. That's what I thought too when I wrote...
> > Even "httpd -C 'ServerTokens full' -V" or whatever
Okay, guess we'll have to live with that unless someone invents a clever
way to "fake" the initialization. But as no configuration has been read
in, there's no infrastructure for the modules.
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] Server: header and tokens
Posted by Martin Kraemer <Ma...@mch.sni.de>.
On Sun, May 10, 1998 at 01:50:38PM -0400, Jim Jagielski wrote:
> [...] either 'Orig' 'OS' or 'Full' where:
Citing Brian:
> I am okay if "normal" becomes "minimal", and "full" becomes the default.
I'd prefer "minimal" or over "orig", too. What's so "original" about it?
I mean, after 1.3 is out, nobody will remember what the "original" was.
(Or is it supposed to be compatible with the "original" 1.2?)
> +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 */
> +};
Can you please add a prefix token to the constants? In C,
enumeration tags have global visibility, so they clutter the global
namespace. Like, e.g.,
> +enum server_token_type {
> + SrvTok_ORIG, /* eg: Apache/1.3.0 */
> + SrvTok_OS, /* eg: Apache/1.3.0 (UNIX) */
> + SrvTok_FULL /* eg: Apache/1.3.0 (UNIX) PHP/3.0 FooBar/1.2b */
> +};
or some such. Feel free to use any sensible prefix.
> - 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);
That means that "httpd -V" won't ever print the individual modules'
version strings? Even "httpd -C 'ServerTokens full' -V" or whatever
could not force them to be printed? Not even the OS part?
Hmm... I would like it if it was possible to make the OS part and
module versions display...
The rest (and the concept) looks good to me.
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