Patch for check_by_ssh - Add option to force pseudo tty allocation

"Skibbe, Oliver" <[email protected]>
Newsgroups gmane.network.nagios.devel
Message-ID <2E1938054F08DB4492C8049E07785223050F5C82__7549.48135368085$1417042924$gmane$org@ex1.NDS.MDKN.DE>
Hey,

because i've needed a pseudo tty for running sudo via ssh, i created a small patch for check_by_ssh

It introduces a new option "-z" which adds

     -t      Force pseudo-tty allocation.  This can be used to execute arbitrary screen-based programs on a remote machine, which can be very useful, e.g. when implementing menu services.  Multiple -t options
             force tty allocation, even if ssh has no local tty.


While using this new option, you have to set -E because on STDERR appears:
Connection to $IP closed.

Maybe there is a better way to surpress this message but i'm not this deep in C.


Let me know if you're interested.


Mit freundlichem Gruß
Oliver Skibbe

Medizinischer Dienst der Krankenversicherung Niedersachsen | MDKN
Geschäftsbereich Zentrale Dienste Informationstechnologie

Oliver Skibbe
Systemadministrator
Hildesheimer Straße 202-206
30519 Hannover
Tel: +49 (0) 511 8785 4321

[email protected]<mailto:[email protected]> | http://www.mdk-niedersachsen.de<http://www.mdk-niedersachsen.de/>
________________________________

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet.

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
check_by_ssh_force-tty.patch (application/octet-stream, 2.5 KB)
--- plugins/check_by_ssh_dev.c  2014-11-26 10:09:56.942045038 +0100
+++ plugins/check_by_ssh.c      2014-11-26 10:10:33.665762563 +0100
@@ -186,6 +186,7 @@
                {"use-ipv4", no_argument, 0, '4'},
                {"use-ipv6", no_argument, 0, '6'},
                {"ssh-option", required_argument, 0, 'o'},
+               {"force-tty", no_argument, 0, 'z'},
                {"quiet", no_argument, 0, 'q'},
                {"configfile", optional_argument, 0, 'F'},
                {0, 0, 0, 0}
@@ -199,7 +200,7 @@
                        strcpy (argv[c], "-t");

        while (1) {
-               c = getopt_long (argc, argv, "Vvh1246fqt:H:O:p:i:u:l:C:S::E::n:s:o:F:", longopts,
+               c = getopt_long (argc, argv, "Vvh1246fqzt:H:O:p:i:u:l:C:S::E::n:s:o:F:", longopts,
                                 &option);

                if (c == -1 || c == EOF)
@@ -275,6 +276,9 @@
                case '6':                                                               /* -6 for IPv6 */
                        comm_append("-6");
                        break;
+               case 'z':                                                                       /* force psudeo tty allocation */
+                       comm_append("-t");
+                       break;
                case 'f':                                                                       /* fork to background */
                        comm_append("-f");
                        break;
@@ -423,6 +427,8 @@
   printf ("    %s\n", _("short name of host in the monitoring configuration [optional]"));
   printf (" %s\n","-o, --ssh-option=OPTION");
   printf ("    %s\n", _("Call ssh with '-o OPTION' (may be used multiple times) [optional]"));
+  printf (" %s\n","-z, --force-tty");
+  printf ("    %s\n", _("Call ssh with '-t' to force pseudo tty allocation. Has to be used in conjunction with -E [optional]"));
   printf (" %s\n","-F, --configfile");
   printf ("    %s\n", _("Tell ssh to use this configfile [optional]"));
   printf (" %s\n","-q, --quiet");
@@ -461,6 +467,6 @@
        printf (" %s -H <host> -C <command> [-fqv] [-1|-2] [-4|-6]\n"
                "       [-S [lines]] [-E [lines]] [-t timeout] [-i identity]\n"
                "       [-l user] [-n name] [-s servicelist] [-O outputfile]\n"
-               "       [-p port] [-o ssh-option] [-F configfile]\n",
+               "       [-p port] [-z] [-o ssh-option] [-F configfile]\n",
                progname);
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.