Hi -- Below is set of patches which, I think, add support for the merging of directory configurations. In particular, this allows someone to do the following, in the same manner as permitted for SetHandler and other httpd directives:
<Directory /> FastCgiAuthenticator /my/auth/fcgi </Directory> <Directory /public> FastCgiAuthenticator None </Directory> <Directory /public/testing> FastCgiAuthenticator /my/test/auth/fcgi </Directory> I confess I have only tested these patches lightly -- they work for my particular application, but please review for typos and errors because I did not do thorough testing. I explicitly did not test anything to do with wrapper_info_hash, for instance. The patches also fix a typo in mod_fcgid.c that meant that FastCgiAuthorizer and FastCgiAuthorizerAuthoritative were not defined. These should apply against version 2.1 but maybe not CVS HEAD. Chris. =========================================================== --- fcgid_conf.c.orig 2007-02-15 21:34:41.000000000 -0500 +++ fcgid_conf.c 2007-04-15 16:02:41.480091450 -0400 @@ -108,6 +108,82 @@ return (void *) config; } +void *merge_dir_config_value(void *base, void *overrides, + int base_overwrite, int overrides_overwrite, + int *overwrite_ptr) +{ + if(overrides_overwrite) + { + *overwrite_ptr = 1; + return overrides; + } + else + { + *overwrite_ptr = base_overwrite; + return base; + } +} + +void *merge_fcgid_dir_config(apr_pool_t * p, void *basev, void *overridesv) +{ + fcgid_dir_conf *base = (fcgid_dir_conf *) basev; + fcgid_dir_conf *overrides = (fcgid_dir_conf *) overridesv; + fcgid_dir_conf *config = apr_pcalloc(p, sizeof(fcgid_dir_conf)); + + config->wrapper_info_hash = apr_hash_overlay(p, + overrides->wrapper_info_hash, base->wrapper_info_hash); + + config->authenticator_info = (auth_conf *) + merge_dir_config_value( + (void *) base->authenticator_info, + (void *) overrides->authenticator_info, + base->authenticator_info_overwrite, + overrides->authenticator_info_overwrite, + &config->authenticator_info_overwrite); + + config->authenticator_authoritative = *((int *) + merge_dir_config_value( + (void *) &base->authenticator_authoritative, + (void *) &overrides->authenticator_authoritative, + base->authenticator_authoritative_overwrite, + overrides->authenticator_authoritative_overwrite, + &config->authenticator_authoritative_overwrite)); + + config->authorizer_info = (auth_conf *) + merge_dir_config_value( + (void *) base->authorizer_info, + (void *) overrides->authorizer_info, + base->authorizer_info_overwrite, + overrides->authorizer_info_overwrite, + &config->authorizer_info_overwrite); + + config->authorizer_authoritative = *((int *) + merge_dir_config_value( + (void *) &base->authorizer_authoritative, + (void *) &overrides->authorizer_authoritative, + base->authorizer_authoritative_overwrite, + overrides->authorizer_authoritative_overwrite, + &config->authorizer_authoritative_overwrite)); + + config->access_info = (auth_conf *) + merge_dir_config_value( + (void *) base->access_info, + (void *) overrides->access_info, + base->access_info_overwrite, + overrides->access_info_overwrite, + &config->access_info_overwrite); + + config->access_authoritative = *((int *) + merge_dir_config_value( + (void *) &base->access_authoritative, + (void *) &overrides->access_authoritative, + base->access_authoritative_overwrite, + overrides->access_authoritative_overwrite, + &config->access_authoritative_overwrite)); + + return (void *) config; +} + const char *set_idle_timeout(cmd_parms * cmd, void *dummy, const char *arg) { server_rec *s = cmd->server; @@ -484,6 +560,11 @@ apr_finfo_t finfo; fcgid_dir_conf *dirconfig = (fcgid_dir_conf *) config; + if(strcasecmp(authenticator, "none") == 0) { + dirconfig->authenticator_info_overwrite = 1; + return NULL; + } + /* Is the wrapper exist? */ if ((rv = apr_stat(&finfo, authenticator, APR_FINFO_NORM, cmd->temp_pool)) != APR_SUCCESS) { @@ -504,6 +585,7 @@ dirconfig->authenticator_info->inode = finfo.inode; dirconfig->authenticator_info->deviceid = finfo.device; dirconfig->authenticator_info->share_group_id = (apr_size_t) - 1; + dirconfig->authenticator_info_overwrite = 1; return NULL; } @@ -513,6 +595,7 @@ fcgid_dir_conf *dirconfig = (fcgid_dir_conf *) config; dirconfig->authenticator_authoritative = arg; + dirconfig->authenticator_authoritative_overwrite = 1; return NULL; } @@ -536,6 +619,11 @@ apr_finfo_t finfo; fcgid_dir_conf *dirconfig = (fcgid_dir_conf *) config; + if(strcasecmp(authorizer, "none") == 0) { + dirconfig->authorizer_info_overwrite = 1; + return NULL; + } + /* Is the wrapper exist? */ if ((rv = apr_stat(&finfo, authorizer, APR_FINFO_NORM, cmd->temp_pool)) != APR_SUCCESS) { @@ -556,6 +644,7 @@ dirconfig->authorizer_info->inode = finfo.inode; dirconfig->authorizer_info->deviceid = finfo.device; dirconfig->authorizer_info->share_group_id = (apr_size_t) - 1; + dirconfig->authorizer_info_overwrite = 1; return NULL; } @@ -565,6 +654,7 @@ fcgid_dir_conf *dirconfig = (fcgid_dir_conf *) config; dirconfig->authorizer_authoritative = arg; + dirconfig->authorizer_authoritative_overwrite = 1; return NULL; } @@ -588,11 +678,16 @@ apr_finfo_t finfo; fcgid_dir_conf *dirconfig = (fcgid_dir_conf *) config; + if(strcasecmp(access, "none") == 0) { + dirconfig->access_info_overwrite = 1; + return NULL; + } + /* Is the wrapper exist? */ if ((rv = apr_stat(&finfo, access, APR_FINFO_NORM, cmd->temp_pool)) != APR_SUCCESS) { return apr_psprintf(cmd->pool, - "can't get authorizer file info: %s, errno: %d", + "can't get access file info: %s, errno: %d", access, apr_get_os_error()); } @@ -607,6 +702,7 @@ dirconfig->access_info->inode = finfo.inode; dirconfig->access_info->deviceid = finfo.device; dirconfig->access_info->share_group_id = (apr_size_t) - 1; + dirconfig->access_info_overwrite = 1; return NULL; } @@ -616,6 +712,7 @@ fcgid_dir_conf *dirconfig = (fcgid_dir_conf *) config; dirconfig->access_authoritative = arg; + dirconfig->access_authoritative_overwrite = 1; return NULL; } --- fcgid_conf.h.orig 2007-02-15 21:34:41.000000000 -0500 +++ fcgid_conf.h 2007-04-15 13:53:45.021839382 -0400 @@ -52,15 +52,21 @@ /* authenticator */ auth_conf *authenticator_info; + int authenticator_info_overwrite; int authenticator_authoritative; + int authenticator_authoritative_overwrite; /* authorizer */ auth_conf *authorizer_info; + int authorizer_info_overwrite; int authorizer_authoritative; + int authorizer_authoritative_overwrite; /* access check */ auth_conf *access_info; + int access_info_overwrite; int access_authoritative; + int access_authoritative_overwrite; } fcgid_dir_conf; void *create_fcgid_server_config(apr_pool_t * p, server_rec * s); @@ -68,6 +74,7 @@ void *overridesv); void *create_fcgid_dir_config(apr_pool_t * p, char *dummy); +void *merge_fcgid_dir_config(apr_pool_t * p, void *basev, void *overridesv); const char *set_idle_timeout(cmd_parms * cmd, void *dummy, const char *arg); --- mod_fcgid.c.orig 2007-02-15 21:34:41.000000000 -0500 +++ mod_fcgid.c 2007-04-15 13:56:18.959990448 -0400 @@ -580,10 +580,10 @@ set_authenticator_authoritative, NULL, ACCESS_CONF | OR_FILEINFO, "Set to 'off' to allow authentication to be passed along to lower modules upon failure"), - AP_INIT_TAKE1("FastCgiAuthenticator", set_authorizer_info, NULL, + AP_INIT_TAKE1("FastCgiAuthorizer", set_authorizer_info, NULL, ACCESS_CONF | OR_FILEINFO, "a absolute authorizer file path"), - AP_INIT_FLAG("FastCgiAuthenticatorAuthoritative", + AP_INIT_FLAG("FastCgiAuthorizerAuthoritative", set_authorizer_authoritative, NULL, ACCESS_CONF | OR_FILEINFO, "Set to 'off' to allow authorization to be passed along to lower modules upon failure"), @@ -618,7 +618,7 @@ module AP_MODULE_DECLARE_DATA fcgid_module = { STANDARD20_MODULE_STUFF, create_fcgid_dir_config, /* create per-directory config structure */ - NULL, /* merge per-directory config structures */ + merge_fcgid_dir_config, /* merge per-directory config structures */ create_fcgid_server_config, /* create per-server config structure */ merge_fcgid_server_config, /* merge per-server config structures */ fcgid_cmds, /* command apr_table_t */ ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Mod-fcgid-users mailing list Mod-fcgid-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mod-fcgid-users