Module config option for permissions, UI cleanup
authorJamie Cameron <jcameron@webmin.com>
Wed, 28 Jan 2009 00:22:34 +0000 (00:22 +0000)
committerJamie Cameron <jcameron@webmin.com>
Wed, 28 Jan 2009 00:22:34 +0000 (00:22 +0000)
htaccess-htpasswd/CHANGELOG
htaccess-htpasswd/config.info
htaccess-htpasswd/edit_dir.cgi
htaccess-htpasswd/save_dir.cgi

index c74522b..4cba723 100644 (file)
@@ -20,3 +20,5 @@ Users can be limited to only editing users and groups (and not adding or changin
 Converted all user interface code to use the new Webmin UI library, for consistency.
 Fixed a bug that prevented a groups file from being added to an existing directory.
 Added a button to link to the Apache module (if accessible) for editing all settings in the .htaccess file.
+---- Changes since 1.450 ----
+Added a Module Config option to set permissions on created .htaccess and .htpasswd files, which defaults to 644.
index 2806c5b..502fc7c 100644 (file)
@@ -6,3 +6,4 @@ md5=Offer MD5 encryption option?,1,1-Yes,0-No
 sha1=Offer SHA1 encryption option?,1,1-Yes,0-No
 digest=Offer digest encryption option?,1,1-Yes,0-No
 extra_directives=Extra directives to include in .htaccess,9,0,0,\t
+perms=Permissions for created files,3,Default (644)
index e2f0875..e1b119e 100755 (executable)
@@ -18,8 +18,7 @@ else {
 
 print &ui_form_start("save_dir.cgi");
 print &ui_hidden("new", $in{'new'});
-print &ui_hidden_table_start($text{'dir_header'}, undef, 2, "main", 1,
-                            [ "width=30%" ]);
+print &ui_hidden_table_start($text{'dir_header'}, "width=100%", 2, "main", 1, [ "width=30%" ]);
 
 # Directory to protect
 if ($in{'new'}) {
@@ -114,8 +113,7 @@ print &ui_hidden_table_end();
 
 # Webmin synchronization mode
 if ($can_sync) {
-       print &ui_hidden_table_start($text{'dir_header2'}, undef, 2, "sync", 0,
-                                    [ "width=30%" ]);
+       print &ui_hidden_table_start($text{'dir_header2'}, "width=100%", 2, "sync", 0, [ "width=30%" ]);
 
        %sync = map { $_, 1 } split(/,/, $dir->[3]);
        foreach $s ('create', 'update', 'delete') {
index 9312f6e..c596814 100755 (executable)
@@ -46,11 +46,16 @@ $currgfile = &foreign_call($apachemod, "find_directive",
                           $agf, $conf, 1);
 &lock_file($currfile) if ($currfile);
 
-# Make sure it is allowed
+# Make sure it is allowed, and create new file if needed
 &switch_user();
 &can_access_dir($htaccess) || &error($text{'dir_ecannot'});
+$missing = !-r $htaccess;
 &open_tempfile(TEST, ">>$htaccess", 1) || &error(&text('dir_ehtaccess', $htaccess, $!));
 &close_tempfile(TEST);
+if ($missing) {
+       &set_ownership_permissions(
+               undef, undef, oct($config{'perms'}) || 0644, $htaccess);
+       }
 
 if ($in{'delete'} || $in{'remove'}) {
        if ($in{'remove'}) {
@@ -250,6 +255,8 @@ else {
                &close_tempfile(FILE) ||
                        &error(&text('dir_ehtpasswd', $file, $!));
                &unlock_file($file);
+               &set_ownership_permissions(
+                       undef, undef, oct($config{'perms'}) || 0644, $file);
                }
 
        # Create an empty groups file if needed
@@ -260,6 +267,8 @@ else {
                &close_tempfile(FILE) ||
                        &error(&text('dir_ehtgroup', $gfile, $!));
                &unlock_file($gfile);
+               &set_ownership_permissions(
+                       undef, undef, oct($config{'perms'}) || 0644, $gfile);
                }
        }