mirror of
https://github.com/ovh/the-bastion.git
synced 2024-09-20 23:15:58 +08:00
feat: auto-add hostname as comment in groupAddServer / selfAddPersonalAccesss
Implements a side suggestion of #60
This commit is contained in:
parent
383f2a011c
commit
edb1b77dfc
|
@ -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;
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue