Add check for file permissions

This commit is contained in:
Jamie Cameron
2018-12-22 21:21:06 -08:00
parent b1a580cd57
commit 04b36157d9
3 changed files with 21 additions and 1 deletions

View File

@@ -89,4 +89,4 @@ Added a Module Config option to show the last collected status on the Webmin sys
---- Changes since 1.870 ----
Added a config option to set a minimum interval between notifications for each monitor.
---- Changes since 1.900 ----
Added support for file ownership checks to the File or Directory monitor.
Added support for file ownership and permission checks to the File or Directory monitor.

View File

@@ -14,6 +14,7 @@ my $allup = 1;
my @badsizes;
my @badowners;
my @badgroups;
my @badperms;
my @allsizes;
foreach my $f (@files) {
local @st = stat($f);
@@ -50,6 +51,7 @@ foreach my $f (@files) {
push(@badowners, $f);
}
}
if ($_[0]->{'group'}) {
# Check for group
my $g = getgrgid($st[5]);
@@ -59,6 +61,15 @@ foreach my $f (@files) {
push(@badgroups, $f);
}
}
if ($_[0]->{'perms'}) {
# Check for permissions
if (($st[2]&0777) != oct($_[0]->{'perms'})) {
$allup = 0;
push(@badperms, $f);
}
}
push(@allsizes, $size) if (defined($size));
}
@@ -80,6 +91,9 @@ if (@badowners) {
if (@badgroups) {
push(@descs, &text('file_egroup', join(" ", @badgroups)));
}
if (@badperms) {
push(@descs, &text('file_eperm', join(" ", @badperms)));
}
my $rv = { 'up' => $allup,
'desc' => join(", ", @descs) };
@@ -113,6 +127,10 @@ print &ui_table_row($text{'file_owner'},
print &ui_table_row($text{'file_group'},
&ui_opt_textbox("group", $_[0]->{'group'}, 20,
$text{'file_nocheck'}), 3);
print &ui_table_row($text{'file_perms'},
&ui_opt_textbox("perms", $_[0]->{'perms'}, 4,
$text{'file_nocheck'}), 3);
}
sub parse_file_dialog
@@ -126,5 +144,6 @@ $_[0]->{'greater'} = $in{'greater'};
$_[0]->{'lesser'} = $in{'lesser'};
$_[0]->{'owner'} = $in{'owner_def'} ? undef : $in{'owner'};
$_[0]->{'group'} = $in{'group_def'} ? undef : $in{'group'};
$_[0]->{'perms'} = $in{'perms_def'} ? undef : $in{'perms'};
}

View File

@@ -261,6 +261,7 @@ file_owner=File owner must be
file_group=File group must be
file_nocheck=Anything
file_perms=Octal permissions must be
file_eperm=Files with wrong permissions : $1
traffic_iface=Interface to monitor
traffic_bytes=Maximum bytes/second