summaryrefslogtreecommitdiffstats
path: root/plugins/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/utils.c')
0 files changed, 0 insertions, 0 deletions
diff --git a/plugins/netutils.c b/plugins/netutils.c
index 0044046..83f8942 100644
--- a/plugins/netutils.c
+++ b/plugins/netutils.c
@@ -167,11 +167,12 @@ np_net_connect (const char *host_name, int port, int *sd, int proto)
167 char port_str[6], host[MAX_HOST_ADDRESS_LENGTH]; 167 char port_str[6], host[MAX_HOST_ADDRESS_LENGTH];
168 size_t len; 168 size_t len;
169 int socktype, result; 169 int socktype, result;
170 short is_socket = (host_name[0] == '/');
170 171
171 socktype = (proto == IPPROTO_UDP) ? SOCK_DGRAM : SOCK_STREAM; 172 socktype = (proto == IPPROTO_UDP) ? SOCK_DGRAM : SOCK_STREAM;
172 173
173 /* as long as it doesn't start with a '/', it's assumed a host or ip */ 174 /* as long as it doesn't start with a '/', it's assumed a host or ip */
174 if(host_name[0] != '/'){ 175 if (!is_socket){
175 memset (&hints, 0, sizeof (hints)); 176 memset (&hints, 0, sizeof (hints));
176 hints.ai_family = address_family; 177 hints.ai_family = address_family;
177 hints.ai_protocol = proto; 178 hints.ai_protocol = proto;
@@ -253,7 +254,11 @@ np_net_connect (const char *host_name, int port, int *sd, int proto)
253 return econn_refuse_state; 254 return econn_refuse_state;
254 break; 255 break;
255 case STATE_CRITICAL: /* user did not set econn_refuse_state */ 256 case STATE_CRITICAL: /* user did not set econn_refuse_state */
256 printf ("%s\n", strerror(errno)); 257 if (is_socket)
258 printf("connect to file socket %s: %s\n", host_name, strerror(errno));
259 else
260 printf("connect to address %s and port %d: %s\n",
261 host_name, port, strerror(errno));
257 return econn_refuse_state; 262 return econn_refuse_state;
258 break; 263 break;
259 default: /* it's a logic error if we do not end up in STATE_(OK|WARNING|CRITICAL) */ 264 default: /* it's a logic error if we do not end up in STATE_(OK|WARNING|CRITICAL) */
@@ -262,7 +267,11 @@ np_net_connect (const char *host_name, int port, int *sd, int proto)
262 } 267 }
263 } 268 }
264 else { 269 else {
265 printf ("%s\n", strerror(errno)); 270 if (is_socket)
271 printf("connect to file socket %s: %s\n", host_name, strerror(errno));
272 else
273 printf("connect to address %s and port %d: %s\n",
274 host_name, port, strerror(errno));
266 return STATE_CRITICAL; 275 return STATE_CRITICAL;
267 } 276 }
268} 277}
diff --git a/plugins/sslutils.c b/plugins/sslutils.c
index 687bffb..d0ae474 100644
--- a/plugins/sslutils.c
+++ b/plugins/sslutils.c
@@ -153,7 +153,8 @@ int np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit){
153 struct tm stamp; 153 struct tm stamp;
154 float time_left; 154 float time_left;
155 int days_left; 155 int days_left;
156 char timestamp[17] = ""; 156 char timestamp[50] = "";
157 time_t tm_t;
157 158
158 certificate=SSL_get_peer_certificate(s); 159 certificate=SSL_get_peer_certificate(s);
159 if (!certificate) { 160 if (!certificate) {
@@ -211,10 +212,8 @@ int np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit){
211 212
212 time_left = difftime(timegm(&stamp), time(NULL)); 213 time_left = difftime(timegm(&stamp), time(NULL));
213 days_left = time_left / 86400; 214 days_left = time_left / 86400;
214 snprintf 215 tm_t = mktime (&stamp);
215 (timestamp, 17, "%02d/%02d/%04d %02d:%02d", 216 strftime(timestamp, 50, "%c", localtime(&tm_t));
216 stamp.tm_mon + 1,
217 stamp.tm_mday, stamp.tm_year + 1900, stamp.tm_hour, stamp.tm_min);
218 217
219 if (days_left > 0 && days_left <= days_till_exp_warn) { 218 if (days_left > 0 && days_left <= days_till_exp_warn) {
220 printf (_("%s - Certificate '%s' expires in %d day(s) (%s).\n"), (days_left>days_till_exp_crit)?"WARNING":"CRITICAL", cn, days_left, timestamp); 219 printf (_("%s - Certificate '%s' expires in %d day(s) (%s).\n"), (days_left>days_till_exp_crit)?"WARNING":"CRITICAL", cn, days_left, timestamp);