Преглед на файлове

Make sure both -C and -K (or neither) are specified for check_nrpe

John C. Frickson преди 9 години
родител
ревизия
6a1259bdf3
променени са 1 файла, в които са добавени 9 реда и са изтрити 0 реда
  1. 9 0
      src/check_nrpe.c

+ 9 - 0
src/check_nrpe.c

@@ -158,6 +158,7 @@ int process_arguments(int argc, char **argv)
 	int argindex = 0;
 	int c = 1;
 	int i = 1;
+	int has_cert = 0, has_priv_key = 0;
 
 #ifdef HAVE_GETOPT_LONG
 	int option_index = 0;
@@ -281,10 +282,12 @@ int process_arguments(int argc, char **argv)
 
 		case 'C':
 			sslprm.cert_file = strdup(optarg);
+			has_cert = 1;
 			break;
 
 		case 'K':
 			sslprm.privatekey_file = strdup(optarg);
+			has_priv_key = 1;
 			break;
 
 		case 'S':
@@ -347,6 +350,12 @@ int process_arguments(int argc, char **argv)
 		}
 	}
 
+	if ((has_cert && !has_priv_key) || (!has_cert && has_priv_key)) {
+		syslog(LOG_ERR, "Error: the client certificate and the private key "
+						"must both be given or neither");
+		return ERROR;
+	}
+
 	/* make sure required args were supplied */
 	if (server_name == NULL && show_help == FALSE && show_version == FALSE
 		&& show_license == FALSE)