Bug Report and patch fix

kapil jain jainkkapil at gmail.com
Mon Aug 20 02:48:21 EST 2012


Hi,

I reviewed my previous patch which causes scp to exit if the file does not
exist rather than continuing the transfer if there are multiple input files.
Here is another patch which differs from previous one in functionality that
even if one file does not exist, continue with other input files and if
valid, continue to upload them rather then exiting the scp program if an
invalid file is found.


-- 
Thanks
Kapil K. Jain
http://jainkkapil.wordpress.com
-------------- next part --------------
? patch.txt
Index: scp.c
===================================================================
RCS file: /cvs/openssh/scp.c,v
retrieving revision 1.189
diff -u -r1.189 scp.c
--- scp.c	22 Sep 2011 11:38:01 -0000	1.189
+++ scp.c	19 Aug 2012 16:43:00 -0000
@@ -653,6 +653,16 @@
 			if (do_local_cmd(&alist) != 0)
 				errs = 1;
 		} else {	/* local to remote */
+			/* Before trying to establish connection, 
+			 * check whether file exists or not.
+			 * If not then continue with next file
+			 */
+			if( access(argv[i],F_OK) == -1 ){
+ 				errno = ENOENT;
+				run_err("%s: %s",argv[i],strerror(errno));
+				continue;
+			}
+
 			if (remin == -1) {
 				xasprintf(&bp, "%s -t %s%s", cmd,
 				    *targ == '-' ? "-- " : "", targ);


More information about the openssh-unix-dev mailing list