*** 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 + #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