I will write on the blackboard 100 times: I will not only test the
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Mon, 22 May 1989 06:16:01 +0000 (22:16 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Mon, 22 May 1989 06:16:01 +0000 (22:16 -0800)
obscure cases, but also the blindingly obvious ones...

SCCS-vsn: bin/rcp/rcp.c 5.17

usr/src/bin/rcp/rcp.c

index a1132aa..4f77f8d 100644 (file)
@@ -22,7 +22,7 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)rcp.c      5.16 (Berkeley) %G%";
+static char sccsid[] = "@(#)rcp.c      5.17 (Berkeley) %G%";
 #endif /* not lint */
 
 /*
 #endif /* not lint */
 
 /*
@@ -72,7 +72,7 @@ main(argc, argv)
 {
        extern int optind;
        struct servent *sp;
 {
        extern int optind;
        struct servent *sp;
-       int ch;
+       int ch, fflag, tflag;
        char *targ, *colon();
        struct passwd *getpwuid();
        int lostconn();
        char *targ, *colon();
        struct passwd *getpwuid();
        int lostconn();
@@ -98,17 +98,15 @@ main(argc, argv)
                exit(1);
        }
 
                exit(1);
        }
 
+       fflag = tflag = 0;
        while ((ch = getopt(argc, argv, "dfkprtx")) != EOF)
                switch(ch) {
                case 'd':
                        targetshouldbedirectory = 1;
                        break;
                case 'f':                       /* "from" */
        while ((ch = getopt(argc, argv, "dfkprtx")) != EOF)
                switch(ch) {
                case 'd':
                        targetshouldbedirectory = 1;
                        break;
                case 'f':                       /* "from" */
-                       iamremote = 1;
-                       (void)response();
-                       (void)setuid(userid);
-                       source(--argc, ++argv);
-                       exit(errs);
+                       fflag = 1;
+                       break;
 #ifdef KERBEROS
                case 'k':
                        strncpy(krb_realm, ++argv, REALM_SZ);
 #ifdef KERBEROS
                case 'k':
                        strncpy(krb_realm, ++argv, REALM_SZ);
@@ -121,10 +119,8 @@ main(argc, argv)
                        ++iamrecursive;
                        break;
                case 't':                       /* "to" */
                        ++iamrecursive;
                        break;
                case 't':                       /* "to" */
-                       iamremote = 1;
-                       (void)setuid(userid);
-                       sink(--argc, ++argv);
-                       exit(errs);
+                       tflag = 1;
+                       break;
 #ifdef KERBEROS
                case 'x':
                        encrypt = 1;
 #ifdef KERBEROS
                case 'x':
                        encrypt = 1;
@@ -138,6 +134,21 @@ main(argc, argv)
        argc -= optind;
        argv += optind;
 
        argc -= optind;
        argv += optind;
 
+       if (fflag) {
+               iamremote = 1;
+               (void)response();
+               (void)setuid(userid);
+               source(argc, argv);
+               exit(errs);
+       }
+
+       if (tflag) {
+               iamremote = 1;
+               (void)setuid(userid);
+               sink(argc, argv);
+               exit(errs);
+       }
+
        if (argc < 2)
                usage();
        if (argc > 2)
        if (argc < 2)
                usage();
        if (argc > 2)