diff --git a/status/CHANGELOG b/status/CHANGELOG index 577fb2f86..bc826b2d5 100644 --- a/status/CHANGELOG +++ b/status/CHANGELOG @@ -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. diff --git a/status/file-monitor.pl b/status/file-monitor.pl index b265237e3..f616a58a4 100755 --- a/status/file-monitor.pl +++ b/status/file-monitor.pl @@ -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'}; } diff --git a/status/lang/en b/status/lang/en index c03e3621c..e2132b90a 100644 --- a/status/lang/en +++ b/status/lang/en @@ -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