summaryrefslogtreecommitdiffhomepage
path: root/cli-runopts.c
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2007-02-22 14:53:49 +0000
committerMatt Johnston <matt@ucc.asn.au>2007-02-22 14:53:49 +0000
commitb01a74a9d757ce2b83465214bde1fa07d3e2d3ea (patch)
tree092cac6797947f7b23fcdcc2c081b19c390c5bc4 /cli-runopts.c
parent66643fa5c723da2dc781c5eeae2e008c280a7b1c (diff)
parent7f12251fbb2acefac04e13a7c6a95ca4dd4b5578 (diff)
merge of 'a9b0496634cdd25647b65e585cc3240f3fa699ee'
and 'c22be8b8f570b48e9662dac32c7b3e7148a42206' --HG-- extra : convert_revision : 066f6aef2791d54b9ec6a0c3033fd28fa946251f
Diffstat (limited to 'cli-runopts.c')
-rw-r--r--cli-runopts.c31
1 files changed, 25 insertions, 6 deletions
diff --git a/cli-runopts.c b/cli-runopts.c
index 54d4875..fc67850 100644
--- a/cli-runopts.c
+++ b/cli-runopts.c
@@ -44,12 +44,15 @@ static void addforward(char* str, struct TCPFwdList** fwdlist);
static void printhelp() {
fprintf(stderr, "Dropbear client v%s\n"
- "Usage: %s [options] [user@]host\n"
+ "Usage: %s [options] [user@]host [command]\n"
"Options are:\n"
"-p <remoteport>\n"
"-l <username>\n"
"-t Allocate a pty\n"
"-T Don't allocate a pty\n"
+ "-N Don't run a remote command\n"
+ "-f Run in background after auth\n"
+ "-y Always accept remote host key if unknown\n"
#ifdef ENABLE_CLI_PUBKEY_AUTH
"-i <identityfile> (multiple allowed)\n"
#endif
@@ -88,7 +91,10 @@ void cli_getopts(int argc, char ** argv) {
cli_opts.remoteport = NULL;
cli_opts.username = NULL;
cli_opts.cmd = NULL;
+ cli_opts.no_cmd = 0;
+ cli_opts.backgrounded = 0;
cli_opts.wantpty = 9; /* 9 means "it hasn't been touched", gets set later */
+ cli_opts.always_accept_key = 0;
#ifdef ENABLE_CLI_PUBKEY_AUTH
cli_opts.privkeys = NULL;
#endif
@@ -144,6 +150,9 @@ void cli_getopts(int argc, char ** argv) {
/* A flag *waves* */
switch (argv[i][1]) {
+ case 'y': /* always accept the remote hostkey */
+ cli_opts.always_accept_key = 1;
+ break;
case 'p': /* remoteport */
next = &cli_opts.remoteport;
break;
@@ -163,6 +172,12 @@ void cli_getopts(int argc, char ** argv) {
case 'T': /* don't want a pty */
cli_opts.wantpty = 0;
break;
+ case 'N':
+ cli_opts.no_cmd = 1;
+ break;
+ case 'f':
+ cli_opts.backgrounded = 1;
+ break;
#ifdef ENABLE_CLI_LOCALTCPFWD
case 'L':
nextislocal = 1;
@@ -269,6 +284,11 @@ void cli_getopts(int argc, char ** argv) {
cli_opts.wantpty = 0;
}
}
+
+ if (cli_opts.backgrounded && cli_opts.cmd == NULL
+ && cli_opts.no_cmd == 0) {
+ dropbear_exit("command required for -f");
+ }
}
#ifdef ENABLE_CLI_PUBKEY_AUTH
@@ -348,7 +368,8 @@ static void addforward(char* origstr, struct TCPFwdList** fwdlist) {
TRACE(("enter addforward"))
- /* We probably don't want to be editing argvs */
+ /* We need to split the original argument up. This var
+ is never free()d. */
str = m_strdup(origstr);
listenport = str;
@@ -358,8 +379,7 @@ static void addforward(char* origstr, struct TCPFwdList** fwdlist) {
TRACE(("connectaddr == NULL"))
goto fail;
}
-
- connectaddr[0] = '\0';
+ *connectaddr = '\0';
connectaddr++;
connectport = strchr(connectaddr, ':');
@@ -367,8 +387,7 @@ static void addforward(char* origstr, struct TCPFwdList** fwdlist) {
TRACE(("connectport == NULL"))
goto fail;
}
-
- connectport[0] = '\0';
+ *connectport = '\0';
connectport++;
newfwd = (struct TCPFwdList*)m_malloc(sizeof(struct TCPFwdList));