Lines 34-40
Link Here
|
34 |
*/ |
34 |
*/ |
35 |
|
35 |
|
36 |
#if defined(LIBC_SCCS) && !defined(lint) |
36 |
#if defined(LIBC_SCCS) && !defined(lint) |
37 |
static char sccsid[] = "@(#)rexec.c 8.1 (Berkeley) 6/4/93"; |
37 |
static volatile char sccsid[] = "@(#)rexec.c 8.1 (Berkeley) 6/4/93"; |
38 |
#endif /* LIBC_SCCS and not lint */ |
38 |
#endif /* LIBC_SCCS and not lint */ |
39 |
|
39 |
|
40 |
#include <sys/types.h> |
40 |
#include <sys/types.h> |
Lines 143-148
Link Here
|
143 |
char *hdir, buf[BUFSIZ], *tmp; |
143 |
char *hdir, buf[BUFSIZ], *tmp; |
144 |
char myname[MAXHOSTNAMELEN], *mydomain; |
144 |
char myname[MAXHOSTNAMELEN], *mydomain; |
145 |
int t, i, c, usedefault = 0; |
145 |
int t, i, c, usedefault = 0; |
|
|
146 |
int myaname=0, myapass=0, myaacct=0; |
146 |
struct stat stb; |
147 |
struct stat stb; |
147 |
|
148 |
|
148 |
hdir = getenv("HOME"); |
149 |
hdir = getenv("HOME"); |
Lines 190-215
Link Here
|
190 |
while ((t = token()) && t != MACH && t != DEFAULT) switch(t) { |
191 |
while ((t = token()) && t != MACH && t != DEFAULT) switch(t) { |
191 |
|
192 |
|
192 |
case LOGIN: |
193 |
case LOGIN: |
193 |
if (token()) |
194 |
if (token()) { |
194 |
if (*aname == 0) { |
195 |
if (*aname == NULL) { |
195 |
*aname = malloc((unsigned) strlen(tokval) + 1); |
196 |
if ((*aname = strdup(tokval)) == NULL) { |
196 |
(void) strcpy(*aname, tokval); |
197 |
warnx("Error: Cannot allocate memory for user name"); |
|
|
198 |
goto bad; |
199 |
} |
200 |
myaname=1; |
197 |
} else { |
201 |
} else { |
198 |
if (strcmp(*aname, tokval)) |
202 |
if (strcmp(*aname, tokval)) |
199 |
goto next; |
203 |
goto next; |
200 |
} |
204 |
} |
|
|
205 |
} |
201 |
break; |
206 |
break; |
202 |
case PASSWD: |
207 |
case PASSWD: |
203 |
if ((*aname == 0 || strcmp(*aname, "anonymous")) && |
208 |
if ((*aname == NULL || strcmp(*aname, "anonymous")) && |
204 |
fstat(fileno(cfile), &stb) >= 0 && |
209 |
fstat(fileno(cfile), &stb) >= 0 && |
205 |
(stb.st_mode & 077) != 0) { |
210 |
(stb.st_mode & 077) != 0) { |
206 |
warnx("Error: .netrc file is readable by others."); |
211 |
warnx("Error: .netrc file is readable by others."); |
207 |
warnx("Remove password or make file unreadable by others."); |
212 |
warnx("Remove password or make file unreadable by others."); |
208 |
goto bad; |
213 |
goto bad; |
209 |
} |
214 |
} |
210 |
if (token() && *apass == 0) { |
215 |
if (token() && *apass == NULL) { |
211 |
*apass = malloc((unsigned) strlen(tokval) + 1); |
216 |
if ((*apass = strdup(tokval)) == NULL) { |
212 |
(void) strcpy(*apass, tokval); |
217 |
warnx("Error: Cannot allocate memory for password"); |
|
|
218 |
goto bad; |
219 |
} |
220 |
myapass=1; |
213 |
} |
221 |
} |
214 |
break; |
222 |
break; |
215 |
case ACCOUNT: |
223 |
case ACCOUNT: |
Lines 219-227
Link Here
|
219 |
warnx("Remove account or make file unreadable by others."); |
227 |
warnx("Remove account or make file unreadable by others."); |
220 |
goto bad; |
228 |
goto bad; |
221 |
} |
229 |
} |
222 |
if (token() && *aacct == 0) { |
230 |
if (token() && *aacct == NULL) { |
223 |
*aacct = malloc((unsigned) strlen(tokval) + 1); |
231 |
if ((*aacct = strdup(tokval)) == NULL) { |
224 |
(void) strcpy(*aacct, tokval); |
232 |
warnx("Error: Cannot allocate memory for account"); |
|
|
233 |
goto bad; |
234 |
} |
235 |
myaacct=1; |
225 |
} |
236 |
} |
226 |
break; |
237 |
break; |
227 |
case MACDEF: |
238 |
case MACDEF: |
Lines 291-296
Link Here
|
291 |
(void) fclose(cfile); |
302 |
(void) fclose(cfile); |
292 |
return (0); |
303 |
return (0); |
293 |
bad: |
304 |
bad: |
|
|
305 |
if (myaname == 1) { |
306 |
free(*aname); |
307 |
*aname = NULL; |
308 |
} |
309 |
if (myapass == 1) { |
310 |
free(*apass); |
311 |
*apass = NULL; |
312 |
} |
313 |
if (myaacct == 1) { |
314 |
free(*aacct); |
315 |
*aacct = NULL; |
316 |
} |
294 |
(void) fclose(cfile); |
317 |
(void) fclose(cfile); |
295 |
return (-1); |
318 |
return (-1); |
296 |
} |
319 |
} |
Lines 304-311
Link Here
|
304 |
{ |
327 |
{ |
305 |
struct sockaddr_in sin, sin2, from; |
328 |
struct sockaddr_in sin, sin2, from; |
306 |
struct hostent *hp; |
329 |
struct hostent *hp; |
307 |
u_short port; |
330 |
int s, timo = 1, s3 = -1; |
308 |
int s, timo = 1, s3; |
|
|
309 |
char c; |
331 |
char c; |
310 |
|
332 |
|
311 |
hp = gethostbyname(*ahost); |
333 |
hp = gethostbyname(*ahost); |
Lines 336-345
Link Here
|
336 |
} |
358 |
} |
337 |
if (fd2p == 0) { |
359 |
if (fd2p == 0) { |
338 |
(void) write(s, "", 1); |
360 |
(void) write(s, "", 1); |
339 |
port = 0; |
|
|
340 |
} else { |
361 |
} else { |
341 |
char num[8]; |
362 |
char num[8]; |
342 |
int s2, sin2len; |
363 |
int s2, sin2len; |
|
|
364 |
u_short port; |
343 |
|
365 |
|
344 |
s2 = socket(AF_INET, SOCK_STREAM, 0); |
366 |
s2 = socket(AF_INET, SOCK_STREAM, 0); |
345 |
if (s2 < 0) { |
367 |
if (s2 < 0) { |
Lines 362-368
Link Here
|
362 |
close(s2); |
384 |
close(s2); |
363 |
if (s3 < 0) { |
385 |
if (s3 < 0) { |
364 |
perror("accept"); |
386 |
perror("accept"); |
365 |
port = 0; |
|
|
366 |
goto bad; |
387 |
goto bad; |
367 |
} |
388 |
} |
368 |
} |
389 |
} |
Lines 386-392
Link Here
|
386 |
} |
407 |
} |
387 |
return (s); |
408 |
return (s); |
388 |
bad: |
409 |
bad: |
389 |
if (port) |
410 |
if (s3 >= 0) |
390 |
(void) close(*fd2p); |
411 |
(void) close(*fd2p); |
391 |
(void) close(s); |
412 |
(void) close(s); |
392 |
return (-1); |
413 |
return (-1); |