iff -d, set the SO_DEBUG flags of the stdout and stderr socket;

implement parsing user@host


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@10413 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Johan Danielsson
2001-07-31 08:16:16 +00:00
parent a955fa27c0
commit b7a4b79403

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997 - 2000 Kungliga Tekniska H<>gskolan * Copyright (c) 1997 - 2001 Kungliga Tekniska H<>gskolan
* (Royal Institute of Technology, Stockholm, Sweden). * (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved. * All rights reserved.
* *
@@ -48,6 +48,7 @@ krb5_crypto crypto;
des_key_schedule schedule; des_key_schedule schedule;
des_cblock iv; des_cblock iv;
#endif #endif
int sock_debug = 0;
/* /*
@@ -522,6 +523,15 @@ proto (int s, int errsock,
return 1; return 1;
} }
if (sock_debug) {
int one = 1;
if (setsockopt(s, SOL_SOCKET, SO_DEBUG, &one, sizeof(one)) < 0)
warn("setsockopt remote");
if (errsock2 != -1 &&
setsockopt(errsock2, SOL_SOCKET, SO_DEBUG, &one, sizeof(one)) < 0)
warn("setsockopt stderr");
}
return loop (s, errsock2); return loop (s, errsock2);
} }
@@ -765,38 +775,29 @@ static int do_errsock = 1;
struct getargs args[] = { struct getargs args[] = {
#ifdef KRB4 #ifdef KRB4
{ "krb4", '4', arg_flag, &use_v4, "Use Kerberos V4", { "krb4", '4', arg_flag, &use_v4, "Use Kerberos V4" },
NULL },
#endif #endif
{ "krb5", '5', arg_flag, &use_v5, "Use Kerberos V5", { "krb5", '5', arg_flag, &use_v5, "Use Kerberos V5" },
NULL }, { "broken", 'K', arg_flag, &use_only_broken, "Use priv port" },
{ "broken", 'K', arg_flag, &use_only_broken, "Use priv port", { NULL, 'd', arg_flag, &sock_debug, "Enable socket debugging" },
NULL }, { "input", 'n', arg_negative_flag, &input, "Close stdin" },
{ "input", 'n', arg_negative_flag, &input, "Close stdin", { "encrypt", 'x', arg_flag, &do_encrypt, "Encrypt connection" },
NULL },
{ "encrypt", 'x', arg_flag, &do_encrypt, "Encrypt connection",
NULL },
{ NULL, 'z', arg_negative_flag, &do_encrypt, { NULL, 'z', arg_negative_flag, &do_encrypt,
"Don't encrypt connection", NULL }, "Don't encrypt connection", NULL },
{ "forward", 'f', arg_flag, &do_forward, "Forward credentials", { "forward", 'f', arg_flag, &do_forward, "Forward credentials"},
NULL }, { NULL, 'G', arg_negative_flag,&do_forward, "Don't forward credentials" },
{ "forward", 'G', arg_negative_flag,&do_forward, "Forward credentials",
NULL },
{ "forwardable", 'F', arg_flag, &do_forwardable, { "forwardable", 'F', arg_flag, &do_forwardable,
"Forward forwardable credentials", NULL }, "Forward forwardable credentials" },
{ "unique", 'u', arg_flag, &do_unique_tkfile, { "unique", 'u', arg_flag, &do_unique_tkfile,
"Use unique remote tkfile", NULL }, "Use unique remote tkfile" },
{ "tkfile", 'U', arg_string, &unique_tkfile, { "tkfile", 'U', arg_string, &unique_tkfile,
"Use that remote tkfile", NULL }, "Use that remote tkfile" },
{ "port", 'p', arg_string, &port_str, "Use this port", { "port", 'p', arg_string, &port_str, "Use this port",
"number-or-service" }, "number-or-service" },
{ "user", 'l', arg_string, &user, "Run as this user", { "user", 'l', arg_string, &user, "Run as this user" },
NULL }, { "stderr", 'e', arg_negative_flag, &do_errsock, "Don't open stderr"},
{ "stderr", 'e', arg_negative_flag, &do_errsock, "don't open stderr"}, { "version", 0, arg_flag, &do_version, NULL },
{ "version", 0, arg_flag, &do_version, "Print version", { "help", 0, arg_flag, &do_help, NULL }
NULL },
{ "help", 0, arg_flag, &do_help, NULL,
NULL }
}; };
static void static void
@@ -822,6 +823,7 @@ main(int argc, char **argv)
int optind = 0; int optind = 0;
int ret = 1; int ret = 1;
char *cmd; char *cmd;
char *tmp;
size_t cmd_len; size_t cmd_len;
const char *local_user; const char *local_user;
char *host = NULL; char *host = NULL;
@@ -916,6 +918,12 @@ main(int argc, char **argv)
else else
host = argv[host_index = optind++]; host = argv[host_index = optind++];
} }
if((tmp = strchr(host, '@')) != NULL) {
*tmp++ = '\0';
user = host;
host = tmp;
}
if (optind == argc) { if (optind == argc) {
close (priv_socket1); close (priv_socket1);