if (not defined $expected_running_as || $running_as ne $expected_running_as) {
if ($running_as ne $expected_running_as) {
warn_syslog("Security violation: current running user ($running_as) unexpected (wanted $expected_running_as)");
return R('ERR_SECURITY_VIOLATION', msg => "Current running user unexpected");
}
if (grep({ $_ } @one_should_succeed) == 0 && $requester ne 'root') {
warn_syslog("Security violation: requesting user '$requester' doesn't have the right to do that (way=$way, group=" . ($shortGroup ? '<u>' : $shortGroup) . ")");
return R('ERR_SECURITY_VIOLATION', msg => "You're not allowed to do that");
}
@ -393,7 +402,7 @@ sub access_modify {
if (!(-e $file)) {
# it doesn't exist yet, create it
OVH::Bastion::touch_file($file, 0644);
OVH::Bastion::touch_file($file, oct(644));
if (!(-e $file)) {
return R('ERR_CANNOT_CREATE_FILE', msg => "File '$file' is missing and couldn't be created");
}
@ -654,7 +663,7 @@ sub get_group_list {
my ($name, $passwd, $gid, $members) = @nextgroup;
if ( $groupType eq 'key'
and $name =~ /^key/
and $name !~ /-(owner|gatekeeper|aclkeeper)$/
and $name !~ /-(?:owner|gatekeeper|aclkeeper)$/
and not grep { $name eq $_ } qw{ keykeeper keyreader })
{
$name =~ s/^key//;
@ -727,7 +736,7 @@ sub get_realm_list {
# check if account is a bastion admin (gives access to adminXyz commands)
# hint: an admin is also always a superowner
sub is_admin {
sub is_admin { ## no critic(Subroutines::RequireArgUnpacking)
my %params = @_;
my $sudo = $params{'sudo'}; # we're run under sudo
my $account = $params{'account'};
@ -761,7 +770,7 @@ sub is_admin {
# check if account is a superowner
# hint: an admin is also always a superowner
sub is_super_owner {
sub is_super_owner { ## no critic(Subroutines::RequireArgUnpacking)
my %params = @_;
my $sudo = $params{'sudo'}; # we're run under sudo
my $account = $params{'account'};
@ -796,7 +805,7 @@ sub is_super_owner {
}
# check if account is an auditor
sub is_auditor {
sub is_auditor { ## no critic(Subroutines::RequireArgUnpacking)
my %params = @_;
my $sudo = $params{'sudo'}; # we're run under sudo
my $account = $params{'account'};
@ -825,13 +834,14 @@ sub is_auditor {
}
# used by funcs below
sub _has_group_role {
sub _has_group_role { ## no critic(Subroutines::RequireArgUnpacking)
my %params = @_;
my $account = $params{'account'};
my $shortGroup = $params{'group'};
my $role = $params{'role'}; # regular or gatekeeper or owner
my $superowner = $params{'superowner'}; # allow superowner (will always return yes if so)
my $sudo = $params{'sudo'}; # are we run under sudo ?