Skip to content

Commit bb2ceae

Browse files
committed
Always print denied command
In case of no configuration or an empty configuration, the command was not printed in the error message and thus made it inconvenient to add the command to the list of regular expression. Thus always print the denied command even when the is no configuration.
1 parent a21719c commit bb2ceae

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

restricted-ssh-commands

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ fi
4141

4242
config_file="/etc/restricted-ssh-commands/$config"
4343
if test ! -f "$config_file"; then
44-
log "No configuration in $config_file. All commands are denied."
44+
log "No configuration in $config_file. All commands including \"${SSH_ORIGINAL_COMMAND-}\" are denied."
4545
exit 125
4646
fi
4747

@@ -68,7 +68,7 @@ done < "$config_file"
6868

6969
if test -z "${found-}"; then
7070
if test "$num_rules" -eq 0; then
71-
log "Empty configuration in $config_file. All commands are denied."
71+
log "Empty configuration in $config_file. All commands including \"${SSH_ORIGINAL_COMMAND-}\" are denied."
7272
exit 125
7373
else
7474
if test "$num_rules" -eq 1; then

test-restricted-ssh-commands

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ tearDown() {
5858
}
5959

6060
test_missing_config() {
61-
failure "true" "foo" "restricted-ssh-commands: No configuration in ${SHUNIT_TMPDIR}/etc/restricted-ssh-commands/foo. All commands are denied." 125
61+
failure "true" "foo" "restricted-ssh-commands: No configuration in ${SHUNIT_TMPDIR}/etc/restricted-ssh-commands/foo. All commands including \"true\" are denied." 125
6262
}
6363

6464
test_empty_config() {
6565
add_rule "foo" ""
66-
failure "true" "foo" "restricted-ssh-commands: Empty configuration in ${SHUNIT_TMPDIR}/etc/restricted-ssh-commands/foo. All commands are denied." 125
66+
failure "true" "foo" "restricted-ssh-commands: Empty configuration in ${SHUNIT_TMPDIR}/etc/restricted-ssh-commands/foo. All commands including \"true\" are denied." 125
6767
}
6868

6969
test_single_rule_config() {

0 commit comments

Comments
 (0)