X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/fdb8e4aac282b72d4670aa3a26d9bba07afc7e6f..1c15e88899094343f75aeba04122cd96a96b428e:/usr/src/usr.bin/rsh/rsh.c diff --git a/usr/src/usr.bin/rsh/rsh.c b/usr/src/usr.bin/rsh/rsh.c index 033393d8f8..4a19b7c809 100644 --- a/usr/src/usr.bin/rsh/rsh.c +++ b/usr/src/usr.bin/rsh/rsh.c @@ -2,7 +2,19 @@ * Copyright (c) 1983, 1990 The Regents of the University of California. * All rights reserved. * - * %sccs.include.redist.c% + * Redistribution and use in source and binary forms are permitted + * provided that: (1) source distributions retain this entire copyright + * notice and comment, and (2) distributions including binaries display + * the following acknowledgement: ``This product includes software + * developed by the University of California, Berkeley and its contributors'' + * in the documentation or other materials provided with the distribution + * and in all advertising materials mentioning features or use of this + * software. Neither the name of the University nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint @@ -12,7 +24,7 @@ char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)rsh.c 5.23.1.1 (Berkeley) %G%"; +static char sccsid[] = "@(#)rsh.c 5.21 (Berkeley) 5/15/90"; #endif /* not lint */ /* @@ -88,7 +100,7 @@ main(argc, argv) } #ifdef KERBEROS -#define OPTIONS "8KLdek:l:nw" +#define OPTIONS "8KLdek:l:nwx" #else #define OPTIONS "8KLdel:nw" #endif @@ -120,6 +132,10 @@ main(argc, argv) nflag = 1; break; #ifdef KERBEROS + case 'x': + encrypt = 1; + des_set_key(cred.session, schedule); + break; #endif case '?': default: @@ -151,6 +167,9 @@ main(argc, argv) user = pw->pw_name; #ifdef KERBEROS + /* -x turns off -n */ + if (encrypt) + nflag = 0; #endif args = copyargs(argv); @@ -181,6 +200,10 @@ try_connect: if (dest_realm == NULL) dest_realm = krb_realmofhost(host); + if (encrypt) + rem = krcmd_mutual(&host, sp->s_port, user, args, + &rfd2, dest_realm, &cred, schedule); + else rem = krcmd(&host, sp->s_port, user, args, &rfd2, dest_realm); if (rem < 0) { @@ -246,6 +269,7 @@ try_connect: } #ifdef KERBEROS + if (!encrypt) #endif { (void)ioctl(rfd2, FIONBIO, &one); @@ -289,6 +313,9 @@ rewrite: rembits = 1 << rem; if ((rembits & (1 << rem)) == 0) goto rewrite; #ifdef KERBEROS + if (encrypt) + wc = des_write(rem, bp, cc); + else #endif wc = write(rem, bp, cc); if (wc < 0) { @@ -321,6 +348,9 @@ done: if (ready & (1 << rfd2)) { errno = 0; #ifdef KERBEROS + if (encrypt) + cc = des_read(rfd2, buf, sizeof buf); + else #endif cc = read(rfd2, buf, sizeof buf); if (cc <= 0) { @@ -332,6 +362,9 @@ done: if (ready & (1 << rem)) { errno = 0; #ifdef KERBEROS + if (encrypt) + cc = des_read(rem, buf, sizeof buf); + else #endif cc = read(rem, buf, sizeof buf); if (cc <= 0) { @@ -348,6 +381,9 @@ sendsig(signo) char signo; { #ifdef KERBEROS + if (encrypt) + (void)des_write(rfd2, &signo, 1); + else #endif (void)write(rfd2, &signo, 1); } @@ -396,11 +432,11 @@ copyargs(argv) usage() { (void)fprintf(stderr, - "usage: rsh [-nd%s]%s[-l login] host [command]\n", + "usage: rsh [-ndx]%s[-l login] host [command]\n", #ifdef KERBEROS - "", " [-k realm] "); + " [-k realm] "); #else - "", " "); + " "); #endif exit(1); }