diff options
Diffstat (limited to 'plugins/popen.c')
-rw-r--r-- | plugins/popen.c | 42 |
1 files changed, 33 insertions, 9 deletions
diff --git a/plugins/popen.c b/plugins/popen.c index 5da12a0..80a7119 100644 --- a/plugins/popen.c +++ b/plugins/popen.c | |||
@@ -1,13 +1,21 @@ | |||
1 | /****************************************************************************** | 1 | /**************************************************************************** |
2 | * popen.c | 2 | * |
3 | * Nagios plugins popen | ||
4 | * | ||
5 | * License: GPL | ||
6 | * Copyright (c) 2005 nagios-plugins team | ||
7 | * | ||
8 | * Last Modified: $Date$ | ||
9 | * | ||
10 | * Description: | ||
3 | * | 11 | * |
4 | * A safe alternative to popen | 12 | * A safe alternative to popen |
5 | * | 13 | * |
6 | * Provides spopen and spclose | 14 | * Provides spopen and spclose |
7 | 15 | * | |
8 | FILE * spopen(const char *); | 16 | * FILE * spopen(const char *); |
9 | int spclose(FILE *); | 17 | * int spclose(FILE *); |
10 | 18 | * | |
11 | * | 19 | * |
12 | * Code taken with liitle modification from "Advanced Programming for the Unix | 20 | * Code taken with liitle modification from "Advanced Programming for the Unix |
13 | * Environment" by W. Richard Stevens | 21 | * Environment" by W. Richard Stevens |
@@ -16,6 +24,22 @@ int spclose(FILE *); | |||
16 | * path passed to the exec'd program are esstially empty. (popen create a shell | 24 | * path passed to the exec'd program are esstially empty. (popen create a shell |
17 | * and passes the environment to it). | 25 | * and passes the environment to it). |
18 | * | 26 | * |
27 | * License Information: | ||
28 | * | ||
29 | * This program is free software; you can redistribute it and/or modify | ||
30 | * it under the terms of the GNU General Public License as published by | ||
31 | * the Free Software Foundation; either version 2 of the License, or | ||
32 | * (at your option) any later version. | ||
33 | * | ||
34 | * This program is distributed in the hope that it will be useful, | ||
35 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
36 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
37 | * GNU General Public License for more details. | ||
38 | * | ||
39 | * You should have received a copy of the GNU General Public License | ||
40 | * along with this program; if not, write to the Free Software | ||
41 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
42 | * | ||
19 | * $Id$ | 43 | * $Id$ |
20 | * | 44 | * |
21 | ******************************************************************************/ | 45 | ******************************************************************************/ |
@@ -121,7 +145,7 @@ spopen (const char *cmdstring) | |||
121 | argv = malloc (sizeof(char*)*argc); | 145 | argv = malloc (sizeof(char*)*argc); |
122 | 146 | ||
123 | if (argv == NULL) { | 147 | if (argv == NULL) { |
124 | printf (_("Could not malloc argv array in popen()\n")); | 148 | printf ("%s\n", _("Could not malloc argv array in popen()")); |
125 | return NULL; | 149 | return NULL; |
126 | } | 150 | } |
127 | 151 | ||
@@ -131,7 +155,7 @@ spopen (const char *cmdstring) | |||
131 | str += strspn (str, " \t\r\n"); /* trim any leading whitespace */ | 155 | str += strspn (str, " \t\r\n"); /* trim any leading whitespace */ |
132 | 156 | ||
133 | if (i >= argc - 2) { | 157 | if (i >= argc - 2) { |
134 | printf (_("CRITICAL - You need more args!!!\n")); | 158 | printf ("%s\n",_("CRITICAL - You need more args!!!")); |
135 | return (NULL); | 159 | return (NULL); |
136 | } | 160 | } |
137 | 161 | ||
@@ -278,7 +302,7 @@ popen_timeout_alarm_handler (int signo) | |||
278 | printf (_("CRITICAL - Plugin timed out after %d seconds\n"), | 302 | printf (_("CRITICAL - Plugin timed out after %d seconds\n"), |
279 | timeout_interval); | 303 | timeout_interval); |
280 | } else { | 304 | } else { |
281 | printf (_("CRITICAL - popen timeout received, but no child process\n")); | 305 | printf ("%s\n", _("CRITICAL - popen timeout received, but no child process")); |
282 | } | 306 | } |
283 | exit (STATE_CRITICAL); | 307 | exit (STATE_CRITICAL); |
284 | } | 308 | } |