| Summary: | sftp does not abort when commands given via -b fail | ||
|---|---|---|---|
| Product: | Portable OpenSSH | Reporter: | Aran Cox <spin> |
| Component: | sftp | Assignee: | OpenSSH Bugzilla mailing list <openssh-bugs> |
| Status: | CLOSED FIXED | ||
| Severity: | normal | ||
| Priority: | P2 | ||
| Version: | -current | ||
| Hardware: | ix86 | ||
| OS: | Linux | ||
|
Description
Aran Cox
2002-12-06 03:14:19 AEDT
Forgot to mention that this is 3.1p1-6 RedHat RPM. This is also Debian bug #173456 (http://bugs.debian.org/173456). Robert Bihlmeyer <robbe@orcus.priv.at> added these comments and suggested the following patch: The following "-b" script should work if everything ran as documented: get the-remote-file rm the-remote-file In the status quo it can incur dataloss (and did for me, aargh!) if the get fails for some reason (e.g. disk full). The appended patch fixes the some cases, and should point people in the right direction. There are still more places where process_get will return -1 (which will not lead to abort). Either all these get changed to 1, or -- as it seems the intention is not to abort on every error -- the manpage documents exactly in which cases an abort will happen. The current situation is just bad. I'd be most satisfied with a "abort on every miniscule error" switch, akin to sh's -e. diff -u openssh-3.5p1/sftp-int.c~ openssh-3.5p1/sftp-int.c --- openssh-3.5p1/sftp-int.c~ 2002-12-30 01:13:29.000000000 +0100 +++ openssh-3.5p1/sftp-int.c 2002-12-30 01:13:29.000000000 +0100 @@ -426,7 +426,7 @@ goto out; } printf("Fetching %s to %s\n", g.gl_pathv[0], abs_dst); - err = do_download(conn, g.gl_pathv[0], abs_dst, pflag); + err = do_download(conn, g.gl_pathv[0], abs_dst, pflag) ? 1 : 0; goto out; } @@ -451,7 +451,7 @@ printf("Fetching %s to %s\n", g.gl_pathv[i], abs_dst); if (do_download(conn, g.gl_pathv[i], abs_dst, pflag) == -1) - err = -1; + err = 1; xfree(abs_dst); abs_dst = NULL; } Fixed in CVS. Any error in any command will now be considered a fatal error, unless you prefix the command with a '-' sign. E.g. put /tmp/existing -put /tmp/nonexisting put /tmp/existing2 will run to completion Mass change of RESOLVED bugs to CLOSED |