rsh.c (27954) | rsh.c (29922) |
---|---|
1/*- 2 * Copyright (c) 1983, 1990, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 28 unchanged lines hidden (view full) --- 37 The Regents of the University of California. All rights reserved.\n"; 38#endif /* not lint */ 39 40#ifndef lint 41#if 0 42static char sccsid[] = "From: @(#)rsh.c 8.3 (Berkeley) 4/6/94"; 43#endif 44static char rcsid[] = | 1/*- 2 * Copyright (c) 1983, 1990, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 28 unchanged lines hidden (view full) --- 37 The Regents of the University of California. All rights reserved.\n"; 38#endif /* not lint */ 39 40#ifndef lint 41#if 0 42static char sccsid[] = "From: @(#)rsh.c 8.3 (Berkeley) 4/6/94"; 43#endif 44static char rcsid[] = |
45 "$Id: rsh.c,v 1.11 1997/03/29 04:31:59 imp Exp $"; | 45 "$Id$"; |
46#endif /* not lint */ 47 48#include <sys/types.h> 49#include <sys/signal.h> 50#include <sys/socket.h> 51#include <sys/ioctl.h> 52#include <sys/file.h> 53#include <sys/time.h> --- 4 unchanged lines hidden (view full) --- 58#include <err.h> 59#include <errno.h> 60#include <pwd.h> 61#include <signal.h> 62#include <stdio.h> 63#include <stdlib.h> 64#include <string.h> 65#include <unistd.h> | 46#endif /* not lint */ 47 48#include <sys/types.h> 49#include <sys/signal.h> 50#include <sys/socket.h> 51#include <sys/ioctl.h> 52#include <sys/file.h> 53#include <sys/time.h> --- 4 unchanged lines hidden (view full) --- 58#include <err.h> 59#include <errno.h> 60#include <pwd.h> 61#include <signal.h> 62#include <stdio.h> 63#include <stdlib.h> 64#include <string.h> 65#include <unistd.h> |
66#include <varargs.h> | 66#include <err.h> |
67 68#include "pathnames.h" 69 70#ifdef KERBEROS 71#include <des.h> | 67 68#include "pathnames.h" 69 70#ifdef KERBEROS 71#include <des.h> |
72#include <kerberosIV/krb.h> | 72#include 73#include "krb.h" |
73 74CREDENTIALS cred; 75Key_schedule schedule; 76int use_kerberos = 1, doencrypt; 77char dst_realm_buf[REALM_SZ], *dest_realm; 78extern char *krb_realmofhost(); 79#endif 80 --- 21 unchanged lines hidden (view full) --- 102 char *args, *host, *p, *user; 103 int timeout = 0; 104 105 argoff = asrsh = dflag = nflag = 0; 106 one = 1; 107 host = user = NULL; 108 109 /* if called as something other than "rsh", use it as the host name */ | 74 75CREDENTIALS cred; 76Key_schedule schedule; 77int use_kerberos = 1, doencrypt; 78char dst_realm_buf[REALM_SZ], *dest_realm; 79extern char *krb_realmofhost(); 80#endif 81 --- 21 unchanged lines hidden (view full) --- 103 char *args, *host, *p, *user; 104 int timeout = 0; 105 106 argoff = asrsh = dflag = nflag = 0; 107 one = 1; 108 host = user = NULL; 109 110 /* if called as something other than "rsh", use it as the host name */ |
110 if (p = strrchr(argv[0], '/')) | 111 if ((p = strrchr(argv[0], '/'))) |
111 ++p; 112 else 113 p = argv[0]; 114 if (strcmp(p, "rsh")) 115 host = p; 116 else 117 asrsh = 1; 118 --- 116 unchanged lines hidden (view full) --- 235 errno = 0; 236 if (dest_realm == NULL) 237 dest_realm = krb_realmofhost(host); 238 239#ifdef CRYPT 240 if (doencrypt) { 241 rem = krcmd_mutual(&host, sp->s_port, user, args, 242 &rfd2, dest_realm, &cred, schedule); | 112 ++p; 113 else 114 p = argv[0]; 115 if (strcmp(p, "rsh")) 116 host = p; 117 else 118 asrsh = 1; 119 --- 116 unchanged lines hidden (view full) --- 236 errno = 0; 237 if (dest_realm == NULL) 238 dest_realm = krb_realmofhost(host); 239 240#ifdef CRYPT 241 if (doencrypt) { 242 rem = krcmd_mutual(&host, sp->s_port, user, args, 243 &rfd2, dest_realm, &cred, schedule); |
243 des_set_key_krb(&cred.session, schedule); | 244 des_set_key(&cred.session, schedule); |
244 } else 245#endif 246 rem = krcmd(&host, sp->s_port, user, args, &rfd2, 247 dest_realm); 248 if (rem < 0) { 249 use_kerberos = 0; 250 sp = getservbyname("shell", "tcp"); 251 if (sp == NULL) --- 90 unchanged lines hidden (view full) --- 342 err(1, "select"); 343 goto rewrite; 344 } 345 if (!FD_ISSET(rem, &rembits)) 346 goto rewrite; 347#ifdef KERBEROS 348#ifdef CRYPT 349 if (doencrypt) | 245 } else 246#endif 247 rem = krcmd(&host, sp->s_port, user, args, &rfd2, 248 dest_realm); 249 if (rem < 0) { 250 use_kerberos = 0; 251 sp = getservbyname("shell", "tcp"); 252 if (sp == NULL) --- 90 unchanged lines hidden (view full) --- 343 err(1, "select"); 344 goto rewrite; 345 } 346 if (!FD_ISSET(rem, &rembits)) 347 goto rewrite; 348#ifdef KERBEROS 349#ifdef CRYPT 350 if (doencrypt) |
350 wc = des_write(rem, bp, cc); | 351 wc = des_enc_write(rem, bp, cc, schedule, &cred.session); |
351 else 352#endif 353#endif 354 wc = write(rem, bp, cc); 355 if (wc < 0) { 356 if (errno == EWOULDBLOCK) 357 goto rewrite; 358 goto done; --- 30 unchanged lines hidden (view full) --- 389 } 390 if (srval == 0) 391 errx(1, "timeout reached (%d seconds)\n", timeout); 392 if (FD_ISSET(rfd2, &ready)) { 393 errno = 0; 394#ifdef KERBEROS 395#ifdef CRYPT 396 if (doencrypt) | 352 else 353#endif 354#endif 355 wc = write(rem, bp, cc); 356 if (wc < 0) { 357 if (errno == EWOULDBLOCK) 358 goto rewrite; 359 goto done; --- 30 unchanged lines hidden (view full) --- 390 } 391 if (srval == 0) 392 errx(1, "timeout reached (%d seconds)\n", timeout); 393 if (FD_ISSET(rfd2, &ready)) { 394 errno = 0; 395#ifdef KERBEROS 396#ifdef CRYPT 397 if (doencrypt) |
397 cc = des_read(rfd2, buf, sizeof buf); | 398 cc = des_enc_read(rfd2, buf, sizeof buf, schedule, &cred.session); |
398 else 399#endif 400#endif 401 cc = read(rfd2, buf, sizeof buf); 402 if (cc <= 0) { 403 if (errno != EWOULDBLOCK) 404 FD_CLR(rfd2, &readfrom); 405 } else 406 (void)write(2, buf, cc); 407 } 408 if (FD_ISSET(rem, &ready)) { 409 errno = 0; 410#ifdef KERBEROS 411#ifdef CRYPT 412 if (doencrypt) | 399 else 400#endif 401#endif 402 cc = read(rfd2, buf, sizeof buf); 403 if (cc <= 0) { 404 if (errno != EWOULDBLOCK) 405 FD_CLR(rfd2, &readfrom); 406 } else 407 (void)write(2, buf, cc); 408 } 409 if (FD_ISSET(rem, &ready)) { 410 errno = 0; 411#ifdef KERBEROS 412#ifdef CRYPT 413 if (doencrypt) |
413 cc = des_read(rem, buf, sizeof buf); | 414 cc = des_enc_read(rem, buf, sizeof buf, schedule, &cred.session); |
414 else 415#endif 416#endif 417 cc = read(rem, buf, sizeof buf); 418 if (cc <= 0) { 419 if (errno != EWOULDBLOCK) 420 FD_CLR(rem, &readfrom); 421 } else --- 7 unchanged lines hidden (view full) --- 429 int sig; 430{ 431 char signo; 432 433 signo = sig; 434#ifdef KERBEROS 435#ifdef CRYPT 436 if (doencrypt) | 415 else 416#endif 417#endif 418 cc = read(rem, buf, sizeof buf); 419 if (cc <= 0) { 420 if (errno != EWOULDBLOCK) 421 FD_CLR(rem, &readfrom); 422 } else --- 7 unchanged lines hidden (view full) --- 430 int sig; 431{ 432 char signo; 433 434 signo = sig; 435#ifdef KERBEROS 436#ifdef CRYPT 437 if (doencrypt) |
437 (void)des_write(rfd2, &signo, 1); | 438 (void)des_enc_write(rfd2, &signo, 1, schedule, &cred.session); |
438 else 439#endif 440#endif 441 (void)write(rfd2, &signo, 1); 442} 443 444char * 445copyargs(argv) --- 37 unchanged lines hidden --- | 439 else 440#endif 441#endif 442 (void)write(rfd2, &signo, 1); 443} 444 445char * 446copyargs(argv) --- 37 unchanged lines hidden --- |