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.
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)
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'}) {
# 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') {
$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'}) {
&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
&close_tempfile(FILE) ||
&error(&text('dir_ehtgroup', $gfile, $!));
&unlock_file($gfile);
+ &set_ownership_permissions(
+ undef, undef, oct($config{'perms'}) || 0644, $gfile);
}
}