summaryrefslogtreecommitdiff
blob: a5b760cd80c260de5503802229d5b318bd01c1a8 (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
--- netkit-rsh-0.17/rlogind/rlogind.c.userandhost	2000-07-23 05:07:58.000000000 +0200
+++ netkit-rsh-0.17/rlogind/rlogind.c	2003-01-17 17:31:25.000000000 +0100
@@ -333,9 +333,10 @@
 
 
 static void child(const char *hname, const char *termtype,
-		  const char *localuser, int authenticated)
+		  const char *localuser, int authenticated,
+		  const char *rusername)
 {
-    char *termenv[2];
+    char *termenv[4];
 
     setup_term(0, termtype);
 
@@ -344,7 +345,17 @@
 	strcpy(termenv[0], "TERM=");
 	strcat(termenv[0], termtype);
     }
-    termenv[1] = NULL;
+    termenv[1] = malloc(strlen(rusername)+12);
+    if (termenv[1]) {   /* shouldn't ever fail, mind you */
+	strcpy(termenv[1], "REMOTEUSER=");
+	strcat(termenv[1], rusername);
+    }
+    termenv[2] = malloc(strlen(hname)+12);
+    if (termenv[2]) {   /* shouldn't ever fail, mind you */
+	strcpy(termenv[2], "REMOTEHOST=");
+	strcat(termenv[2], hname);
+    }
+    termenv[3] = NULL;
 
     if (authenticated) {
 	auth_finish();
@@ -420,7 +431,7 @@
     if (pid == 0) {
 	/* netfd should always be 0, but... */ 
 	if (netfd > 2) close(netfd);
-	child(hname, termtype, lusername, authenticated);
+	child(hname, termtype, lusername, authenticated, rusername);
     }
     on = 1;
     ioctl(netfd, FIONBIO, &on);
--- netkit-rsh-0.17/rshd/rshd.c.userandhost	2003-01-17 17:25:22.000000000 +0100
+++ netkit-rsh-0.17/rshd/rshd.c	2003-01-17 17:25:22.000000000 +0100
@@ -102,8 +102,10 @@
 char	homedir[64] = "HOME=";
 char	shell[64] = "SHELL=";
 char	path[100] = "PATH=";
+char	remoteuser[20] = "REMOTEUSER=";
+char	remotehost[50] = "REMOTEHOST=";
 char	*envinit[] =
-	    {homedir, shell, path, username, 0};
+	    {homedir, shell, path, username, remoteuser, remotehost, 0};
 extern	char	**environ;
 
 static void error(const char *fmt, ...);
@@ -460,6 +462,12 @@
 	strncat(homedir, pwd->pw_dir, sizeof(homedir)-6);
 	homedir[sizeof(homedir)-1] = 0;
 
+	strncat(remoteuser, remuser, sizeof(remoteuser)-12);
+	remoteuser[sizeof(remoteuser)-1] = 0;
+
+	strncat(remotehost, hostname, sizeof(remotehost)-12);
+	remotehost[sizeof(remotehost)-1] = 0;
+
 	strcat(path, _PATH_DEFPATH);
 
 	strncat(shell, theshell, sizeof(shell)-7);