marsadm: show wrong permissions

Feature request by Tilmann Steinberg.

It greatly eases debugging when searching for a source of wrong
permissions.

Some admin tools like Puppet seem to have their own default notion
of "secure permissions" and try to "fix" them ;)
This commit is contained in:
Thomas Schoebel-Theuer 2016-02-04 13:50:36 +01:00
parent c0d57bef7a
commit 8c3cfe97f3
1 changed files with 4 additions and 2 deletions

View File

@ -5087,8 +5087,10 @@ if ($mars_stat[4]) {
lwarn "Fixed by setting to 0.\n";
}
# check permissions
if ($mars_stat[2] & 077777 != 0700) {
lwarn "Directory $mars has wrong permissions.\n";
my $perms = ($mars_stat[2] & 07777);
if ($perms != 0700) {
my $txt = sprintf("Directory $mars has wrong permissions 0%o.\n", $perms);
lwarn($txt);
chmod(0700, $mars) or ldie "Cannot chmod $mars.\n";
lwarn "Fixed to mode 0700 for security reasons.\n";
}