BSD 4_3_Net_2 release
[unix-history] / usr / src / bin / rcp / rcp.c
index ff7a0e7..a8984b2 100644 (file)
@@ -1,70 +1,85 @@
-
-/*
- *     $Source:$
- *     $Header:$
- */
-
 /*
 /*
- * Copyright (c) 1983 The Regents of the University of California.
+ * Copyright (c) 1983, 1990 The Regents of the University of California.
  * All rights reserved.
  *
  * All rights reserved.
  *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley.  The name of the
- * University may not 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.
+ * 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
 char copyright[] =
  */
 
 #ifndef lint
 char copyright[] =
-"@(#) Copyright (c) 1983 The Regents of the University of California.\n\
+"@(#) Copyright (c) 1983, 1990 The Regents of the University of California.\n\
  All rights reserved.\n";
 #endif /* not lint */
 
 #ifndef lint
  All rights reserved.\n";
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)rcp.c      5.21 (Berkeley) 7/17/89";
+static char sccsid[] = "@(#)rcp.c      5.32.1.1 (Berkeley) 8/20/91";
 #endif /* not lint */
 
 /*
  * rcp
  */
 #include <sys/param.h>
 #endif /* not lint */
 
 /*
  * rcp
  */
 #include <sys/param.h>
-#include <sys/types.h>
-#include <sys/file.h>
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <sys/ioctl.h>
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <sys/ioctl.h>
-#include <sys/dir.h>
-#include <sys/signal.h>
+#include <sys/socket.h>
+#include <sys/wait.h>
 #include <netinet/in.h>
 #include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
+#include <dirent.h>
+#include <fcntl.h>
+#include <signal.h>
 #include <pwd.h>
 #include <netdb.h>
 #include <errno.h>
 #include <pwd.h>
 #include <netdb.h>
 #include <errno.h>
-#include <strings.h>
+#include <unistd.h>
 #include <stdio.h>
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #include <ctype.h>
 #include "pathnames.h"
 
 #ifdef KERBEROS
 #include <ctype.h>
 #include "pathnames.h"
 
 #ifdef KERBEROS
-#include <krb.h>
+#include <kerberosIV/des.h>
+#include <kerberosIV/krb.h>
 char   dst_realm_buf[REALM_SZ];
 char   *dest_realm = NULL;
 char   dst_realm_buf[REALM_SZ];
 char   *dest_realm = NULL;
-int    use_kerberos = 1, encrypt = 0;
+int    use_kerberos = 1;
 CREDENTIALS    cred;
 Key_schedule   schedule;
 extern char    *krb_realmofhost();
 CREDENTIALS    cred;
 Key_schedule   schedule;
 extern char    *krb_realmofhost();
-#define        OPTIONS "dfkprtx"
+#define        OPTIONS "dfk:prt"
 #else
 #define        OPTIONS "dfprt"
 #endif
 
 #else
 #define        OPTIONS "dfprt"
 #endif
 
-extern int errno;
 struct passwd *pwd;
 u_short        port;
 uid_t  userid;
 struct passwd *pwd;
 u_short        port;
 uid_t  userid;
@@ -79,16 +94,17 @@ typedef struct _buf {
        char    *buf;
 } BUF;
 
        char    *buf;
 } BUF;
 
+void lostconn();
+
 main(argc, argv)
        int argc;
        char **argv;
 {
        extern int optind;
 main(argc, argv)
        int argc;
        char **argv;
 {
        extern int optind;
+       extern char *optarg;
        struct servent *sp;
        int ch, fflag, tflag;
        struct servent *sp;
        int ch, fflag, tflag;
-       char *targ, *colon();
-       struct passwd *getpwuid();
-       int lostconn();
+       char *targ, *shell, *colon();
 
        fflag = tflag = 0;
        while ((ch = getopt(argc, argv, OPTIONS)) != EOF)
 
        fflag = tflag = 0;
        while ((ch = getopt(argc, argv, OPTIONS)) != EOF)
@@ -102,13 +118,9 @@ main(argc, argv)
                        break;
 #ifdef KERBEROS
                case 'k':
                        break;
 #ifdef KERBEROS
                case 'k':
-                       strncpy(dst_realm_buf, ++argv, REALM_SZ);
+                       strncpy(dst_realm_buf, optarg, REALM_SZ);
                        dest_realm = dst_realm_buf;
                        break;
                        dest_realm = dst_realm_buf;
                        break;
-               case 'x':
-                       encrypt = 1;
-                       /* des_set_key(cred.session, schedule); */
-                       break;
 #endif
                /* rshd-invoked options (server) */
                case 'd':
 #endif
                /* rshd-invoked options (server) */
                case 'd':
@@ -131,26 +143,27 @@ main(argc, argv)
        argv += optind;
 
 #ifdef KERBEROS
        argv += optind;
 
 #ifdef KERBEROS
-       sp = getservbyname((encrypt ? "ekshell" : "kshell"), "tcp");
+       shell = "kshell";
+       sp = getservbyname(shell, "tcp");
        if (sp == NULL) {
                char    msgbuf[64];
                use_kerberos = 0;
        if (sp == NULL) {
                char    msgbuf[64];
                use_kerberos = 0;
-               (void) sprintf(msgbuf, "can't get entry for %s/tcp service",
-                       (encrypt ? "ekshell" : "kshell"));
+               (void)snprintf(msgbuf, sizeof(msgbuf),
+                   "can't get entry for %s/tcp service", shell);
                old_warning(msgbuf);
                old_warning(msgbuf);
-               sp = getservbyname("shell", "tcp");
+               sp = getservbyname(shell = "shell", "tcp");
        }
 #else
        }
 #else
-       sp = getservbyname("shell", "tcp");
+       sp = getservbyname(shell = "shell", "tcp");
 #endif
        if (sp == NULL) {
 #endif
        if (sp == NULL) {
-               (void)fprintf(stderr, "rcp: shell/tcp: unknown service\n");
+               (void)fprintf(stderr, "rcp: %s/tcp: unknown service\n", shell);
                exit(1);
        }
        port = sp->s_port;
 
        if (!(pwd = getpwuid(userid = getuid()))) {
                exit(1);
        }
        port = sp->s_port;
 
        if (!(pwd = getpwuid(userid = getuid()))) {
-               (void)fprintf(stderr, "rcp: unknown user %d.\n", userid);
+               (void)fprintf(stderr, "rcp: unknown user %d.\n", (int)userid);
                exit(1);
        }
 
                exit(1);
        }
 
@@ -177,12 +190,14 @@ main(argc, argv)
        rem = -1;
        /* command to be executed on remote system using "rsh" */
 #ifdef KERBEROS
        rem = -1;
        /* command to be executed on remote system using "rsh" */
 #ifdef KERBEROS
-       (void)sprintf(cmd, "rcp%s%s%s%s", iamrecursive ? " -r" : "",
-           ((encrypt && use_kerberos) ? " -x" : ""),
+       (void)snprintf(cmd, sizeof(cmd),
+           "rcp%s%s%s%s", iamrecursive ? " -r" : "",
+           "",
            pflag ? " -p" : "", targetshouldbedirectory ? " -d" : "");
 #else
            pflag ? " -p" : "", targetshouldbedirectory ? " -d" : "");
 #else
-       (void)sprintf(cmd, "rcp%s%s%s", iamrecursive ? " -r" : "",
-           pflag ? " -p" : "", targetshouldbedirectory ? " -d" : "");
+       (void)snprintf(cmd, sizeof(cmd), "rcp%s%s%s",
+           iamrecursive ? " -r" : "", pflag ? " -p" : "",
+           targetshouldbedirectory ? " -d" : "");
 #endif
 
        (void)signal(SIGPIPE, lostconn);
 #endif
 
        (void)signal(SIGPIPE, lostconn);
@@ -202,9 +217,9 @@ toremote(targ, argc, argv)
        int argc;
        char **argv;
 {
        int argc;
        char **argv;
 {
-       int i;
+       int i, len, tos;
        char *bp, *host, *src, *suser, *thost, *tuser;
        char *bp, *host, *src, *suser, *thost, *tuser;
-       char *colon(), *malloc();
+       char *colon();
 
        *targ++ = 0;
        if (*targ == 0)
 
        *targ++ = 0;
        if (*targ == 0)
@@ -230,11 +245,11 @@ toremote(targ, argc, argv)
                        if (*src == 0)
                                src = ".";
                        host = index(argv[i], '@');
                        if (*src == 0)
                                src = ".";
                        host = index(argv[i], '@');
-                       if (!(bp = malloc((u_int)(strlen(_PATH_RSH) +
-                                   strlen(argv[i]) + strlen(src) +
-                                   tuser ? strlen(tuser) : 0 + strlen(thost) +
-                                   strlen(targ)) + CMDNEEDS + 20)))
-                                       nospace();
+                       len = strlen(_PATH_RSH) + strlen(argv[i]) +
+                           strlen(src) + (tuser ? strlen(tuser) : 0) +
+                           strlen(thost) + strlen(targ) + CMDNEEDS + 20;
+                       if (!(bp = malloc(len)))
+                               nospace();
                        if (host) {
                                *host++ = 0;
                                suser = argv[i];
                        if (host) {
                                *host++ = 0;
                                suser = argv[i];
@@ -242,13 +257,14 @@ toremote(targ, argc, argv)
                                        suser = pwd->pw_name;
                                else if (!okname(suser))
                                        continue;
                                        suser = pwd->pw_name;
                                else if (!okname(suser))
                                        continue;
-                               (void)sprintf(bp,
+                               (void)snprintf(bp, len,
                                    "%s %s -l %s -n %s %s '%s%s%s:%s'",
                                    _PATH_RSH, host, suser, cmd, src,
                                    tuser ? tuser : "", tuser ? "@" : "",
                                    thost, targ);
                        } else
                                    "%s %s -l %s -n %s %s '%s%s%s:%s'",
                                    _PATH_RSH, host, suser, cmd, src,
                                    tuser ? tuser : "", tuser ? "@" : "",
                                    thost, targ);
                        } else
-                               (void)sprintf(bp, "%s %s -n %s %s '%s%s%s:%s'",
+                               (void)snprintf(bp, len,
+                                   "%s %s -n %s %s '%s%s%s:%s'",
                                    _PATH_RSH, argv[i], cmd, src,
                                    tuser ? tuser : "", tuser ? "@" : "",
                                    thost, targ);
                                    _PATH_RSH, argv[i], cmd, src,
                                    tuser ? tuser : "", tuser ? "@" : "",
                                    thost, targ);
@@ -256,10 +272,10 @@ toremote(targ, argc, argv)
                        (void)free(bp);
                } else {                        /* local to remote */
                        if (rem == -1) {
                        (void)free(bp);
                } else {                        /* local to remote */
                        if (rem == -1) {
-                               if (!(bp = malloc((u_int)strlen(targ) +
-                                   CMDNEEDS + 20)))
+                               len = strlen(targ) + CMDNEEDS + 20;
+                               if (!(bp = malloc(len)))
                                        nospace();
                                        nospace();
-                               (void)sprintf(bp, "%s -t %s", cmd, targ);
+                               (void)snprintf(bp, len, "%s -t %s", cmd, targ);
                                host = thost;
 #ifdef KERBEROS
                                if (use_kerberos)
                                host = thost;
 #ifdef KERBEROS
                                if (use_kerberos)
@@ -273,6 +289,10 @@ toremote(targ, argc, argv)
                                            bp, 0);
                                if (rem < 0)
                                        exit(1);
                                            bp, 0);
                                if (rem < 0)
                                        exit(1);
+                               tos = IPTOS_THROUGHPUT;
+                               if (setsockopt(rem, IPPROTO_IP, IP_TOS,
+                                   (char *)&tos, sizeof(int)) < 0)
+                                       perror("rcp: setsockopt TOS (ignored)");
                                if (response() < 0)
                                        exit(1);
                                (void)free(bp);
                                if (response() < 0)
                                        exit(1);
                                (void)free(bp);
@@ -287,16 +307,17 @@ tolocal(argc, argv)
        int argc;
        char **argv;
 {
        int argc;
        char **argv;
 {
-       int i;
+       int i, len, tos;
        char *bp, *host, *src, *suser;
        char *bp, *host, *src, *suser;
-       char *colon(), *malloc();
+       char *colon();
 
        for (i = 0; i < argc - 1; i++) {
                if (!(src = colon(argv[i]))) {  /* local to local */
 
        for (i = 0; i < argc - 1; i++) {
                if (!(src = colon(argv[i]))) {  /* local to local */
-                       if (!(bp = malloc((u_int)(strlen(_PATH_CP) +
-                           strlen(argv[i]) + strlen(argv[argc - 1])) + 20)))
+                       len = strlen(_PATH_CP) + strlen(argv[i]) +
+                           strlen(argv[argc - 1]) + 20;
+                       if (!(bp = malloc(len)))
                                nospace();
                                nospace();
-                       (void)sprintf(bp, "%s%s%s %s %s", _PATH_CP,
+                       (void)snprintf(bp, len, "%s%s%s %s %s", _PATH_CP,
                            iamrecursive ? " -r" : "", pflag ? " -p" : "",
                            argv[i], argv[argc - 1]);
                        (void)susystem(bp);
                            iamrecursive ? " -r" : "", pflag ? " -p" : "",
                            argv[i], argv[argc - 1]);
                        (void)susystem(bp);
@@ -318,9 +339,10 @@ tolocal(argc, argv)
                        host = argv[i];
                        suser = pwd->pw_name;
                }
                        host = argv[i];
                        suser = pwd->pw_name;
                }
-               if (!(bp = malloc((u_int)(strlen(src)) + CMDNEEDS + 20)))
+               len = strlen(src) + CMDNEEDS + 20;
+               if (!(bp = malloc(len)))
                        nospace();
                        nospace();
-               (void)sprintf(bp, "%s -f %s", cmd, src);
+               (void)snprintf(bp, len, "%s -f %s", cmd, src);
 #ifdef KERBEROS
                if (use_kerberos)
                        rem = kerberos(&host, bp, pwd->pw_name, suser);
 #ifdef KERBEROS
                if (use_kerberos)
                        rem = kerberos(&host, bp, pwd->pw_name, suser);
@@ -330,9 +352,13 @@ tolocal(argc, argv)
                (void)free(bp);
                if (rem < 0)
                        continue;
                (void)free(bp);
                if (rem < 0)
                        continue;
-               (void)setreuid(0, userid);
+               (void)seteuid(userid);
+               tos = IPTOS_THROUGHPUT;
+               if (setsockopt(rem, IPPROTO_IP, IP_TOS,
+                   (char *)&tos, sizeof(int)) < 0)
+                       perror("rcp: setsockopt TOS (ignored)");
                sink(1, argv + argc - 1);
                sink(1, argv + argc - 1);
-               (void)setreuid(userid, 0);
+               (void)seteuid(0);
                (void)close(rem);
                rem = -1;
        }
                (void)close(rem);
                rem = -1;
        }
@@ -453,17 +479,17 @@ notreg:                   (void)close(f);
                         * Make it compatible with possible future
                         * versions expecting microseconds.
                         */
                         * Make it compatible with possible future
                         * versions expecting microseconds.
                         */
-                       (void)sprintf(buf, "T%ld 0 %ld 0\n", stb.st_mtime,
-                           stb.st_atime);
-                       (void)write(rem, buf, strlen(buf));
+                       (void)snprintf(buf, sizeof(buf),
+                           "T%ld 0 %ld 0\n", stb.st_mtime, stb.st_atime);
+                       (void)write(rem, buf, (int)strlen(buf));
                        if (response() < 0) {
                                (void)close(f);
                                continue;
                        }
                }
                        if (response() < 0) {
                                (void)close(f);
                                continue;
                        }
                }
-               (void)sprintf(buf, "C%04o %ld %s\n", stb.st_mode&07777,
-                   stb.st_size, last);
-               (void)write(rem, buf, strlen(buf));
+               (void)snprintf(buf, sizeof(buf),
+                   "C%04o %ld %s\n", stb.st_mode&07777, stb.st_size, last);
+               (void)write(rem, buf, (int)strlen(buf));
                if (response() < 0) {
                        (void)close(f);
                        continue;
                if (response() < 0) {
                        (void)close(f);
                        continue;
@@ -494,11 +520,11 @@ rsource(name, statp)
        char *name;
        struct stat *statp;
 {
        char *name;
        struct stat *statp;
 {
-       DIR *d;
-       struct direct *dp;
+       DIR *dirp;
+       struct dirent *dp;
        char *last, *vect[1], path[MAXPATHLEN];
 
        char *last, *vect[1], path[MAXPATHLEN];
 
-       if (!(d = opendir(name))) {
+       if (!(dirp = opendir(name))) {
                error("rcp: %s: %s\n", name, strerror(errno));
                return;
        }
                error("rcp: %s: %s\n", name, strerror(errno));
                return;
        }
@@ -508,21 +534,22 @@ rsource(name, statp)
        else
                last++;
        if (pflag) {
        else
                last++;
        if (pflag) {
-               (void)sprintf(path, "T%ld 0 %ld 0\n", statp->st_mtime,
-                   statp->st_atime);
-               (void)write(rem, path, strlen(path));
+               (void)snprintf(path, sizeof(path),
+                   "T%ld 0 %ld 0\n", statp->st_mtime, statp->st_atime);
+               (void)write(rem, path, (int)strlen(path));
                if (response() < 0) {
                if (response() < 0) {
-                       closedir(d);
+                       closedir(dirp);
                        return;
                }
        }
                        return;
                }
        }
-       (void)sprintf(path, "D%04o %d %s\n", statp->st_mode&07777, 0, last);
-       (void)write(rem, path, strlen(path));
+       (void)snprintf(path, sizeof(path),
+           "D%04o %d %s\n", statp->st_mode&07777, 0, last);
+       (void)write(rem, path, (int)strlen(path));
        if (response() < 0) {
        if (response() < 0) {
-               closedir(d);
+               closedir(dirp);
                return;
        }
                return;
        }
-       while (dp = readdir(d)) {
+       while (dp = readdir(dirp)) {
                if (dp->d_ino == 0)
                        continue;
                if (!strcmp(dp->d_name, ".") || !strcmp(dp->d_name, ".."))
                if (dp->d_ino == 0)
                        continue;
                if (!strcmp(dp->d_name, ".") || !strcmp(dp->d_name, ".."))
@@ -531,11 +558,11 @@ rsource(name, statp)
                        error("%s/%s: name too long.\n", name, dp->d_name);
                        continue;
                }
                        error("%s/%s: name too long.\n", name, dp->d_name);
                        continue;
                }
-               (void)sprintf(path, "%s/%s", name, dp->d_name);
+               (void)snprintf(path, sizeof(path), "%s/%s", name, dp->d_name);
                vect[0] = path;
                source(1, vect);
        }
                vect[0] = path;
                source(1, vect);
        }
-       closedir(d);
+       closedir(dirp);
        (void)write(rem, "E\n", 2);
        (void)response();
 }
        (void)write(rem, "E\n", 2);
        (void)response();
 }
@@ -573,6 +600,7 @@ response()
        /*NOTREACHED*/
 }
 
        /*NOTREACHED*/
 }
 
+void
 lostconn()
 {
        if (!iamremote)
 lostconn()
 {
        if (!iamremote)
@@ -594,7 +622,7 @@ sink(argc, argv)
        char ch, *targ, *why;
        int amt, count, exists, first, mask, mode;
        int ofd, setimes, size, targisdir;
        char ch, *targ, *why;
        int amt, count, exists, first, mask, mode;
        int ofd, setimes, size, targisdir;
-       char *np, *vect[1], buf[BUFSIZ], *malloc();
+       char *np, *vect[1], buf[BUFSIZ];
 
 #define        atime   tv[0]
 #define        mtime   tv[1]
 
 #define        atime   tv[0]
 #define        mtime   tv[1]
@@ -629,7 +657,7 @@ sink(argc, argv)
 
                if (buf[0] == '\01' || buf[0] == '\02') {
                        if (iamremote == 0)
 
                if (buf[0] == '\01' || buf[0] == '\02') {
                        if (iamremote == 0)
-                               (void)write(2, buf + 1, strlen(buf + 1));
+                               (void)write(2, buf + 1, (int)strlen(buf + 1));
                        if (buf[0] == '\02')
                                exit(1);
                        errs++;
                        if (buf[0] == '\02')
                                exit(1);
                        errs++;
@@ -693,14 +721,14 @@ sink(argc, argv)
                if (targisdir) {
                        static char *namebuf;
                        static int cursize;
                if (targisdir) {
                        static char *namebuf;
                        static int cursize;
-                       int need;
+                       size_t need;
 
                        need = strlen(targ) + strlen(cp) + 250;
                        if (need > cursize) {
 
                        need = strlen(targ) + strlen(cp) + 250;
                        if (need > cursize) {
-                               if (!(namebuf = malloc((u_int)need)))
+                               if (!(namebuf = malloc(need)))
                                        error("out of memory\n");
                        }
                                        error("out of memory\n");
                        }
-                       (void)sprintf(namebuf, "%s%s%s", targ,
+                       (void)snprintf(namebuf, need, "%s%s%s", targ,
                            *targ ? "/" : "", cp);
                        np = namebuf;
                }
                            *targ ? "/" : "", cp);
                        np = namebuf;
                }
@@ -805,8 +833,7 @@ allocbuf(bp, fd, blksize)
        int fd, blksize;
 {
        struct stat stb;
        int fd, blksize;
 {
        struct stat stb;
-       int size;
-       char *malloc();
+       size_t size;
 
        if (fstat(fd, &stb) < 0) {
                error("rcp: fstat: %s\n", strerror(errno));
 
        if (fstat(fd, &stb) < 0) {
                error("rcp: fstat: %s\n", strerror(errno));
@@ -818,7 +845,7 @@ allocbuf(bp, fd, blksize)
        if (bp->cnt < size) {
                if (bp->buf != 0)
                        free(bp->buf);
        if (bp->cnt < size) {
                if (bp->buf != 0)
                        free(bp->buf);
-               bp->buf = (char *)malloc((u_int)size);
+               bp->buf = malloc(size);
                if (!bp->buf) {
                        error("rcp: malloc: out of memory\n");
                        return(0);
                if (!bp->buf) {
                        error("rcp: malloc: out of memory\n");
                        return(0);
@@ -856,8 +883,8 @@ usage()
 {
 #ifdef KERBEROS
        (void)fprintf(stderr, "%s\n\t%s\n",
 {
 #ifdef KERBEROS
        (void)fprintf(stderr, "%s\n\t%s\n",
-           "usage: rcp [-k realm] [-px] f1 f2",
-           "or: rcp [-k realm] [-rpx] f1 ... fn directory");
+           "usage: rcp [-k realm] [-p] f1 f2",
+           "or: rcp [-k realm] [-rp] f1 ... fn directory");
 #else
        (void)fprintf(stderr,
            "usage: rcp [-p] f1 f2; or: rcp [-rp] f1 ... fn directory\n");
 #else
        (void)fprintf(stderr,
            "usage: rcp [-p] f1 f2; or: rcp [-rp] f1 ... fn directory\n");
@@ -886,13 +913,6 @@ again:
                if (dest_realm == NULL)
                        dest_realm = krb_realmofhost(*host);
 
                if (dest_realm == NULL)
                        dest_realm = krb_realmofhost(*host);
 
-               if (encrypt)
-                       rem = krcmd_mutual(
-                               host, port,
-                               user, bp, 0,
-                               dest_realm,
-                               &cred, schedule);
-               else
                        rem = krcmd(
                                host, port,
                                user, bp, 0, dest_realm);
                        rem = krcmd(
                                host, port,
                                user, bp, 0, dest_realm);
@@ -916,11 +936,6 @@ again:
                        goto again;
                }
        } else {
                        goto again;
                }
        } else {
-               if (encrypt) {
-                       fprintf(stderr,
-                           "The -x option requires Kerberos authentication\n");
-                       exit(1);
-               }
                rem = rcmd(host, sp->s_port, locuser, user, bp, 0);
        }
        return(rem);
                rem = rcmd(host, sp->s_port, locuser, user, bp, 0);
        }
        return(rem);