X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/c66bde989c72461b5ca17917a47f91441a3f3347..ed554bc5e4201344d7eaad78263566e79428759c:/usr/src/bin/rcp/rcp.c diff --git a/usr/src/bin/rcp/rcp.c b/usr/src/bin/rcp/rcp.c index 82f4a5350e..fc593a5858 100644 --- a/usr/src/bin/rcp/rcp.c +++ b/usr/src/bin/rcp/rcp.c @@ -2,7 +2,33 @@ * Copyright (c) 1983, 1990, 1992, 1993 * The Regents of the University of California. All rights reserved. * - * %sccs.include.redist.c% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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 BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. */ #ifndef lint @@ -12,7 +38,7 @@ static char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)rcp.c 8.1 (Berkeley) %G%"; +static char sccsid[] = "@(#)rcp.c 8.2 (Berkeley) 4/2/94"; #endif /* not lint */ #include @@ -50,7 +76,12 @@ int use_kerberos = 1; CREDENTIALS cred; Key_schedule schedule; extern char *krb_realmofhost(); +#ifdef CRYPT +int doencrypt = 0; +#define OPTIONS "dfKk:prtx" +#else #define OPTIONS "dfKk:prt" +#endif #else #define OPTIONS "dfprt" #endif @@ -98,6 +129,12 @@ main(argc, argv) dest_realm = dst_realm_buf; (void)strncpy(dst_realm_buf, optarg, REALM_SZ); break; +#ifdef CRYPT + case 'x': + doencrypt = 1; + /* des_set_key(cred.session, schedule); */ + break; +#endif #endif case 'p': pflag = 1; @@ -126,7 +163,11 @@ main(argc, argv) #ifdef KERBEROS if (use_kerberos) { +#ifdef CRYPT + shell = doencrypt ? "ekshell" : "kshell"; +#else shell = "kshell"; +#endif if ((sp = getservbyname(shell, "tcp")) == NULL) { use_kerberos = 0; oldw("can't get entry for %s/tcp service", shell); @@ -169,7 +210,11 @@ main(argc, argv) #ifdef KERBEROS (void)snprintf(cmd, sizeof(cmd), "rcp%s%s%s%s", iamrecursive ? " -r" : "", +#ifdef CRYPT + (doencrypt && use_kerberos ? " -x" : ""), +#else "", +#endif pflag ? " -p" : "", targetshouldbedirectory ? " -d" : ""); #else (void)snprintf(cmd, sizeof(cmd), "rcp%s%s%s", @@ -240,7 +285,7 @@ toremote(targ, argc, argv) thost, targ); } else (void)snprintf(bp, len, - "%s %s -n %s %s '%s%s%s:%s'", + "exec %s %s -n %s %s '%s%s%s:%s'", _PATH_RSH, argv[i], cmd, src, tuser ? tuser : "", tuser ? "@" : "", thost, targ); @@ -293,7 +338,7 @@ tolocal(argc, argv) strlen(argv[argc - 1]) + 20; if (!(bp = malloc(len))) err(1, NULL); - (void)snprintf(bp, len, "%s%s%s %s %s", _PATH_CP, + (void)snprintf(bp, len, "exec %s%s%s %s %s", _PATH_CP, iamrecursive ? " -r" : "", pflag ? " -p" : "", argv[i], argv[argc - 1]); if (susystem(bp, userid)) @@ -486,7 +531,6 @@ sink(argc, argv) char *argv[]; { static BUF buffer; - register char *cp; struct stat stb; struct timeval tv[2]; enum { YES, NO, DISPLAYED } wrerr; @@ -494,7 +538,7 @@ sink(argc, argv) off_t i, j; int amt, count, exists, first, mask, mode, ofd, omode; int setimes, size, targisdir, wrerrno; - char ch, *np, *targ, *why, *vect[1], buf[BUFSIZ]; + char ch, *cp, *np, *targ, *why, *vect[1], buf[BUFSIZ]; #define atime tv[0] #define mtime tv[1] @@ -735,6 +779,11 @@ again: if (dest_realm == NULL) dest_realm = krb_realmofhost(*host); rem = +#ifdef CRYPT + doencrypt ? + krcmd_mutual(host, + port, user, bp, 0, dest_realm, &cred, schedule) : +#endif krcmd(host, port, user, bp, 0, dest_realm); if (rem < 0) { @@ -749,6 +798,11 @@ again: goto again; } } else { +#ifdef CRYPT + if (doencrypt) + errx(1, + "the -x option requires Kerberos authentication"); +#endif rem = rcmd(host, port, locuser, user, bp, 0); } return (rem); @@ -758,8 +812,7 @@ again: int response() { - register char *cp; - char ch, resp, rbuf[BUFSIZ]; + char ch, *cp, resp, rbuf[BUFSIZ]; if (read(rem, &resp, sizeof(resp)) != sizeof(resp)) lostconn(0); @@ -793,9 +846,15 @@ void usage() { #ifdef KERBEROS +#ifdef CRYPT + (void)fprintf(stderr, "%s\n\t%s\n", + "usage: rcp [-Kpx] [-k realm] f1 f2", + "or: rcp [-Kprx] [-k realm] f1 ... fn directory"); +#else (void)fprintf(stderr, "%s\n\t%s\n", "usage: rcp [-Kp] [-k realm] f1 f2", "or: rcp [-Kpr] [-k realm] f1 ... fn directory"); +#endif #else (void)fprintf(stderr, "usage: rcp [-p] f1 f2; or: rcp [-pr] f1 ... fn directory\n");