feat: auto-add hostname as comment in groupAddServer / selfAddPersonalAccesss

Implements a side suggestion of #60
This commit is contained in:
Stéphane Lesimple 2021-02-18 12:45:27 +00:00 committed by Stéphane Lesimple
parent 383f2a011c
commit edb1b77dfc
3 changed files with 17 additions and 0 deletions

View file

@ -130,6 +130,12 @@ else {
osh_info "Forcing add as asked, we didn't test the SSH connection, maybe it won't work!";
}
# if no comment is specified, but we're adding the server by hostname,
# use it to craft a comment
if (!$comment && $host ne $ip) {
$comment = "hostname=$host";
}
my @command = qw{ sudo -n -u };
push @command, ($group, '--', '/usr/bin/env', 'perl', '-T', $OVH::Bastion::BASEPATH . '/bin/helper/osh-groupAddServer');
push @command, '--group', $group;

View file

@ -111,6 +111,12 @@ else {
osh_info "Forcing add as asked, we didn't test the SSH connection, maybe it won't work!";
}
# if no comment is specified, but we're adding the server by hostname,
# use it to craft a comment
if (!$comment && $host ne $ip) {
$comment = "hostname=$host";
}
my @command = qw{ sudo -n -u allowkeeper -- /usr/bin/env perl -T };
push @command, $OVH::Bastion::BASEPATH . '/bin/helper/osh-accountModifyPersonalAccess';
push @command, '--target', 'self';

View file

@ -129,6 +129,11 @@ testsuite_selfaccesses()
contain "Access denied for"
json .command null .value null .error_code KO_ACCESS_DENIED
# auto hostname=$host comment
success selfAddPersonalAccess self_add_personal_access_auto_comment $a0 --osh selfAddPersonalAccess --host localhost -u autocomment -p 1234 --force --ttl 1
json .command selfAddPersonalAccess .error_code OK .value.comment "hostname=localhost" .value.user autocomment .value.port 1234 .value.ttl 1
# forcekey
success selfListIngressKeys for_force_key $a0 --osh selfListEgressKeys