Skip to content

Commit

Permalink
Allow multiple --ssh-opt in command line
Browse files Browse the repository at this point in the history
--ssh-opt is much more powerfull if it can be specified multiple times.

So allow that.
  • Loading branch information
donald committed Sep 24, 2022
1 parent 0b1cd9c commit a5500f7
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions cmirror.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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)
Expand All @@ -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 == '?')
Expand All @@ -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;

Expand Down

0 comments on commit a5500f7

Please sign in to comment.