print uri for directory of newly created user foerste
authorMatthias Förste <foerste@schlittermann.de>
Mon, 18 Jul 2011 14:06:28 +0200
branchfoerste
changeset 31 df24e0f202f1
parent 30 433042c33ad8
child 32 647b45aaf4da
print uri for directory of newly created user
cgi-bin/ius-dav-htuseradd.cgi
ius-dav-htpasswd.conf.ex
lib/Ius/Dav/Htpasswd.pm
--- a/cgi-bin/ius-dav-htuseradd.cgi	Mon Jul 18 13:48:33 2011 +0200
+++ b/cgi-bin/ius-dav-htuseradd.cgi	Mon Jul 18 14:06:28 2011 +0200
@@ -69,16 +69,22 @@
 for ($user, $pass, $expiry) { $doit = 1 and last if defined and $_ ne ''; }
 
 if ($doit) {
+
+    my $conf = readconfig or die "Can't readconfig"; 
     my @cmd = ( qw(sudo ius-dav-htuseradd -u), $user );
     push @cmd, '-e', $expiry if defined $expiry and $expiry ne '';
 
     print $q->hr;
     if ( my $pass = qx(@cmd) ) {
+
+        my $url = "$conf->{dav_base_remote}/$user";
+
         chomp $pass;
+
         print $q->table(
             $q->Tr(
                 $q->td('Url:'),
-                $q->td('not yet implemented')
+                $q->td($q->a({ -href => $url }, $url))
             ),
             $q->Tr(
                 $q->td('Passwort:'),
--- a/ius-dav-htpasswd.conf.ex	Mon Jul 18 13:48:33 2011 +0200
+++ b/ius-dav-htpasswd.conf.ex	Mon Jul 18 14:06:28 2011 +0200
@@ -1,29 +1,33 @@
 # expire user after this many days per default
-expiry 	    = 1
+expiry 	        = 1
 
 # don't accept arguments less than expiry_min to the --expiry option
-expiry_min  = 1
+expiry_min      = 1
 
 # don't accept arguments greater than expiry_max to the --expiry option
-expiry_max  = 56
+expiry_max      = 56
 
 
-# user directories will be placed below dav_base
-dav_base    = /srv/ius-dav
+# user directories will be placed below dav_base_local
+dav_base_local  = /srv/ius-dav
+
+# the username will be prefixed with dav_base_remote when displaying the uri
+# for the directory of a newly created user (you can omit the trailing slash)
+dav_base_remote = https://hostname/
 
 # where to place/look for the htpasswd; note that we may want a different
 # htpasswd file in the same directory to limit access to the admin cgi script
-htpasswd    = /usr/local/etc/ius-dav-htpasswd/htpasswd.dav
+htpasswd        = /usr/local/etc/ius-dav-htpasswd/htpasswd.dav
 
 # where to place/look for configuration snippets
-conf_d      = /usr/local/etc/ius-dav-htpasswd/apache.d
+conf_d          = /usr/local/etc/ius-dav-htpasswd/apache.d
 
 
 # webserver user
-www_user    = www-data
+www_user        = www-data
 
 # webserver group
-www_group   = www-data
+www_group       = www-data
 
 # master user with access to all directories (optional)
-master_user = david
+master_user     = davius
--- a/lib/Ius/Dav/Htpasswd.pm	Mon Jul 18 13:48:33 2011 +0200
+++ b/lib/Ius/Dav/Htpasswd.pm	Mon Jul 18 14:06:28 2011 +0200
@@ -58,7 +58,8 @@
           expiry=i
           expiry_min=i
           expiry_max=i
-          dav_base=s
+          dav_base_local=s
+          dav_base_remote=s
           htpasswd=s
           conf_d=s
           www_user=s
@@ -94,7 +95,7 @@
     my ( $conf, $user, $pass, $expiry ) = @_;
 
     for (
-        qw(expiry expiry_min expiry_max dav_base htpasswd conf_d www_user www_group)
+        qw(expiry expiry_min expiry_max dav_base_local htpasswd conf_d www_user www_group)
       )
     {
         die "Can't determine '$_' - please check configuration"
@@ -104,7 +105,7 @@
     $expiry = $conf->{expiry} unless defined $expiry and $expiry ne '';
     die 'Invalid input' unless validate $conf, $user, $expiry;
 
-    my $user_dir = "$conf->{dav_base}/$user";
+    my $user_dir = "$conf->{dav_base_local}/$user";
     mkdir "$user_dir" or die "Can't mkdir '$user_dir': $!";
 
     my ( $www_user, $www_group ) = @{$conf}{qw(www_user www_group)};
@@ -157,14 +158,14 @@
 
     my $rc;
 
-    for (qw(dav_base htpasswd conf_d)) {
+    for (qw(dav_base_local htpasswd conf_d)) {
         die "Can't determine '$_' - please check configuration"
           unless defined $conf->{$_};
     }
 
     # avoid 'Found = in conditional, should be ==' warnings
     no warnings qw(syntax);
-    my $user_dir = "$conf->{dav_base}/$user";
+    my $user_dir = "$conf->{dav_base_local}/$user";
     my $err;
     rmtree( $user_dir, error => $err )
       or $rc = -1