You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by Roy Fielding <fi...@hyperreal.com> on 1996/10/06 04:25:06 UTC
cvs commit: apache/src http_config.h http_config.c http_main.c
fielding 96/10/05 19:25:06
Modified: src http_config.h http_config.c http_main.c
Log:
Enhanced the httpd -h option's output to make it readable by
normal users and to improve internal documentation of override mask.
Reviewed by: Ben Laurie <be...@gonzo.ben.algroup.co.uk>
Revision Changes Path
1.12 +21 -6 apache/src/http_config.h
Index: http_config.h
===================================================================
RCS file: /export/home/cvs/apache/src/http_config.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -C3 -r1.11 -r1.12
*** http_config.h 1996/08/20 11:50:43 1.11
--- http_config.h 1996/10/06 02:25:02 1.12
***************
*** 1,5 ****
/* ====================================================================
! * Copyright (c) 1995 The Apache Group. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
--- 1,5 ----
/* ====================================================================
! * Copyright (c) 1995, 1996 The Apache Group. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
***************
*** 50,56 ****
*
*/
! /* $Id: http_config.h,v 1.11 1996/08/20 11:50:43 paul Exp $ */
/*
* The central data structures around here...
--- 50,56 ----
*
*/
! /* $Id: http_config.h,v 1.12 1996/10/06 02:25:02 fielding Exp $ */
/*
* The central data structures around here...
***************
*** 86,93 ****
char *errmsg; /* 'usage' message, in case of syntax errors */
} command_rec;
! /* Values for the req_override slot */
!
#define OR_NONE 0
#define OR_LIMIT 1
#define OR_OPTIONS 2
--- 86,107 ----
char *errmsg; /* 'usage' message, in case of syntax errors */
} command_rec;
! /* The allowed locations for a configuration directive are the union of
! * those indicated by each set bit in the req_override mask.
! *
! * (req_override & RSRC_CONF) => *.conf outside <Directory> or <Location>
! * (req_override & ACCESS_CONF) => *.conf inside <Directory> or <Location>
! * (req_override & OR_AUTHCFG) => *.conf inside <Directory> or <Location>
! * and .htaccess when AllowOverride AuthConfig
! * (req_override & OR_LIMIT) => *.conf inside <Directory> or <Location>
! * and .htaccess when AllowOverride Limit
! * (req_override & OR_OPTIONS) => *.conf anywhere
! * and .htaccess when AllowOverride Options
! * (req_override & OR_FILEINFO) => *.conf anywhere
! * and .htaccess when AllowOverride FileInfo
! * (req_override & OR_INDEXES) => *.conf anywhere
! * and .htaccess when AllowOverride Indexes
! */
#define OR_NONE 0
#define OR_LIMIT 1
#define OR_OPTIONS 2
***************
*** 95,102 ****
#define OR_AUTHCFG 8
#define OR_INDEXES 16
#define OR_UNSET 32
! #define ACCESS_CONF 64 /* command valid in access.conf */
! #define RSRC_CONF 128 /* command valid in srm.conf */
#define OR_ALL (OR_LIMIT|OR_OPTIONS|OR_FILEINFO|OR_AUTHCFG|OR_INDEXES)
/*
--- 109,116 ----
#define OR_AUTHCFG 8
#define OR_INDEXES 16
#define OR_UNSET 32
! #define ACCESS_CONF 64
! #define RSRC_CONF 128
#define OR_ALL (OR_LIMIT|OR_OPTIONS|OR_FILEINFO|OR_AUTHCFG|OR_INDEXES)
/*
***************
*** 232,237 ****
--- 246,252 ----
server_rec *read_config (pool *conf_pool, pool *temp_pool, char *config_name);
void setup_prelinked_modules();
+ void show_directives();
/* For http_request.c... */
1.24 +96 -4 apache/src/http_config.c
Index: http_config.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_config.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -C3 -r1.23 -r1.24
*** http_config.c 1996/09/23 03:01:03 1.23
--- http_config.c 1996/10/06 02:25:03 1.24
***************
*** 1,5 ****
/* ====================================================================
! * Copyright (c) 1995 The Apache Group. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
--- 1,5 ----
/* ====================================================================
! * Copyright (c) 1995, 1996 The Apache Group. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
***************
*** 50,56 ****
*
*/
! /* $Id: http_config.c,v 1.23 1996/09/23 03:01:03 brian Exp $ */
/*
* http_config.c: once was auxillary functions for reading httpd's config
--- 50,56 ----
*
*/
! /* $Id: http_config.c,v 1.24 1996/10/06 02:25:03 fielding Exp $ */
/*
* http_config.c: once was auxillary functions for reading httpd's config
***************
*** 82,89 ****
/****************************************************************
*
* We begin with the functions which deal with the linked list
! * of modules which control just about all of server operation in
! * Shambhala.
*/
static int num_modules = 0;
--- 82,88 ----
/****************************************************************
*
* We begin with the functions which deal with the linked list
! * of modules which control just about all of the server operation.
*/
static int num_modules = 0;
***************
*** 915,919 ****
--- 914,1011 ----
(*m->init) (s, p);
return s;
+ }
+
+ /********************************************************************
+ * Configuration directives are restricted in terms of where they may
+ * appear in the main configuration files and/or .htaccess files according
+ * to the bitmask req_override in the command_rec structure.
+ * If any of the overrides set in req_override are also allowed in the
+ * context in which the command is read, then the command is allowed.
+ * The context is determined as follows:
+ *
+ * inside *.conf --> override = (RSRC_CONF|OR_ALL)&~(OR_AUTHCFG|OR_LIMIT);
+ * within <Directory> or <Location> --> override = OR_ALL|ACCESS_CONF;
+ * within .htaccess --> override = AllowOverride for current directory;
+ *
+ * the result is, well, a rather confusing set of possibilities for when
+ * a particular directive is allowed to be used. This procedure prints
+ * in English where the given (pc) directive can be used.
+ */
+ void show_overrides(command_rec *pc, module *pm)
+ {
+ int n = 0;
+
+ printf("\tAllowed in *.conf ");
+ if ((pc->req_override & (OR_OPTIONS|OR_FILEINFO|OR_INDEXES)) ||
+ ((pc->req_override & RSRC_CONF) &&
+ ((pc->req_override & (ACCESS_CONF|OR_AUTHCFG|OR_LIMIT)))))
+ printf("anywhere");
+ else if (pc->req_override & RSRC_CONF)
+ printf("only outside <Directory> or <Location>");
+ else
+ printf("only inside <Directory> or <Location>");
+
+ /* Warn if the directive is allowed inside <Directory> or .htaccess
+ * but module doesn't support per-dir configuration */
+
+ if ((pc->req_override & (OR_ALL|ACCESS_CONF)) && !pm->create_dir_config)
+ printf(" [no per-dir config]");
+
+ if (pc->req_override & OR_ALL) {
+ printf(" and in .htaccess\n\twhen AllowOverride");
+
+ if ((pc->req_override & OR_ALL) == OR_ALL)
+ printf(" isn't None");
+ else {
+ printf(" includes ");
+
+ if (pc->req_override & OR_AUTHCFG) {
+ if (n++) printf(" or ");
+ printf("AuthConfig");
+ }
+ if (pc->req_override & OR_LIMIT) {
+ if (n++) printf(" or ");
+ printf("Limit");
+ }
+ if (pc->req_override & OR_OPTIONS) {
+ if (n++) printf(" or ");
+ printf("Options");
+ }
+ if (pc->req_override & OR_FILEINFO) {
+ if (n++) printf(" or ");
+ printf("FileInfo");
+ }
+ if (pc->req_override & OR_INDEXES) {
+ if (n++) printf(" or ");
+ printf("Indexes");
+ }
+ }
+ }
+ printf("\n");
+ }
+
+ /* Show the prelinked configuration directives, the help string explaining
+ * the directive arguments, in what module they are handled, and in
+ * what parts of the configuration they are allowed. Used for httpd -h.
+ */
+ void show_directives()
+ {
+ extern module *prelinked_modules[];
+ extern char *module_names[];
+ command_rec *pc;
+ int n;
+ int t;
+
+ for(t=0 ; prelinked_modules[t] ; ++t)
+ ;
+ for(n=0 ; prelinked_modules[n] ; ++n)
+ for(pc=prelinked_modules[n]->cmds ; pc && pc->name ; ++pc) {
+ printf("%s\n", pc->name);
+ if (pc->errmsg)
+ printf("\t%s\n", pc->errmsg);
+ printf("\t%s\n", module_names[t-n-1]);
+ show_overrides(pc, prelinked_modules[n]);
+ }
}
1.76 +2 -49 apache/src/http_main.c
Index: http_main.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_main.c,v
retrieving revision 1.75
retrieving revision 1.76
diff -C3 -r1.75 -r1.76
*** http_main.c 1996/10/02 00:31:52 1.75
--- http_main.c 1996/10/06 02:25:03 1.76
***************
*** 1,5 ****
/* ====================================================================
! * Copyright (c) 1995 The Apache Group. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
--- 1,5 ----
/* ====================================================================
! * Copyright (c) 1995, 1996 The Apache Group. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
***************
*** 50,56 ****
*
*/
! /* $Id: http_main.c,v 1.75 1996/10/02 00:31:52 jim Exp $ */
/*
* httpd.c: simple http daemon for answering WWW file requests
--- 50,56 ----
*
*/
! /* $Id: http_main.c,v 1.76 1996/10/06 02:25:03 fielding Exp $ */
/*
* httpd.c: simple http daemon for answering WWW file requests
***************
*** 1847,1899 ****
}
} /* standalone_main */
-
- void show_overrides(command_rec *pc,module *pm)
- {
- int n;
- struct
- {
- int override;
- char letter;
- } aOvers[]= {
- { OR_LIMIT, 'L' },
- { OR_OPTIONS, 'O' },
- { OR_FILEINFO, 'F' },
- { OR_AUTHCFG, 'A' },
- { OR_INDEXES, 'I' },
- { ACCESS_CONF, 'a' },
- { RSRC_CONF, 'r' },
- { (OR_ALL|RSRC_CONF)&~(OR_LIMIT|OR_AUTHCFG), 'd' }, /* outside <Directory> */
- { OR_ALL|ACCESS_CONF, 'D' }, /* inside <Directory> */
- { 0, '\0' }
- };
-
- for(n=0 ; aOvers[n].override ; ++n)
- if(pc->req_override&aOvers[n].override)
- putchar(aOvers[n].letter);
- if((pc->req_override&(OR_ALL|ACCESS_CONF)) && !pm->create_dir_config)
- putchar('!'); /* Directive allowed inside <Directory> but module doesn't support per-dir config */
- }
-
- void show_directives()
- {
- extern module *prelinked_modules[];
- extern char *module_names[];
- command_rec *pc;
- int n;
- int t;
-
- for(t=0 ; prelinked_modules[t] ; ++t)
- ;
- for(n=0 ; prelinked_modules[n] ; ++n)
- for(pc=prelinked_modules[n]->cmds ; pc && pc->name ; ++pc)
- {
- printf("%s\t%s\t%s\t", pc->name, pc->errmsg ? pc->errmsg : "",
- module_names[t-n-1]);
- show_overrides(pc,prelinked_modules[n]);
- putchar('\n');
- }
- }
extern char *optarg;
extern int optind;
--- 1847,1852 ----