1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
Description: Switches priority of -M commandline option and $AUTOSSH_PORT environment variable
Bug-Debian: https://bugs.debian.org/238150
--- a/autossh.c
+++ b/autossh.c
@@ -193,7 +193,7 @@
if (code) {
fprintf(stderr, "\n");
fprintf(stderr,
- " -M specifies monitor port. May be overridden by"
+ " -M specifies monitor port. Overrides the"
" environment\n"
" variable AUTOSSH_PORT. 0 turns monitoring"
" loop off.\n"
@@ -293,14 +293,17 @@
*/
get_env_args();
- /*
+ /* if we got it from the environment */
+ if (env_port)
+ writep = env_port;
+
+ /*
* We accept all ssh args, and quietly pass them on
* to ssh when we call it.
*/
while ((ch = getopt(argc, argv, OPTION_STRING)) != -1) {
switch(ch) {
case 'M':
- if (!env_port)
writep = optarg;
break;
case 'V':
@@ -324,9 +327,6 @@
}
}
- /* if we got it from the environment */
- if (env_port)
- writep = env_port;
/*
* We must at least have a monitor port and a remote host.
@@ -417,7 +417,7 @@
continue;
}
}
- if (wp && env_port && !done_fwds) {
+ if (wp && !done_fwds) {
add_arg("-L");
add_arg(wmbuf);
if (!echop) {
@@ -425,7 +425,8 @@
add_arg(rmbuf);
}
done_fwds = 1;
- } else if (!sawargstop && argv[i][0] == '-' && argv[i][1] == 'M') {
+ }
+ if (!sawargstop && argv[i][0] == '-' && argv[i][1] == 'M') {
if (argv[i][2] == '\0')
i++;
if (wp && !done_fwds) {
|