WHM 警告 /etc/shadow 上的无效权限,“预期:3377602730,实际:0644”

WHM 警告 /etc/shadow 上的无效权限,“预期:3377602730,实际:0644”

我收到了 WHM 实例发送的一些警报消息,警告我的影子文件权限无效。但是,实际权限 ( 0400) 似乎是正确的,并且它报告的权限似乎非常大...数字?

从今天早上开始:

/etc/shadow has non default permissions. Expected: 2401450770, Actual: 0400.
Review the permissions on /etc/shadow to ensure they are safe

从今天晚上开始:

/etc/shadow has non default permissions. Expected: 3377602730, Actual: 0400.
Review the permissions on /etc/shadow to ensure they are safe

这些报告的权限意味着什么,为什么 WHM 不满意0400

答案1

查看源代码。尝试设置权限 0200 或 0600。

sub _check_for_unsafe_permissions {
my ($self) = @_;

my %test_files = (
    '/etc/shadow' => { 'perms' => [ 0200, 0600 ], 'uid' => 0, 'gid' => 0 },
    '/etc/passwd' => { 'perms' => [0644], 'uid' => 0, 'gid' => 0 }
);

for my $file ( keys %test_files ) {
    my $expected_attributes = $test_files{$file};
    my ( $current_mode, $uid, $gid ) = ( stat($file) )[ 2, 4, 5 ];
    my $perms_ok = 0;
    foreach my $allowed_perms ( @{ $expected_attributes->{'perms'} } ) {
        if ( ( $allowed_perms & 07777 ) == ( $current_mode & 07777 ) ) {
            $perms_ok = 1;
            last;
        }
    }
    if ( !$perms_ok ) {
        my $expected_mode = sprintf( "%04o", $expected_attributes->{'perms'} );
        my $actual_mode   = sprintf( "%04o", $current_mode & 07777 );
        $self->add_warn_advice(
            'text'       => ["$file has non default permissions.  Expected: $expected_mode, Actual: $actual_mode."],
            'suggestion' => ["Review the permissions on $file to ensure they are safe"]
        );
    }

    if ( $uid != $expected_attributes->{'uid'} or $gid != $expected_attributes->{'gid'} ) {
        $self->add_warn_advice(
            'text'       => ["$file has non root user and/or group"],
            'suggestion' => ["Review the ownership permissions

预期的权限输出应该是一个 4 个字符的八进制格式的值,但看起来 perl 的 sprint 函数不正确显示了多维数组值,从而显示了垃圾。

来源(安全顾问位于 WHM - Cpanel 的安全中心内) https://github.com/bdraco/addon_securityadvisor https://github.com/bdraco/addon_securityadvisor/blob/master/pkg/Cpanel/Security/Advisor/Assessors/Permissions.pm

相关内容