kludges for parsing `rsh hostname -l user'
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@5105 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -52,7 +52,7 @@ des_cblock iv;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int input; /* Read from stdin */
|
static int input = 1; /* Read from stdin */
|
||||||
|
|
||||||
static int
|
static int
|
||||||
loop (int s, int errsock)
|
loop (int s, int errsock)
|
||||||
@@ -425,6 +425,7 @@ static int
|
|||||||
doit_broken (int argc,
|
doit_broken (int argc,
|
||||||
char **argv,
|
char **argv,
|
||||||
int optind,
|
int optind,
|
||||||
|
char *host,
|
||||||
char *remote_user,
|
char *remote_user,
|
||||||
char *local_user,
|
char *local_user,
|
||||||
int port,
|
int port,
|
||||||
@@ -439,11 +440,10 @@ doit_broken (int argc,
|
|||||||
if (priv_socket1 < 0 || priv_socket2 < 0)
|
if (priv_socket1 < 0 || priv_socket2 < 0)
|
||||||
errx (1, "unable to bind reserved port: is rsh setuid root?");
|
errx (1, "unable to bind reserved port: is rsh setuid root?");
|
||||||
|
|
||||||
hostent = roken_gethostbyname (argv[optind]);
|
hostent = roken_gethostbyname (host);
|
||||||
if (hostent == NULL)
|
if (hostent == NULL)
|
||||||
errx (1, "gethostbyname '%s' failed: %s",
|
errx (1, "gethostbyname '%s' failed: %s",
|
||||||
argv[optind],
|
host, hstrerror(h_errno));
|
||||||
hstrerror(h_errno));
|
|
||||||
|
|
||||||
memset (&addr, 0, sizeof(addr));
|
memset (&addr, 0, sizeof(addr));
|
||||||
addr.sin_family = AF_INET;
|
addr.sin_family = AF_INET;
|
||||||
@@ -469,16 +469,20 @@ doit_broken (int argc,
|
|||||||
err (1, "fork");
|
err (1, "fork");
|
||||||
else if(pid == 0) {
|
else if(pid == 0) {
|
||||||
char **new_argv;
|
char **new_argv;
|
||||||
int i;
|
int i = 0;
|
||||||
|
|
||||||
new_argv = malloc((argc + 2) * sizeof(*new_argv));
|
new_argv = malloc((argc + 2) * sizeof(*new_argv));
|
||||||
if (new_argv == NULL)
|
if (new_argv == NULL)
|
||||||
errx (1, "malloc: out of memory");
|
errx (1, "malloc: out of memory");
|
||||||
new_argv[0] = argv[0];
|
new_argv[i] = argv[i];
|
||||||
new_argv[1] = "-K";
|
++i;
|
||||||
for(i = 1; i < argc; ++i)
|
if (optind == i)
|
||||||
new_argv[i + 1] = argv[i];
|
new_argv[i++] = inet_ntoa(**h);
|
||||||
new_argv[optind + 1] = inet_ntoa(**h);
|
new_argv[i++] = "-K";
|
||||||
|
for(; i <= argc; ++i)
|
||||||
|
new_argv[i] = argv[i - 1];
|
||||||
|
if (optind > 1)
|
||||||
|
new_argv[optind + 1] = inet_ntoa(**h);
|
||||||
new_argv[argc + 1] = NULL;
|
new_argv[argc + 1] = NULL;
|
||||||
execv(PATH_RSH, new_argv);
|
execv(PATH_RSH, new_argv);
|
||||||
err(1, "execv(%s)", PATH_RSH);
|
err(1, "execv(%s)", PATH_RSH);
|
||||||
@@ -615,6 +619,8 @@ main(int argc, char **argv)
|
|||||||
size_t cmd_len;
|
size_t cmd_len;
|
||||||
struct passwd *pwd;
|
struct passwd *pwd;
|
||||||
char *local_user;
|
char *local_user;
|
||||||
|
char *host;
|
||||||
|
int host_index = -1;
|
||||||
|
|
||||||
priv_port1 = priv_port2 = IPPORT_RESERVED-1;
|
priv_port1 = priv_port2 = IPPORT_RESERVED-1;
|
||||||
priv_socket1 = rresvport(&priv_port1);
|
priv_socket1 = rresvport(&priv_port1);
|
||||||
@@ -623,6 +629,11 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
set_progname (argv[0]);
|
set_progname (argv[0]);
|
||||||
|
|
||||||
|
if (argc >= 2 && argv[1][0] != '-') {
|
||||||
|
host = argv[host_index = 1];
|
||||||
|
optind = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (getarg (args, sizeof(args) / sizeof(args[0]), argc, argv,
|
if (getarg (args, sizeof(args) / sizeof(args[0]), argc, argv,
|
||||||
&optind))
|
&optind))
|
||||||
usage (1);
|
usage (1);
|
||||||
@@ -648,8 +659,11 @@ main(int argc, char **argv)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc - optind < 2)
|
if (host == NULL)
|
||||||
usage (1);
|
if (argc - optind < 2)
|
||||||
|
usage (1);
|
||||||
|
else
|
||||||
|
host = argv[host_index = optind++];
|
||||||
|
|
||||||
if (port_str) {
|
if (port_str) {
|
||||||
struct servent *s = roken_getservbyname (port_str, "tcp");
|
struct servent *s = roken_getservbyname (port_str, "tcp");
|
||||||
@@ -674,7 +688,7 @@ main(int argc, char **argv)
|
|||||||
if (user == NULL)
|
if (user == NULL)
|
||||||
user = local_user;
|
user = local_user;
|
||||||
|
|
||||||
cmd_len = construct_command(&cmd, argc - optind - 1, argv + optind + 1);
|
cmd_len = construct_command(&cmd, argc - optind, argv + optind);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Try all different authentication methods
|
* Try all different authentication methods
|
||||||
@@ -689,7 +703,7 @@ main(int argc, char **argv)
|
|||||||
tmp_port = krb5_getportbyname (context, "kshell", "tcp", 544);
|
tmp_port = krb5_getportbyname (context, "kshell", "tcp", 544);
|
||||||
|
|
||||||
auth_method = AUTH_KRB5;
|
auth_method = AUTH_KRB5;
|
||||||
ret = doit (argv[optind], user, local_user, tmp_port, cmd, cmd_len);
|
ret = doit (host, user, local_user, tmp_port, cmd, cmd_len);
|
||||||
}
|
}
|
||||||
#ifdef KRB4
|
#ifdef KRB4
|
||||||
if (ret && use_v4) {
|
if (ret && use_v4) {
|
||||||
@@ -703,7 +717,7 @@ main(int argc, char **argv)
|
|||||||
tmp_port = krb5_getportbyname (context, "kshell", "tcp", 544);
|
tmp_port = krb5_getportbyname (context, "kshell", "tcp", 544);
|
||||||
|
|
||||||
auth_method = AUTH_KRB4;
|
auth_method = AUTH_KRB4;
|
||||||
ret = doit (argv[optind], user, local_user, tmp_port, cmd, cmd_len);
|
ret = doit (host, user, local_user, tmp_port, cmd, cmd_len);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (ret && use_broken) {
|
if (ret && use_broken) {
|
||||||
@@ -714,7 +728,7 @@ main(int argc, char **argv)
|
|||||||
else
|
else
|
||||||
tmp_port = krb5_getportbyname(context, "shell", "tcp", 514);
|
tmp_port = krb5_getportbyname(context, "shell", "tcp", 514);
|
||||||
auth_method = AUTH_BROKEN;
|
auth_method = AUTH_BROKEN;
|
||||||
ret = doit_broken (argc, argv, optind,
|
ret = doit_broken (argc, argv, host_index, host,
|
||||||
user, local_user,
|
user, local_user,
|
||||||
tmp_port,
|
tmp_port,
|
||||||
priv_socket1,
|
priv_socket1,
|
||||||
|
Reference in New Issue
Block a user