comparison cli-runopts.c @ 68:eee77ac31ccc

cleaning up the pubkey defines
author Matt Johnston <matt@ucc.asn.au>
date Thu, 12 Aug 2004 14:56:22 +0000
parents 38c3146aa23d
children c85c88500ea6
comparison
equal deleted inserted replaced
67:86725004a0ea 68:eee77ac31ccc
32 32
33 cli_runopts cli_opts; /* GLOBAL */ 33 cli_runopts cli_opts; /* GLOBAL */
34 34
35 static void printhelp(); 35 static void printhelp();
36 static void parsehostname(char* userhostarg); 36 static void parsehostname(char* userhostarg);
37 #ifdef DROPBEAR_PUBKEY_AUTH 37 #ifdef ENABLE_CLI_PUBKEY_AUTH
38 static void loadidentityfile(const char* filename); 38 static void loadidentityfile(const char* filename);
39 #endif 39 #endif
40 #ifdef ENABLE_CLI_ANYTCPFWD 40 #ifdef ENABLE_CLI_ANYTCPFWD
41 static void addforward(char* str, struct TCPFwdList** fwdlist); 41 static void addforward(char* str, struct TCPFwdList** fwdlist);
42 #endif 42 #endif
47 "Usage: %s [options] [user@]host\n" 47 "Usage: %s [options] [user@]host\n"
48 "Options are:\n" 48 "Options are:\n"
49 "-p <remoteport>\n" 49 "-p <remoteport>\n"
50 "-t Allocate a pty\n" 50 "-t Allocate a pty\n"
51 "-T Don't allocate a pty\n" 51 "-T Don't allocate a pty\n"
52 #ifdef DROPBEAR_PUBKEY_AUTH 52 #ifdef ENABLE_CLI_PUBKEY_AUTH
53 "-i <identityfile> (multiple allowed)\n" 53 "-i <identityfile> (multiple allowed)\n"
54 #endif 54 #endif
55 #ifdef ENABLE_CLI_LOCALTCPFWD 55 #ifdef ENABLE_CLI_LOCALTCPFWD
56 "-L <listenport:remotehsot:reportport> Local port forwarding\n" 56 "-L <listenport:remotehsot:reportport> Local port forwarding\n"
57 #endif 57 #endif
65 void cli_getopts(int argc, char ** argv) { 65 void cli_getopts(int argc, char ** argv) {
66 66
67 unsigned int i, j; 67 unsigned int i, j;
68 char ** next = 0; 68 char ** next = 0;
69 unsigned int cmdlen; 69 unsigned int cmdlen;
70 #ifdef DROPBEAR_PUBKEY_AUTH 70 #ifdef ENABLE_CLI_PUBKEY_AUTH
71 int nextiskey = 0; /* A flag if the next argument is a keyfile */ 71 int nextiskey = 0; /* A flag if the next argument is a keyfile */
72 #endif 72 #endif
73 #ifdef ENABLE_CLI_LOCALTCPFWD 73 #ifdef ENABLE_CLI_LOCALTCPFWD
74 int nextislocal = 0; 74 int nextislocal = 0;
75 #endif 75 #endif
83 cli_opts.remotehost = NULL; 83 cli_opts.remotehost = NULL;
84 cli_opts.remoteport = NULL; 84 cli_opts.remoteport = NULL;
85 cli_opts.username = NULL; 85 cli_opts.username = NULL;
86 cli_opts.cmd = NULL; 86 cli_opts.cmd = NULL;
87 cli_opts.wantpty = 9; /* 9 means "it hasn't been touched", gets set later */ 87 cli_opts.wantpty = 9; /* 9 means "it hasn't been touched", gets set later */
88 #ifdef DROPBEAR_PUBKEY_AUTH 88 #ifdef ENABLE_CLI_PUBKEY_AUTH
89 cli_opts.pubkeys = NULL; 89 cli_opts.pubkeys = NULL;
90 #endif 90 #endif
91 #ifdef ENABLE_CLI_LOCALTCPFWD 91 #ifdef ENABLE_CLI_LOCALTCPFWD
92 cli_opts.localfwds = NULL; 92 cli_opts.localfwds = NULL;
93 #endif 93 #endif
101 opts.ipv6 = 1; 101 opts.ipv6 = 1;
102 */ 102 */
103 103
104 /* Iterate all the arguments */ 104 /* Iterate all the arguments */
105 for (i = 1; i < (unsigned int)argc; i++) { 105 for (i = 1; i < (unsigned int)argc; i++) {
106 #ifdef DROPBEAR_PUBKEY_AUTH 106 #ifdef ENABLE_CLI_PUBKEY_AUTH
107 if (nextiskey) { 107 if (nextiskey) {
108 /* Load a hostkey since the previous argument was "-i" */ 108 /* Load a hostkey since the previous argument was "-i" */
109 loadidentityfile(argv[i]); 109 loadidentityfile(argv[i]);
110 nextiskey = 0; 110 nextiskey = 0;
111 continue; 111 continue;
148 148
149 switch (argv[i][1]) { 149 switch (argv[i][1]) {
150 case 'p': /* remoteport */ 150 case 'p': /* remoteport */
151 next = &cli_opts.remoteport; 151 next = &cli_opts.remoteport;
152 break; 152 break;
153 #ifdef DROPBEAR_PUBKEY_AUTH 153 #ifdef ENABLE_CLI_PUBKEY_AUTH
154 case 'i': /* an identityfile */ 154 case 'i': /* an identityfile */
155 nextiskey = 1; 155 nextiskey = 1;
156 break; 156 break;
157 #endif 157 #endif
158 case 't': /* we want a pty */ 158 case 't': /* we want a pty */
253 cli_opts.wantpty = 0; 253 cli_opts.wantpty = 0;
254 } 254 }
255 } 255 }
256 } 256 }
257 257
258 #ifdef DROPBEAR_PUBKEY_AUTH 258 #ifdef ENABLE_CLI_PUBKEY_AUTH
259 static void loadidentityfile(const char* filename) { 259 static void loadidentityfile(const char* filename) {
260 260
261 struct PubkeyList * nextkey; 261 struct PubkeyList * nextkey;
262 sign_key *key; 262 sign_key *key;
263 int keytype; 263 int keytype;