From 006e516739869cba59b3be6e15a2879273c53cfe Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Mon, 8 Dec 2008 17:17:50 +0100 Subject: [PATCH] Fix check when to use rsync locally. We can do this if (a) remote_host_arg is "localhost" and (b) remote_user_arg is the same as logname. The old code only looked at the logname and thus tried to use rsync locally even if a remote_host_arg was specified. --- dss.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/dss.c b/dss.c index af02f1c..f8a1e51 100644 --- a/dss.c +++ b/dss.c @@ -695,6 +695,21 @@ out: return ret; } +/* + * We can not use rsync locally if the local user is different from the remote + * user or if the src dir is not on the local host (or both). + */ +static int use_rsync_locally(char *logname) +{ + char *h = conf.remote_host_arg; + + if (strcmp(h, "localhost") && strcmp(h, "127.0.0.1")) + return 0; + if (conf.remote_user_given && strcmp(conf.remote_user_arg, logname)) + return 0; + return 1; +} + static void create_rsync_argv(char ***argv, int64_t *num) { char *logname, *newest; @@ -718,7 +733,7 @@ static void create_rsync_argv(char ***argv, int64_t *num) } else DSS_INFO_LOG("no previous snapshot found\n"); logname = dss_logname(); - if (conf.remote_user_given && !strcmp(conf.remote_user_arg, logname)) + if (use_rsync_locally(logname)) (*argv)[i++] = dss_strdup(conf.source_dir_arg); else (*argv)[i++] = make_message("%s@%s:%s/", conf.remote_user_given? -- 2.39.2