Mercurial > dropbear
comparison svr-chansession.c @ 1289:a23386821e9f
Add -c <command> option to force a specific command
This change adds a -c option to dropbear, to force the session to use a
specific command, in a similar fashion to OpenSSH's ForceCommand
configuration option.
This is useful to provide a simple fixed service over ssh, without
requiring an authorized key file for the per-key forced_command option.
This setting takes precedence over the channel session's provided
command, and the per-key forced_command setting.
Signed-off-by: Jeremy Kerr <[email protected]>
author | Jeremy Kerr <jk@ozlabs.org> |
---|---|
date | Tue, 12 Apr 2016 21:01:08 +0800 |
parents | b1fabf797bd3 |
children | 750ec4ec4cbe |
comparison
equal
deleted
inserted
replaced
1288:c93af4270fa1 | 1289:a23386821e9f |
---|---|
669 return DROPBEAR_FAILURE; | 669 return DROPBEAR_FAILURE; |
670 } | 670 } |
671 } | 671 } |
672 } | 672 } |
673 | 673 |
674 /* take public key option 'command' into account */ | 674 |
675 svr_pubkey_set_forced_command(chansess); | 675 /* take global command into account */ |
676 if (svr_opts.forced_command) { | |
677 chansess->original_command = chansess->cmd ? : m_strdup(""); | |
678 chansess->cmd = m_strdup(svr_opts.forced_command); | |
679 } else { | |
680 /* take public key option 'command' into account */ | |
681 svr_pubkey_set_forced_command(chansess); | |
682 } | |
683 | |
676 | 684 |
677 #ifdef LOG_COMMANDS | 685 #ifdef LOG_COMMANDS |
678 if (chansess->cmd) { | 686 if (chansess->cmd) { |
679 dropbear_log(LOG_INFO, "User %s executing '%s'", | 687 dropbear_log(LOG_INFO, "User %s executing '%s'", |
680 ses.authstate.pw_name, chansess->cmd); | 688 ses.authstate.pw_name, chansess->cmd); |