* 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
#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 <sys/param.h>
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
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;
#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);
#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",
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);
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))
char *argv[];
{
static BUF buffer;
- register char *cp;
struct stat stb;
struct timeval tv[2];
enum { YES, NO, DISPLAYED } wrerr;
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]
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) {
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);
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);
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");