"-v" handling in scp (was Re: add scp path to _PATH_STDPATH)

Ishikawa ishikawa at yk.rim.or.jp
Mon Mar 5 08:52:52 EST 2001


mouring at etoh.eviladmin.org wrote:

> Would be better because your patch accepts unlimited -v, but only honors
> the first three.
>
>

How about the modified patch.

As it turned out, while I tried to modify the '-v' handling to warn the
user about more than three '-v's, I found out if I specify more than
three "-v"s, the local ssh barfs!

Example:

    ishikawa at duron$ ./scp  -v -v -v -v /tmp/t.bug
ishikawa at host.example.com:/tmp/t.bug
    Only the first three '-v's are honoured for passing to remote scp. The
rest is ignored.
    The local ssh receive as many '-v's as specified.
    Executing: program /usr/local/bin/ssh host ishikawa at host.example.com,
user ishikawa, command scp -v -v -v -t /tmp/t.bug
    OpenSSH_2.5.1p2, SSH protocols 1.5/2.0, OpenSSL 0x0090581f
    Too high debugging level.

    lost connection
    (* what ?! *)
    ishikawa at duron$ ./ssh -v -v -v -v
    OpenSSH_2.5.1p2, SSH protocols 1.5/2.0, OpenSSL 0x0090581f
    Too high debugging level.


So here is a slightly modified patch.
With this, the user at least gets the warning if s/he specifies
more than three "-v"s. The rest is ignored.

Example.

    ./scp -v -v -v -v /tmp/t.lst host:/tmp/t.lst

    Only the first three '-v's are honoured for passing to remote scp.
    OpenSSH ssh 2.5.1p2 only accepts only up to three '-v's.
    The rest is ignored.

    Executing: program /usr/local/bin/ssh host host, user (unspecified),
command scp -v -v -v -t /tmp/t.lst
    OpenSSH_2.5.1p2, SSH protocols 1.5/2.0, OpenSSL 0x0090581f
    debug: Reading configuration data /usr/local/etc/ssh_config
    debug: Applying options for *
    debug: ssh_connect: getuid 1001 geteuid 0 anon 0
    ...

ishikawa at duron$ rcsdiff -c scp.c
===================================================================
RCS file: RCS/scp.c,v
retrieving revision 1.1
diff -c -r1.1 scp.c
*** scp.c       2001/03/04 18:35:17     1.1
--- scp.c       2001/03/04 21:44:14
***************
*** 277,284 ****
                        ssh_program = xstrdup(optarg);
                        break;
                case 'v':
!                       verbose_mode = 1;
!                       break;
                case 'q':
                        showprogress = 0;
                        break;
--- 277,294 ----
                        ssh_program = xstrdup(optarg);
                        break;
                case 'v':
!                 verbose_mode ++; /* for remote  */
!                 if(verbose_mode <= 3)
!                   addargs("-v"); /* for local ssh */
!                 if(verbose_mode == 4)
!                   {
!
!                     fprintf(stderr,"\nOnly the first three '-v's are
honoured for passing to remote scp. \n");
!                     fprintf(stderr,"OpenSSH ssh 2.5.1p2 only accepts only
up to three '-v's.\n");
!                     fprintf(stderr,"The rest is ignored.\n\n");
!
!                   }
!                 break;
                case 'q':
                        showprogress = 0;
                        break;
***************
*** 330,336 ****
        remin = remout = -1;
        /* Command to be executed on remote system using "ssh". */
        (void) snprintf(cmd, sizeof cmd, "scp%s%s%s%s",
!           verbose_mode ? " -v" : "",
            iamrecursive ? " -r" : "", pflag ? " -p" : "",
            targetshouldbedirectory ? " -d" : "");

--- 340,350 ----
        remin = remout = -1;
        /* Command to be executed on remote system using "ssh". */
        (void) snprintf(cmd, sizeof cmd, "scp%s%s%s%s",
!                       /** try to handle up to three '-v's. */
!                       verbose_mode <=0  ? ""
!                       : ( verbose_mode == 1 ? " -v"
!                           : ( verbose_mode == 2 ? " -v -v"
!                               : " -v -v -v" )),
            iamrecursive ? " -r" : "", pflag ? " -p" : "",
            targetshouldbedirectory ? " -d" : "");

***************
*** 404,410 ****
                                snprintf(bp, len,
                                    "%s%s -x -o'FallBackToRsh no' -n "
                                    "-l %s %s %s %s '%s%s%s:%s'",
!                                   ssh_program, verbose_mode ? " -v" : "",

                                    suser, host, cmd, src,
                                    tuser ? tuser : "", tuser ? "@" : "",
                                    thost, targ);
--- 418,430 ----
                                snprintf(bp, len,
                                    "%s%s -x -o'FallBackToRsh no' -n "
                                    "-l %s %s %s %s '%s%s%s:%s'",
!                                   ssh_program,
!                                        /** try to handle up to three
'-v's. */
!                                        verbose_mode <=0  ? ""
!                                        : ( verbose_mode == 1 ? " -v"
!                                            : ( verbose_mode == 2 ? " -v
-v"
!                                                : " -v -v -v" )),
!
                                    suser, host, cmd, src,
                                    tuser ? tuser : "", tuser ? "@" : "",
                                    thost, targ);
***************
*** 413,419 ****
                                snprintf(bp, len,
                                    "exec %s%s -x -o'FallBackToRsh no' -n
%s "
                                    "%s %s '%s%s%s:%s'",
!                                   ssh_program, verbose_mode ? " -v" : "",

                                    host, cmd, src,
                                    tuser ? tuser : "", tuser ? "@" : "",
                                    thost, targ);
--- 433,444 ----
                                snprintf(bp, len,
                                    "exec %s%s -x -o'FallBackToRsh no' -n
%s "
                                    "%s %s '%s%s%s:%s'",
!                                   ssh_program,
!                                /** try to handle up to three '-v's. */
!                                        verbose_mode <=0  ? ""
!                                        : ( verbose_mode == 1 ? " -v"
!                                            : ( verbose_mode == 2 ? " -v
-v"
!                                                : " -v -v -v" )),
                                    host, cmd, src,
                                    tuser ? tuser : "", tuser ? "@" : "",
                                    thost, targ);
ishikawa at duron$








More information about the openssh-unix-dev mailing list