summaryrefslogtreecommitdiffstats
path: root/web/attachments/439112-check_pgsql.c.patch
blob: 62e2db4b5633175b1c182922ebcdf8540f018204 (plain)
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
64
*** check_pgsql.c.old	Thu Mar 22 09:58:45 2012
--- check_pgsql.c	Thu Mar 22 10:05:08 2012
***************
*** 32,37 ****
--- 32,39 ----
  const char *copyright = "1999-2007";
  const char *email = "nagiosplug-devel@lists.sourceforge.net";
  
+ #include <sys/stat.h>
+ 
  #include "common.h"
  #include "utils.h"
  
***************
*** 57,62 ****
--- 59,65 ----
  void print_help (void);
  int is_pg_dbname (char *);
  int is_pg_logname (char *);
+ int is_directory(char *);
  
  char *pghost = NULL;						/* host name of the backend server */
  char *pgport = NULL;						/* port of the backend server */
***************
*** 265,272 ****
  				twarn = strtod (optarg, NULL);
  			break;
  		case 'H':     /* host */
! 			if (!is_host (optarg))
! 				usage2 (_("Invalid hostname/address"), optarg);
  			else
  				pghost = optarg;
  			break;
--- 268,275 ----
  				twarn = strtod (optarg, NULL);
  			break;
  		case 'H':     /* host */
! 			if (!is_host (optarg) && !is_directory(optarg))
! 				usage2 (_("Invalid hostname/address/directory"), optarg);
  			else
  				pghost = optarg;
  			break;
***************
*** 411,416 ****
--- 414,432 ----
  -@@
  ******************************************************************************/
  
+ int
+ is_directory (char *pathname)
+ {
+ 	struct stat s;
+ 
+ 	if (lstat(pathname, &s) != 0)
+ 		return (FALSE);
+ 
+ 	if (S_ISDIR(s.st_mode))
+ 		return (TRUE);
+ 	else
+ 		return (FALSE);
+ }
  
  
  void