comparison svr-runopts.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 64a50eac1030
children ee2ffa044c7e
comparison
equal deleted inserted replaced
1288:c93af4270fa1 1289:a23386821e9f
77 "-j Disable local port forwarding\n" 77 "-j Disable local port forwarding\n"
78 #endif 78 #endif
79 #ifdef ENABLE_SVR_REMOTETCPFWD 79 #ifdef ENABLE_SVR_REMOTETCPFWD
80 "-k Disable remote port forwarding\n" 80 "-k Disable remote port forwarding\n"
81 "-a Allow connections to forwarded ports from any host\n" 81 "-a Allow connections to forwarded ports from any host\n"
82 "-c command Force executed command\n"
82 #endif 83 #endif
83 "-p [address:]port\n" 84 "-p [address:]port\n"
84 " Listen on specified tcp port (and optionally address),\n" 85 " Listen on specified tcp port (and optionally address),\n"
85 " up to %d can be specified\n" 86 " up to %d can be specified\n"
86 " (default port is %s if none specified)\n" 87 " (default port is %s if none specified)\n"
123 124
124 125
125 /* see printhelp() for options */ 126 /* see printhelp() for options */
126 svr_opts.bannerfile = NULL; 127 svr_opts.bannerfile = NULL;
127 svr_opts.banner = NULL; 128 svr_opts.banner = NULL;
129 svr_opts.forced_command = NULL;
128 svr_opts.forkbg = 1; 130 svr_opts.forkbg = 1;
129 svr_opts.norootlogin = 0; 131 svr_opts.norootlogin = 0;
130 svr_opts.noauthpass = 0; 132 svr_opts.noauthpass = 0;
131 svr_opts.norootpass = 0; 133 svr_opts.norootpass = 0;
132 svr_opts.allowblankpass = 0; 134 svr_opts.allowblankpass = 0;
174 176
175 for (j = 1; (c = argv[i][j]) != '\0' && !next && !nextisport; j++) { 177 for (j = 1; (c = argv[i][j]) != '\0' && !next && !nextisport; j++) {
176 switch (c) { 178 switch (c) {
177 case 'b': 179 case 'b':
178 next = &svr_opts.bannerfile; 180 next = &svr_opts.bannerfile;
181 break;
182 case 'c':
183 next = &svr_opts.forced_command;
179 break; 184 break;
180 case 'd': 185 case 'd':
181 case 'r': 186 case 'r':
182 next = &keyfile; 187 next = &keyfile;
183 break; 188 break;