]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blame - src/patches/inetutils-1.4.2-daemon_fixes-1.patch
Merge branch 'ppp-update' into beyond-next
[people/teissler/ipfire-2.x.git] / src / patches / inetutils-1.4.2-daemon_fixes-1.patch
CommitLineData
a5ee5623
MT
1Submitted By: Randy McMurchy <randy_at_linuxfromscratch_dot_org>
2Date: 2005-03-23
3Initial Package Version: 1.4.2
4Upstream Status: Not sure
5Origin: Internet (URL's are now lost)
6Description: Fix the rexecd daemon so that it understands shadow
7 passwords. Fix the rshd daemon so that it properly
8 resolves hostnames.
9
10diff -Naur inetutils-1.4.2-orig/rexecd/rexecd.c inetutils-1.4.2/rexecd/rexecd.c
11--- inetutils-1.4.2-orig/rexecd/rexecd.c 2002-12-11 12:38:00.000000000 +0000
12+++ inetutils-1.4.2/rexecd/rexecd.c 2005-02-22 19:53:44.146962264 +0000
13@@ -79,6 +79,10 @@
14 #include <varargs.h>
15 #endif
16
17+#ifdef HAVE_SHADOW_H
18+#include <shadow.h>
19+#endif
20+
21 void error __P ((const char *fmt, ...));
22 /*
23 * remote execute server:
24@@ -127,6 +131,10 @@
25 char *cmdbuf, *cp, *namep;
26 char *user, *pass;
27 struct passwd *pwd;
28+#ifdef HAVE_SHADOW_H
29+ struct spwd *spwd;
30+ char *pw_field;
31+#endif
32 int s;
33 u_short port;
34 int pv[2], pid, cc;
35@@ -186,6 +194,24 @@
36 exit(1);
37 }
38 endpwent();
39+
40+#ifdef HAVE_SHADOW_H
41+ // Get encrypted password from /etc/shadow if possible,
42+ // else from /etc/passwd.
43+ spwd = getspnam(user);
44+ if (spwd) {
45+ pw_field = spwd->sp_pwdp;
46+ } else {
47+ pw_field = pwd->pw_passwd;
48+ }
49+ if (*pw_field != '\0') {
50+ namep = CRYPT (pass, pw_field);
51+ if (strcmp(namep, pw_field)) {
52+ error("Password incorrect.\n");
53+ exit(1);
54+ }
55+ }
56+#else
57 if (*pwd->pw_passwd != '\0') {
58 namep = CRYPT (pass, pwd->pw_passwd);
59 if (strcmp(namep, pwd->pw_passwd)) {
60@@ -193,6 +219,7 @@
61 exit(1);
62 }
63 }
64+#endif
65 write(STDERR_FILENO, "\0", 1);
66 if (port) {
67 pipe(pv);
68diff -Naur inetutils-1.4.2-orig/rshd/rshd.c inetutils-1.4.2/rshd/rshd.c
69--- inetutils-1.4.2-orig/rshd/rshd.c 2002-12-11 12:38:00.000000000 +0000
70+++ inetutils-1.4.2/rshd/rshd.c 2005-02-22 19:54:33.162510768 +0000
71@@ -443,7 +443,7 @@
72 dup2 (sockfd, STDERR_FILENO);
73 }
74
75- /* Get the "name" of the clent form its Internet address.
76+ /* Get the "name" of the client form its Internet address.
77 * This is used for the autentication below
78 */
79 errorstr = NULL;
80@@ -457,52 +457,49 @@
81 * in a remote net; look up the name and check that this
82 * address corresponds to the name.
83 */
84- hostname = strdup (hp->h_name);
85+ const char *remotehost = strdup(hp->h_name);
86 #ifdef KERBEROS
87 if (!use_kerberos)
88 #endif
89- if (check_all || local_domain (hp->h_name))
90+ if (! remotehost)
91+ errorstr = "Out of memory\n";
92+ else if (check_all || local_domain (remotehost))
93 {
94- char *remotehost = (char *) alloca (strlen (hp->h_name) + 1);
95- if (! remotehost)
96- errorstr = "Out of memory\n";
97- else
98+ errorhost = remotehost;
99+ hp = gethostbyname (remotehost);
100+ if (hp == NULL)
101 {
102- strcpy (remotehost, hp->h_name);
103- errorhost = remotehost;
104- hp = gethostbyname (remotehost);
105- if (hp == NULL)
106+ syslog (LOG_INFO,
107+ "Couldn't look up address for %s", remotehost);
108+ errorstr = "Couldn't look up address for your host (%s)\n";
109+ hostname = strdup(inet_ntoa(fromp->sin_addr));
110+ }
111+ else
112+ {
113+ for (; ; hp->h_addr_list++)
114 {
115- syslog (LOG_INFO,
116- "Couldn't look up address for %s", remotehost);
117- errorstr = "Couldn't look up address for your host (%s)\n";
118- hostname = inet_ntoa (fromp->sin_addr);
119+ if (hp->h_addr_list[0] == NULL)
120+ {
121+ syslog (LOG_NOTICE,
122+ "Host addr %s not listed for host %s",
123+ inet_ntoa (fromp->sin_addr), hp->h_name);
124+ errorstr = "Host address mismatch for %s\n";
125+ hostname = strdup(inet_ntoa(fromp->sin_addr));
126+ break;
127+ }
128+ if (!memcmp (hp->h_addr_list[0],
129+ (caddr_t)&fromp->sin_addr,
130+ sizeof fromp->sin_addr))
131+ {
132+ hostname = strdup(hp->h_name);
133+ break; /* equal, OK */
134+ }
135 }
136- else
137- for (; ; hp->h_addr_list++)
138- {
139- if (hp->h_addr_list[0] == NULL)
140- {
141- syslog (LOG_NOTICE,
142- "Host addr %s not listed for host %s",
143- inet_ntoa (fromp->sin_addr), hp->h_name);
144- errorstr = "Host address mismatch for %s\n";
145- hostname = inet_ntoa (fromp->sin_addr);
146- break;
147- }
148- if (!memcmp (hp->h_addr_list[0],
149- (caddr_t)&fromp->sin_addr,
150- sizeof fromp->sin_addr))
151- {
152- hostname = hp->h_name;
153- break; /* equal, OK */
154- }
155- }
156- }
157+ }
158 }
159 }
160 else
161- errorhost = hostname = inet_ntoa (fromp->sin_addr);
162+ errorhost = hostname = strdup(inet_ntoa(fromp->sin_addr));
163
164 #ifdef KERBEROS
165 if (use_kerberos)
166