summaryrefslogtreecommitdiffstats
path: root/web/attachments/439112-check_pgsql.c.patch
diff options
context:
space:
mode:
Diffstat (limited to 'web/attachments/439112-check_pgsql.c.patch')
-rw-r--r--web/attachments/439112-check_pgsql.c.patch64
1 files changed, 64 insertions, 0 deletions
diff --git a/web/attachments/439112-check_pgsql.c.patch b/web/attachments/439112-check_pgsql.c.patch
new file mode 100644
index 0000000..62e2db4
--- /dev/null
+++ b/web/attachments/439112-check_pgsql.c.patch
@@ -0,0 +1,64 @@
1*** check_pgsql.c.old Thu Mar 22 09:58:45 2012
2--- check_pgsql.c Thu Mar 22 10:05:08 2012
3***************
4*** 32,37 ****
5--- 32,39 ----
6 const char *copyright = "1999-2007";
7 const char *email = "nagiosplug-devel@lists.sourceforge.net";
8
9+ #include <sys/stat.h>
10+
11 #include "common.h"
12 #include "utils.h"
13
14***************
15*** 57,62 ****
16--- 59,65 ----
17 void print_help (void);
18 int is_pg_dbname (char *);
19 int is_pg_logname (char *);
20+ int is_directory(char *);
21
22 char *pghost = NULL; /* host name of the backend server */
23 char *pgport = NULL; /* port of the backend server */
24***************
25*** 265,272 ****
26 twarn = strtod (optarg, NULL);
27 break;
28 case 'H': /* host */
29! if (!is_host (optarg))
30! usage2 (_("Invalid hostname/address"), optarg);
31 else
32 pghost = optarg;
33 break;
34--- 268,275 ----
35 twarn = strtod (optarg, NULL);
36 break;
37 case 'H': /* host */
38! if (!is_host (optarg) && !is_directory(optarg))
39! usage2 (_("Invalid hostname/address/directory"), optarg);
40 else
41 pghost = optarg;
42 break;
43***************
44*** 411,416 ****
45--- 414,432 ----
46 -@@
47 ******************************************************************************/
48
49+ int
50+ is_directory (char *pathname)
51+ {
52+ struct stat s;
53+
54+ if (lstat(pathname, &s) != 0)
55+ return (FALSE);
56+
57+ if (S_ISDIR(s.st_mode))
58+ return (TRUE);
59+ else
60+ return (FALSE);
61+ }
62
63
64 void