[PATCH] scp -S support

Tommi Virtanen tv at debian.org
Sun Aug 13 04:06:45 EST 2000


	[Please Cc: me, I'm not on the list]

	fsh (http://www.lysator.liu.se/fsh/) is a program that keeps
	an ssh tunnel open and multiplexes multiple batch sessions
	through that single connection, avoiding slower public key
	crypto for things like cvs.

	fsh includes an utility called fcp that can multiplex file
	copies through this single connection. It relies on scp for
	the actual file copying, and expects to be able to pass scp a
	-S option to make scp use a fsh's own substitute for ssh.

	However, OpenSSH 2.x does not currently have -S. This simple
	patch adds it, documentation and all.

diff -u openssh-1.2.3/scp.1 openssh-1.2.3.scp/scp.1
--- openssh-1.2.3/scp.1	Thu Jan 20 14:13:36 2000
+++ openssh-1.2.3.scp/scp.1	Fri May  5 09:42:21 2000
@@ -93,6 +93,11 @@
 .Fl p
 is already reserved for preserving the times and modes of the file in
 .Xr rcp 1 .
+.It Fl S
+Name of program to use for the encrypted connection. The program must 
+understand
+.Xr ssh 1
+options.
 .It Fl 4
 Forces
 .Nm
diff -u openssh-1.2.3/scp.c openssh-1.2.3.scp/scp.c
--- openssh-1.2.3/scp.c	Fri May  5 09:43:24 2000
+++ openssh-1.2.3.scp/scp.c	Fri May  5 09:39:09 2000
@@ -103,6 +103,9 @@
 /* This is the port to use in contacting the remote site (is non-NULL). */
 char *port = NULL;
 
+/* This is the program to execute for the secured connection. ("ssh" or -S) */
+char *ssh_program = SSH_PROGRAM;
+
 /*
  * This function executes the given command as the specified user on the
  * given host.  This returns < 0 if execution fails, and >= 0 otherwise. This
@@ -148,7 +151,7 @@
 		close(pout[1]);
 
 		i = 0;
-		args[i++] = SSH_PROGRAM;
+		args[i++] = ssh_program;
 		args[i++] = "-x";
 		args[i++] = "-oFallBackToRsh no";
 		if (IPv4)
@@ -182,8 +185,8 @@
 		args[i++] = cmd;
 		args[i++] = NULL;
 
-		execvp(SSH_PROGRAM, args);
-		perror(SSH_PROGRAM);
+		execvp(ssh_program, args);
+		perror(ssh_program);
 		exit(1);
 	}
 	/* Parent.  Close the other side, and return the local side. */
@@ -247,7 +250,7 @@
 	extern int optind;
 
 	fflag = tflag = 0;
-	while ((ch = getopt(argc, argv, "dfprtvBCc:i:P:q46")) != EOF)
+	while ((ch = getopt(argc, argv, "dfprtvBCc:i:P:q46S:")) != EOF)
 		switch (ch) {
 		/* User-visible flags. */
 		case '4':
@@ -265,6 +268,9 @@
 		case 'r':
 			iamrecursive = 1;
 			break;
+		case 'S':
+			ssh_program = optarg;
+			break;
 		/* Server options. */
 		case 'd':
 			targetshouldbedirectory = 1;
@@ -388,7 +394,7 @@
 			if (*src == 0)
 				src = ".";
 			host = strchr(argv[i], '@');
-			len = strlen(SSH_PROGRAM) + strlen(argv[i]) +
+			len = strlen(ssh_program) + strlen(argv[i]) +
 				strlen(src) + (tuser ? strlen(tuser) : 0) +
 				strlen(thost) + strlen(targ) + CMDNEEDS + 32;
 			bp = xmalloc(len);
@@ -402,7 +408,7 @@
 					continue;
 				(void) sprintf(bp,
 					       "%s%s -x -o'FallBackToRsh no' -n -l %s %s %s %s '%s%s%s:%s'",
-					       SSH_PROGRAM, verbose_mode ? " -v" : "",
+					       ssh_program, verbose_mode ? " -v" : "",
 					       suser, host, cmd, src,
 					       tuser ? tuser : "", tuser ? "@" : "",
 					       thost, targ);
@@ -410,7 +416,7 @@
 				host = cleanhostname(argv[i]);
 				(void) sprintf(bp,
 					       "exec %s%s -x -o'FallBackToRsh no' -n %s %s %s '%s%s%s:%s'",
-					       SSH_PROGRAM, verbose_mode ? " -v" : "",
+					       ssh_program, verbose_mode ? " -v" : "",
 					       host, cmd, src,
 					       tuser ? tuser : "", tuser ? "@" : "",
 					       thost, targ);
@@ -931,7 +937,7 @@
 usage()
 {
 	(void) fprintf(stderr,
-		       "usage: scp [-pqrvC46] [-P port] [-c cipher] [-i identity] f1 f2; or:\n       scp [options] f1 ... fn directory\n");
+		       "usage: scp [-pqrvC46] [-S ssh] [-P port] [-c cipher] [-i identity] f1 f2; or:\n       scp [options] f1 ... fn directory\n");
 	exit(1);
 }
 

-- 
tv@{{hq.yok.utu,havoc,gaeshido}.fi,{debian,wanderer}.org,stonesoft.com}
unix, linux, debian, networks, security, | Rather than a beep
kernel, TCP/IP, C, perl, free software,  | Or a rude error message,
mail, www, sw devel, unix admin, hacks.  | These words: "File not found."





More information about the openssh-unix-dev mailing list