Protect againsts directory clashes
authorJamie Cameron <jcameron@webmin.com>
Tue, 29 Jul 2008 16:34:42 +0000 (16:34 +0000)
committerJamie Cameron <jcameron@webmin.com>
Tue, 29 Jul 2008 16:34:42 +0000 (16:34 +0000)
htaccess-htpasswd/delete.cgi
htaccess-htpasswd/lang/en
htaccess-htpasswd/save_dir.cgi

index da2041d..02afc83 100755 (executable)
@@ -17,8 +17,8 @@ foreach $d (@d) {
                $htaccess = "$dir->[0]/$config{'htaccess'}";
                &can_access_dir($htaccess) || &error($text{'dir_ecannot'});
                &unlink_logged($htaccess);
-               &unlink_logged($dir->[1]);
-               &unlink_logged($dir->[4]) if ($dir->[4]);
+               &unlink_logged($dir->[1]) if (!-d $dir->[1]);
+               &unlink_logged($dir->[4]) if ($dir->[4] && !-d $dir->[4]);
                @dirs = grep { $_ ne $dir } @dirs;
                }
        }
index 9e5caf1..b42afd3 100644 (file)
@@ -58,6 +58,8 @@ dir_delete=Un-Protect
 dir_delete2=Un-Protect And Remove Files
 dir_delete3=Un-Protect And Remove File
 dir_apache=Edit Apache Options
+dir_efiledir='$1' is a directory, and so cannot be used as a users file
+dir_egfiledir='$1' is a directory, and so cannot be used as a groups file
 
 edit_title1=Create User
 edit_title2=Edit User
index 5973ad6..9312f6e 100755 (executable)
@@ -56,8 +56,8 @@ if ($in{'delete'} || $in{'remove'}) {
        if ($in{'remove'}) {
                # Blow away .htaccess, htpasswd and htgroups
                &unlink_logged($htaccess);
-               &unlink_logged($currfile) if ($currfile);
-               &unlink_logged($currgfile) if ($currgfile);
+               &unlink_logged($currfile) if ($currfile && !-d $currfile);
+               &unlink_logged($currgfile) if ($currgfile && !-d $currgfile);
                @dirs = grep { $_ ne $dir } @dirs;
                }
        else {
@@ -94,6 +94,7 @@ else {
                        $file = $in{'file'};
                        }
                }
+       -d $file && &error(&text('dir_efiledir', $file));
 
        # Parse groups file option
        if (!$can_htgroups) {
@@ -118,6 +119,7 @@ else {
                        $gfile = $in{'gfile'};
                        }
                }
+       -d $gfile && &error(&text('dir_egfiledir', $gfile));
 
        # Parse require option
        @require = ( $in{'require_mode'} );