summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBertrand Jacquin <beber@meleeweb.net>2012-12-04 19:03:58 +0100
committerBertrand Jacquin <beber@meleeweb.net>2012-12-04 19:03:58 +0100
commit523f34416e58cc6c363fa936c7cc8289774337c3 (patch)
tree8cc6b512905e0b63bf5edafed9711a03f3c3f9fb
parent[CLEANUP] Reinded to prepare further work (diff)
downloadmod_virtualvalue-523f34416e58cc6c363fa936c7cc8289774337c3.tar.gz
[FEATURE] Implement rewrite AuthUserFile.
Auth* need to be placed in <Location> (or so), but VirtualValue refuse to, this could be done later maybe (see TODO). So you need to do something bastard like this : <Location /> AuthName "Access Required" AuthType Basic # This one need to be placed every time you need to use # VirtualValue AuthUserFile AuthUserFile /dev/null Require valid-user </Location> VirtualValue AuthUserFile /var/www/htpasswd-%{ENV:DOMAIN} Solution to redeclare modules/aaa/mod_authn_file.c struct doesn't enchant me, but can't find the way to move between element safely.
-rw-r--r--TODO2
-rw-r--r--mod_virtualvalue.c27
2 files changed, 28 insertions, 1 deletions
diff --git a/TODO b/TODO
index d25610e..9419573 100644
--- a/TODO
+++ b/TODO
@@ -3,6 +3,7 @@
- Validate config on startup
- Validate config on -t (hook test_config)
- Caching
+ - Handle <Location>
* Syntax evolution
@@ -28,4 +29,3 @@
- ap_log_cerror
- Use memory pool
- Use more of apr API
-
diff --git a/mod_virtualvalue.c b/mod_virtualvalue.c
index 1332524..58f5e0c 100644
--- a/mod_virtualvalue.c
+++ b/mod_virtualvalue.c
@@ -144,6 +144,7 @@ static int vv_alter_docroot (int argc, char **argv, request_rec *r);
static int vv_alter_scriptalias (int argc, char **argv, request_rec *r);
static int vv_alter_serveradmin (int argc, char **argv, request_rec *r);
static int vv_alter_servername (int argc, char **argv, request_rec *r);
+static int vv_alter_authuserfile (int argc, char **argv, request_rec *r);
static int vv_echo (int argc, char **argv, request_rec *r);
static const char *vv_replace_HTTP (char *full __U__, char *search, request_rec *r);
@@ -163,6 +164,7 @@ token_t token_tab[] = {
{ "ScriptAlias" , 12, vv_alter_scriptalias },
{ "ServerAdmin" , 12, vv_alter_serveradmin },
{ "ServerName" , 11, vv_alter_servername },
+ { "AuthUserFile" , 13, vv_alter_authuserfile },
{ "echo" , 5 , vv_echo },
{ NULL , 0 , NULL }
};
@@ -413,6 +415,31 @@ static int vv_alter_servername (int argc __U__, char **argv, request_rec *r) {
return (OK);
}
+/* As declared in modules/aaa/mod_authn_file.c */
+extern module AP_MODULE_DECLARE_DATA authn_file_module;
+
+struct authn_file_config_rec {
+ char *pwfile;
+};
+
+static int vv_alter_authuserfile (int argc __U__, char **argv, request_rec *r) {
+ struct authn_file_config_rec *conf;
+ char *authuserfile;
+
+ conf = ap_get_module_config(r->per_dir_config, &authn_file_module);
+ authuserfile = vv_flat_arg (argv[0], r);
+
+ if (!authuserfile) {
+ VV_error ("%s", "Can't build AuthUserFile");
+ return (DECLINED);
+ }
+
+ conf->pwfile = authuserfile;
+ ap_set_module_config (r->per_dir_config, &authn_file_module, conf);
+
+ return (OK);
+}
+
static void *vv_create_server_config (apr_pool_t *p, server_rec *s __U__) {
virtualvalue_cfg_t *cfg = (virtualvalue_cfg_t *)apr_pcalloc(p, sizeof(virtualvalue_cfg_t));