httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexei Kosut <ako...@nueva.pvt.k12.ca.us>
Subject NCSA-style Auth*File directives
Date Sat, 31 Aug 1996 23:22:55 GMT
As a followup to my last message, here is a patch that makes
AuthUserFile/AuthGroupFile/AuthDigestFile work as they do in NCSA
httpd, specifically:

Auth[User|Group|Digest]File filename [filetype]

e.g.

AuthUserFile /www/dbmdatabase dbm
AuthGroupFile /www/flatfilegroups standard

In order to do this, I had to make several modifications to the core:

1. A TAKE12 argument type was added, to supplement TAKE1 and TAKE2. It
   means a directive can have either one or two arguments.

2. A directive handler can use "return DECLINE_CMD;" to cause the
   config-file parser to skip to the next module. This allows
   mod_auth, mod_auth_dbm and mod_auth_db to all have a handler for
   AuthUserFile and AuthGroupFile.

Anyhow, here's the patch. It still doesn't let you do digest with DBM
files (which NCSA does), but it's possible:

Index: http_config.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_config.c,v
retrieving revision 1.22
diff -c -r1.22 http_config.c
*** http_config.c	1996/08/24 14:36:13	1.22
--- http_config.c	1996/08/31 23:06:02
***************
*** 440,445 ****
--- 440,456 ----
  
  	return (*cmd->func) (parms, mconfig, w, w2);
  	
+     case TAKE12:
+ 
+ 	w = getword_conf (parms->pool, &args);
+ 	w2 = getword_conf (parms->pool, &args);
+ 	
+ 	if (*w == '\0' || *args != 0) 
+ 	    return pstrcat (parms->pool, cmd->name, " takes 1-2 arguments",
+ 			    cmd->errmsg ? ", " : NULL, cmd->errmsg, NULL);
+ 
+ 	return (*cmd->func) (parms, mconfig, w, *w2 ? w2 : NULL);
+ 	
      case ITERATE:
  
  	while (*(w = getword_conf (parms->pool, &args)) != '\0')
***************
*** 498,504 ****
     command_rec *cmdp;
     module *modp;
  
!    for (modp = top_module; modp; modp = modp->next) 
         if (modp->cmds && (cmdp = find_command (cmd_name, modp->cmds))) {
  	   *mod = modp;
  	   return cmdp;
--- 509,515 ----
     command_rec *cmdp;
     module *modp;
  
!    for (modp = *mod; modp; modp = modp->next) 
         if (modp->cmds && (cmdp = find_command (cmd_name, modp->cmds))) {
  	   *mod = modp;
  	   return cmdp;
***************
*** 509,517 ****
  
  char *handle_command (cmd_parms *parms, void *config, char *l)
  {
!     char *args, *cmd_name;
      command_rec *cmd;
!     module *mod;
  
      ++parms->config_line;
      if((l[0] == '#') || (!l[0])) return NULL;
--- 520,528 ----
  
  char *handle_command (cmd_parms *parms, void *config, char *l)
  {
!     char *args, *cmd_name, *retval;
      command_rec *cmd;
!     module *mod = top_module;
  
      ++parms->config_line;
      if((l[0] == '#') || (!l[0])) return NULL;
***************
*** 520,544 ****
      cmd_name = getword_conf (parms->temp_pool, &args);
      if (*cmd_name == '\0') return NULL;
  	
!     if (!(cmd = find_command_in_modules (cmd_name, &mod))) {
! 	return pstrcat (parms->pool, "Invalid command ", cmd_name, NULL);
!     }
!     else {
! 	void *mconfig = get_module_config (config, mod);
! 	void *sconfig = get_module_config (parms->server->module_config, mod);
! 	      
! 	if (!mconfig && mod->create_dir_config) {
! 	    mconfig = (*mod->create_dir_config) (parms->pool, parms->path);
! 	    set_module_config (config, mod, mconfig);
  	}
  	    
! 	if (!sconfig && mod->create_server_config) {
! 	    sconfig = (*mod->create_server_config)(parms->pool, parms->server);
! 	    set_module_config (parms->server->module_config, mod, sconfig);
  	}
! 	
! 	return invoke_cmd (cmd, parms, mconfig, args);
!     }
  }
  
  char *srm_command_loop (cmd_parms *parms, void *config)
--- 531,562 ----
      cmd_name = getword_conf (parms->temp_pool, &args);
      if (*cmd_name == '\0') return NULL;
  	
!     do {
! 	if (!(cmd = find_command_in_modules (cmd_name, &mod))) {
! 	    return pstrcat (parms->pool, "Invalid command ", cmd_name, NULL);
  	}
+ 	else {
+ 	    void *mconfig = get_module_config (config, mod);
+ 	    void *sconfig =
+ 		get_module_config (parms->server->module_config, mod);
  	    
! 	    if (!mconfig && mod->create_dir_config) {
! 		mconfig = (*mod->create_dir_config) (parms->pool, parms->path);
! 		set_module_config (config, mod, mconfig);
! 	    }
! 	    
! 	    if (!sconfig && mod->create_server_config) {
! 		sconfig =
! 		    (*mod->create_server_config)(parms->pool, parms->server);
! 		set_module_config (parms->server->module_config, mod, sconfig);
! 	    }
! 	    
! 	    retval = invoke_cmd (cmd, parms, mconfig, args);
! 	    mod = mod->next;	/* Next time around, skip this one */
  	}
!     } while (retval && !strcmp(retval, DECLINE_CMD));
! 
!     return retval;
  }
  
  char *srm_command_loop (cmd_parms *parms, void *config)
Index: http_config.h
===================================================================
RCS file: /export/home/cvs/apache/src/http_config.h,v
retrieving revision 1.11
diff -c -r1.11 http_config.h
*** http_config.h	1996/08/20 11:50:43	1.11
--- http_config.h	1996/08/31 23:06:04
***************
*** 69,75 ****
  				 * (e.g., AddIcon)
  				 */
    FLAG,				/* One of 'On' or 'Off' */
!   NO_ARGS			/* No args at all, e.g. </Directory> */
  };
  
  typedef struct command_struct {
--- 69,76 ----
  				 * (e.g., AddIcon)
  				 */
    FLAG,				/* One of 'On' or 'Off' */
!   NO_ARGS,			/* No args at all, e.g. </Directory> */
!   TAKE12			/* one or two arguments */
  };
  
  typedef struct command_struct {
***************
*** 98,103 ****
--- 99,111 ----
  #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)
+ 
+ /* This can be returned by a function if they don't wish to handle
+  * a command. Make it something not likely someone will actually use
+  * as an error code.
+  */
+ 
+ #define DECLINE_CMD "\a\b"
  
  /*
   * This structure is passed to a command which is being invoked,
Index: mod_auth.c
===================================================================
RCS file: /export/home/cvs/apache/src/mod_auth.c,v
retrieving revision 1.5
diff -c -r1.5 mod_auth.c
*** mod_auth.c	1996/08/20 11:50:57	1.5
--- mod_auth.c	1996/08/31 23:06:06
***************
*** 79,89 ****
      return pcalloc (p, sizeof(auth_config_rec));
  }
  
  command_rec auth_cmds[] = {
! { "AuthUserFile", set_string_slot,
!     (void*)XtOffsetOf(auth_config_rec,auth_pwfile), OR_AUTHCFG, TAKE1, NULL },
! { "AuthGroupFile", set_string_slot,
!     (void*)XtOffsetOf(auth_config_rec,auth_grpfile), OR_AUTHCFG, TAKE1, NULL },
  { NULL }
  };
  
--- 79,97 ----
      return pcalloc (p, sizeof(auth_config_rec));
  }
  
+ char *set_auth_slot (cmd_parms *cmd, void *offset, char *f, char *t)
+ {
+     if (t && strcmp(t, "standard"))
+         return pstrcat(cmd->pool, "Invalid auth file type: ",  t, NULL);
+ 
+     return set_string_slot(cmd, offset, f);
+ }
+ 
  command_rec auth_cmds[] = {
! { "AuthUserFile", set_auth_slot,
!   (void*)XtOffsetOf(auth_config_rec,auth_pwfile), OR_AUTHCFG, TAKE12, NULL },
! { "AuthGroupFile", set_auth_slot,
!   (void*)XtOffsetOf(auth_config_rec,auth_grpfile), OR_AUTHCFG, TAKE12, NULL },
  { NULL }
  };
  
Index: mod_auth_db.c
===================================================================
RCS file: /export/home/cvs/apache/src/mod_auth_db.c,v
retrieving revision 1.2
diff -c -r1.2 mod_auth_db.c
*** mod_auth_db.c	1996/08/20 11:50:58	1.2
--- mod_auth_db.c	1996/08/31 23:06:08
***************
*** 95,100 ****
--- 95,108 ----
      return pcalloc (p, sizeof(db_auth_config_rec));
  }
  
+ char *set_db_slot (cmd_parms *cmd, void *offset, char *f, char *t)
+ {
+     if (!t || strcmp(t, "db"))
+         return DECLINE_CMD;
+ 
+     return set_string_slot(cmd, offset, f);
+ }
+ 
  command_rec db_auth_cmds[] = {
  { "AuthDBUserFile", set_string_slot,
      (void*)XtOffsetOf(db_auth_config_rec, auth_dbpwfile),
***************
*** 102,107 ****
--- 110,121 ----
  { "AuthDBGroupFile", set_string_slot,
      (void*)XtOffsetOf(db_auth_config_rec, auth_dbgrpfile),
      OR_AUTHCFG, TAKE1, NULL },
+ { "AuthUserFile", set_db_slot,
+     (void*)XtOffsetOf(db_auth_config_rec, auth_dbpwfile),
+     OR_AUTHCFG, TAKE12, NULL },
+ { "AuthGroupFile", set_db_slot,
+     (void*)XtOffsetOf(db_auth_config_rec, auth_dbgrpfile),
+     OR_AUTHCFG, TAKE12, NULL },
  { NULL }
  };
  
Index: mod_auth_dbm.c
===================================================================
RCS file: /export/home/cvs/apache/src/mod_auth_dbm.c,v
retrieving revision 1.6
diff -c -r1.6 mod_auth_dbm.c
*** mod_auth_dbm.c	1996/08/20 11:50:59	1.6
--- mod_auth_dbm.c	1996/08/31 23:06:09
***************
*** 79,84 ****
--- 79,92 ----
      return pcalloc (p, sizeof(dbm_auth_config_rec));
  }
  
+ char *set_dbm_slot (cmd_parms *cmd, void *offset, char *f, char *t)
+ {
+     if (!t || strcmp(t, "dbm"))
+ 	return DECLINE_CMD;
+ 
+     return set_string_slot(cmd, offset, f);
+ }
+ 
  command_rec dbm_auth_cmds[] = {
  { "AuthDBMUserFile", set_string_slot,
      (void*)XtOffsetOf(dbm_auth_config_rec, auth_dbmpwfile),
***************
*** 86,91 ****
--- 94,105 ----
  { "AuthDBMGroupFile", set_string_slot,
      (void*)XtOffsetOf(dbm_auth_config_rec, auth_dbmgrpfile),
      OR_AUTHCFG, TAKE1, NULL },
+ { "AuthUserFile", set_dbm_slot,
+     (void*)XtOffsetOf(dbm_auth_config_rec, auth_dbmpwfile),
+     OR_AUTHCFG, TAKE12, NULL },
+ { "AuthGroupFile", set_dbm_slot,
+     (void*)XtOffsetOf(dbm_auth_config_rec, auth_dbmgrpfile),
+     OR_AUTHCFG, TAKE12, NULL },
  { NULL }
  };
  
Index: mod_digest.c
===================================================================
RCS file: /export/home/cvs/apache/src/mod_digest.c,v
retrieving revision 1.7
diff -c -r1.7 mod_digest.c
*** mod_digest.c	1996/08/20 11:51:05	1.7
--- mod_digest.c	1996/08/31 23:06:12
***************
*** 84,92 ****
      return pcalloc (p, sizeof(digest_config_rec));
  }
  
  command_rec digest_cmds[] = {
! { "AuthDigestFile", set_string_slot,
!     (void*)XtOffsetOf(digest_config_rec,pwfile), OR_AUTHCFG, TAKE1, NULL },
  { NULL }
  };
  
--- 84,100 ----
      return pcalloc (p, sizeof(digest_config_rec));
  }
  
+ char *set_digest_slot (cmd_parms *cmd, void *offset, char *f, char *t)
+ {
+     if (t && strcmp(t, "standard"))
+ 	return pstrcat(cmd->pool, "Invalid auth file type: ",  t, NULL);
+ 
+     return set_string_slot(cmd, offset, f);
+ }
+ 
  command_rec digest_cmds[] = {
! { "AuthDigestFile", set_digest_slot,
!   (void*)XtOffsetOf(digest_config_rec,pwfile), OR_AUTHCFG, TAKE12, NULL },
  { NULL }
  };
  


-- 
________________________________________________________________________
Alexei Kosut <akosut@nueva.pvt.k12.ca.us>      The Apache HTTP Server
URL: http://www.nueva.pvt.k12.ca.us/~akosut/   http://www.apache.org/


Mime
View raw message