From a5500f71bf75b9417a4b593e7e75529635537157 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Sat, 24 Sep 2022 11:59:30 +0200 Subject: [PATCH] Allow multiple --ssh-opt in command line --ssh-opt is much more powerfull if it can be specified multiple times. So allow that. --- cmirror.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cmirror.c b/cmirror.c index 5354c07..2e404da 100644 --- a/cmirror.c +++ b/cmirror.c @@ -285,7 +285,7 @@ static int reduce; static int force_status; static int bandwidth; static int allowremotefs; -static char *ssh_opt; +static char **ssh_opts; static int cksum; static int opt_nice; static int unix_socket; @@ -1204,7 +1204,9 @@ static void master(char *master_path, char *target) { char *s = g_strdup_printf("%s:%s", unix_socket_name, unix_socket_name); g_ptr_array_add(args, s); } - if (ssh_opt) g_ptr_array_add(args, ssh_opt); + if (ssh_opts) + for (char **p = ssh_opts ; *p ; p++) + g_ptr_array_add(args, *p); g_ptr_array_add(args, slave); g_ptr_array_add(args, "/usr/bin/cmirror"); g_ptr_array_add(args, "--slave"); @@ -1457,6 +1459,7 @@ int main(int argc, char **argv) { } g_autoptr(GStrvBuilder) excepts_builder = g_strv_builder_new(); + g_autoptr(GStrvBuilder) ssh_opts_builder = g_strv_builder_new(); while (1) { int opt = getopt_long(argc, argv, "", options, NULL); if (opt == -1) @@ -1470,7 +1473,7 @@ int main(int argc, char **argv) { else if (opt == 102) g_strv_builder_add(excepts_builder, g_strdup(optarg)); else if (opt == 103) - ssh_opt = g_strdup(optarg); + g_strv_builder_add(ssh_opts_builder, g_strdup(optarg)); else if (opt == 104) unix_socket_name = g_strdup(optarg); else if (opt == '?') @@ -1479,6 +1482,7 @@ int main(int argc, char **argv) { die("internal error: getopt returned %d\n", opt); } excepts = g_strv_builder_end(excepts_builder); + ssh_opts = g_strv_builder_end(ssh_opts_builder); argv = &argv[optind]; argc -= optind;