blob: 8091dcc69ce3ebfc8bb60eb8f23d3600cce6ae23 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
--- netkit-rsh-0.16/rexec/rexec.c.prompt Mon Feb 28 16:23:33 2000
+++ netkit-rsh-0.16/rexec/rexec.c Mon Feb 28 16:49:23 2000
@@ -164,12 +164,30 @@
user_name[strlen(user_name)-1] = '\0'; /* Hopefully fgets always adds
a newline. */
passwd = getpass("Password: ");
+ } else {
+
+ if ( user_name == NULL )
+ user_name = getenv("REXEC_USER");
+ if ( user_name == NULL ) {
+ uid_t uid = getuid();
+ struct passwd *pw = getpwuid(uid);
+ if (!(pw && pw->pw_name)) {
+ fprintf(stderr, "Can't lookup uid %d\n", uid);
+ exit(1);
+ }
+ user_name = strdup(pw->pw_name);
+ }
+ if ( passwd == NULL )
+ passwd = getenv("REXEC_PASS");
+ if ( passwd == NULL )
+ passwd = getpass("Password: ");
}
- if ( user_name == NULL )
- user_name = getenv("REXEC_USER");
- if ( passwd == NULL )
- passwd = getenv("REXEC_PASS");
+ if (!(user_name && passwd)) {
+ fprintf(stderr, "Can't use %s without supplying a user and password\n",
+ progname);
+ exit(1);
+ }
if ( (sock = rexec(&host, port_exec, user_name, passwd, command,
p_to_aux_sock)) < 0 )
|