summaryrefslogtreecommitdiff
path: root/usr.bin/rsync/main.c
diff options
context:
space:
mode:
authorChristian Weisgerber <naddy@cvs.openbsd.org>2019-03-31 08:47:47 +0000
committerChristian Weisgerber <naddy@cvs.openbsd.org>2019-03-31 08:47:47 +0000
commit62eba8762a949ea3eb27048ce89d4eded14d72e4 (patch)
treec40ac103f781bc6f1844de3c0272b6ea85ee8843 /usr.bin/rsync/main.c
parent9115d231b1a1c4bf35f8969f4d0c61b7eff1ae55 (diff)
Add ability to combine rsync:// and -e by splitting rsync_socket()
into two functions, rsync_connect() to establish a TCP connection to the remote daemon, and rsync_socket() to run the actual protocol. E.g.: rsync -av --del -e 'ssh -W localhost:rsync -lanoncvs' \ rsync://anoncvs.spacehopper.org/OpenBSD-CVS/ /cvs ok deraadt@
Diffstat (limited to 'usr.bin/rsync/main.c')
-rw-r--r--usr.bin/rsync/main.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/usr.bin/rsync/main.c b/usr.bin/rsync/main.c
index 0ec61ee951c..9f2de25f97f 100644
--- a/usr.bin/rsync/main.c
+++ b/usr.bin/rsync/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.40 2019/03/30 23:48:24 schwarze Exp $ */
+/* $Id: main.c,v 1.41 2019/03/31 08:47:46 naddy Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -269,7 +269,7 @@ main(int argc, char *argv[])
{
struct opts opts;
pid_t child;
- int fds[2], rc, c, st, i;
+ int fds[2], sd, rc, c, st, i;
struct sess sess;
struct fargs *fargs;
char **args;
@@ -417,12 +417,15 @@ main(int argc, char *argv[])
/*
* If we're contacting an rsync:// daemon, then we don't need to
* fork, because we won't start a server ourselves.
- * Route directly into the socket code, in that case.
+ * Route directly into the socket code, unless a remote shell
+ * has explicitly been specified.
*/
- if (fargs->remote) {
+ if (fargs->remote && opts.ssh_prog == NULL) {
assert(fargs->mode == FARGS_RECEIVER);
- exit(rsync_socket(&opts, fargs));
+ if ((rc = rsync_connect(&opts, &sd, fargs)) == 0)
+ rc = rsync_socket(&opts, sd, fargs);
+ exit(rc);
}
/* Drop the dns/inet possibility. */
@@ -447,7 +450,7 @@ main(int argc, char *argv[])
memset(&sess, 0, sizeof(struct sess));
sess.opts = &opts;
- if ((args = fargs_cmdline(&sess, fargs)) == NULL) {
+ if ((args = fargs_cmdline(&sess, fargs, NULL)) == NULL) {
ERRX1(&sess, "fargs_cmdline");
_exit(1);
}
@@ -469,7 +472,10 @@ main(int argc, char *argv[])
/* NOTREACHED */
default:
close(fds[1]);
- rc = rsync_client(&opts, fds[0], fargs);
+ if (!fargs->remote)
+ rc = rsync_client(&opts, fds[0], fargs);
+ else
+ rc = rsync_socket(&opts, fds[0], fargs);
break;
}