You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by Brian Behlendorf <br...@hyperreal.com> on 1996/10/09 00:19:31 UTC

cvs commit: apache/src http_config.c http_config.h mod_auth.c mod_auth_db.c mod_auth_dbm.c mod_digest.c

brian       96/10/08 15:19:30

  Modified:    src       http_config.c http_config.h mod_auth.c
                        mod_auth_db.c  mod_auth_dbm.c mod_digest.c
  Log:
  Reviewed by:	Brian Behlendorf
  Submitted by:	Alexei Kosut
  
  Alexei wrote:
  > 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.
  
  Revision  Changes    Path
  1.25      +38 -20    apache/src/http_config.c
  
  Index: http_config.c
  ===================================================================
  RCS file: /export/home/cvs/apache/src/http_config.c,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -C3 -r1.24 -r1.25
  *** http_config.c	1996/10/06 02:25:03	1.24
  --- http_config.c	1996/10/08 22:19:20	1.25
  ***************
  *** 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
  --- 50,56 ----
     *
     */
    
  ! /* $Id: http_config.c,v 1.25 1996/10/08 22:19:20 brian Exp $ */
    
    /*
     * http_config.c: once was auxillary functions for reading httpd's config
  ***************
  *** 439,444 ****
  --- 439,455 ----
    
    	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')
  ***************
  *** 497,503 ****
       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;
  --- 508,514 ----
       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;
  ***************
  *** 508,516 ****
    
    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;
  --- 519,527 ----
    
    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;
  ***************
  *** 519,543 ****
        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)
  --- 530,561 ----
        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)
  
  
  
  1.14      +10 -2     apache/src/http_config.h
  
  Index: http_config.h
  ===================================================================
  RCS file: /export/home/cvs/apache/src/http_config.h,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -C3 -r1.13 -r1.14
  *** http_config.h	1996/10/08 21:46:57	1.13
  --- http_config.h	1996/10/08 22:19:21	1.14
  ***************
  *** 50,56 ****
     *
     */
    
  ! /* $Id: http_config.h,v 1.13 1996/10/08 21:46:57 brian Exp $ */
    
    /*
     * The central data structures around here...
  --- 50,56 ----
     *
     */
    
  ! /* $Id: http_config.h,v 1.14 1996/10/08 22:19:21 brian Exp $ */
    
    /*
     * The central data structures around here...
  ***************
  *** 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 {
  ***************
  *** 112,117 ****
  --- 113,125 ----
    #define ACCESS_CONF 64
    #define RSRC_CONF 128
    #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,
  
  
  
  1.6       +13 -5     apache/src/mod_auth.c
  
  Index: mod_auth.c
  ===================================================================
  RCS file: /export/home/cvs/apache/src/mod_auth.c,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -C3 -r1.5 -r1.6
  *** mod_auth.c	1996/08/20 11:50:57	1.5
  --- mod_auth.c	1996/10/08 22:19:22	1.6
  ***************
  *** 50,56 ****
     *
     */
    
  ! /* $Id: mod_auth.c,v 1.5 1996/08/20 11:50:57 paul Exp $ */
    
    /*
     * http_auth: authentication
  --- 50,56 ----
     *
     */
    
  ! /* $Id: mod_auth.c,v 1.6 1996/10/08 22:19:22 brian Exp $ */
    
    /*
     * http_auth: authentication
  ***************
  *** 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 }
    };
    
  
  
  
  1.3       +15 -1     apache/src/mod_auth_db.c
  
  Index: mod_auth_db.c
  ===================================================================
  RCS file: /export/home/cvs/apache/src/mod_auth_db.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -C3 -r1.2 -r1.3
  *** mod_auth_db.c	1996/08/20 11:50:58	1.2
  --- mod_auth_db.c	1996/10/08 22:19:23	1.3
  ***************
  *** 50,56 ****
     *
     */
    
  ! /* $Id: mod_auth_db.c,v 1.2 1996/08/20 11:50:58 paul Exp $ */
    
    /*
     * mod_auth_db: authentication
  --- 50,56 ----
     *
     */
    
  ! /* $Id: mod_auth_db.c,v 1.3 1996/10/08 22:19:23 brian Exp $ */
    
    /*
     * mod_auth_db: authentication
  ***************
  *** 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 }
    };
    
  
  
  
  1.7       +15 -1     apache/src/mod_auth_dbm.c
  
  Index: mod_auth_dbm.c
  ===================================================================
  RCS file: /export/home/cvs/apache/src/mod_auth_dbm.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -C3 -r1.6 -r1.7
  *** mod_auth_dbm.c	1996/08/20 11:50:59	1.6
  --- mod_auth_dbm.c	1996/10/08 22:19:23	1.7
  ***************
  *** 50,56 ****
     *
     */
    
  ! /* $Id: mod_auth_dbm.c,v 1.6 1996/08/20 11:50:59 paul Exp $ */
    
    /*
     * http_auth: authentication
  --- 50,56 ----
     *
     */
    
  ! /* $Id: mod_auth_dbm.c,v 1.7 1996/10/08 22:19:23 brian Exp $ */
    
    /*
     * http_auth: authentication
  ***************
  *** 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 }
    };
    
  
  
  
  1.8       +11 -3     apache/src/mod_digest.c
  
  Index: mod_digest.c
  ===================================================================
  RCS file: /export/home/cvs/apache/src/mod_digest.c,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -C3 -r1.7 -r1.8
  *** mod_digest.c	1996/08/20 11:51:05	1.7
  --- mod_digest.c	1996/10/08 22:19:24	1.8
  ***************
  *** 50,56 ****
     *
     */
    
  ! /* $Id: mod_digest.c,v 1.7 1996/08/20 11:51:05 paul Exp $ */
    
    /*
     * mod_digest: MD5 digest authentication
  --- 50,56 ----
     *
     */
    
  ! /* $Id: mod_digest.c,v 1.8 1996/10/08 22:19:24 brian Exp $ */
    
    /*
     * mod_digest: MD5 digest authentication
  ***************
  *** 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 }
    };