$OpenBSD: patch-cgi_cmd_c,v 1.5 2017/02/07 21:40:06 sthen Exp $
--- cgi/cmd.c.orig	Thu Dec 22 21:40:50 2016
+++ cgi/cmd.c	Tue Feb  7 21:30:12 2017
@@ -2671,7 +2671,7 @@ static int cmd_submitf(int id, const char *fmt, ...) {
 
 	command = extcmd_get_name(id);
 
-	len = snprintf(cmd, sizeof(cmd) - 1, "[%lu] %s;", time(NULL), command);
+	len = snprintf(cmd, sizeof(cmd) - 1, "[%lld] %s;", (long long)time(NULL), command);
 
 	if (len < 0 || len >= sizeof(cmd))
 		return ERROR;
@@ -2821,7 +2821,7 @@ int commit_command(int cmd) {
 			if (commands[x].host_name == NULL)
 				continue;
 			if (is_authorized[x])
-				submit_result[x] = cmd_submitf(cmd, "%s;%lu", commands[x].host_name, notification_time);
+				submit_result[x] = cmd_submitf(cmd, "%s;%lld", commands[x].host_name, (long long)notification_time);
 		}
 		break;
 
@@ -2830,7 +2830,7 @@ int commit_command(int cmd) {
 			if (commands[x].host_name == NULL)
 				continue;
 			if (is_authorized[x])
-				submit_result[x] = cmd_submitf(cmd, "%s;%s;%lu", commands[x].host_name, commands[x].description, notification_time);
+				submit_result[x] = cmd_submitf(cmd, "%s;%s;%lld", commands[x].host_name, commands[x].description, (long long)notification_time);
 		}
 		break;
 
@@ -2842,7 +2842,7 @@ int commit_command(int cmd) {
 			if (commands[x].host_name == NULL)
 				continue;
 			if (is_authorized[x])
-				submit_result[x] = cmd_submitf(cmd, "%s;%s;%lu", commands[x].host_name, commands[x].description, start_time);
+				submit_result[x] = cmd_submitf(cmd, "%s;%s;%lld", commands[x].host_name, commands[x].description, (long long)start_time);
 		}
 		break;
 
@@ -2850,7 +2850,7 @@ int commit_command(int cmd) {
 	case CMD_SHUTDOWN_PROCESS:
 	case CMD_RESTART_PROCESS:
 		if (is_authorized[x])
-			submit_result[x] = cmd_submitf(cmd, "%lu", scheduled_time);
+			submit_result[x] = cmd_submitf(cmd, "%lld", (long long)scheduled_time);
 		break;
 
 	case CMD_DISABLE_NOTIFICATIONS:
@@ -2858,10 +2858,10 @@ int commit_command(int cmd) {
 			/* we should expire the disabled notifications */
 			if(end_time > 0) {
 				cmd = CMD_DISABLE_NOTIFICATIONS_EXPIRE_TIME;
-				submit_result[x] = cmd_submitf(cmd, "%lu;%lu", scheduled_time, end_time);
+				submit_result[x] = cmd_submitf(cmd, "%lld;%lld", (long long)scheduled_time, (long long)end_time);
 				my_free(temp_buffer);
 			} else {
-				submit_result[x] = cmd_submitf(cmd, "%lu", scheduled_time);
+				submit_result[x] = cmd_submitf(cmd, "%lld", (long long)scheduled_time);
 			}
 		}
 		break;
@@ -2892,7 +2892,7 @@ int commit_command(int cmd) {
 			if (commands[x].host_name == NULL)
 				continue;
 			if (is_authorized[x])
-				submit_result[x] = cmd_submitf(cmd, "%s;%lu", commands[x].host_name, scheduled_time);
+				submit_result[x] = cmd_submitf(cmd, "%s;%lld", commands[x].host_name, (long long)scheduled_time);
 		}
 		break;
 
@@ -2941,7 +2941,7 @@ int commit_command(int cmd) {
 					} else {
 						asprintf(&temp_buffer, "%s", comment_data);
 					}
-					submit_result[x] = cmd_submitf(cmd, "%s;%d;%d;%d;%lu;%s;%s", commands[x].host_name, (sticky_ack == TRUE) ? ACKNOWLEDGEMENT_STICKY : ACKNOWLEDGEMENT_NORMAL, send_notification, persistent_comment, end_time, comment_author, temp_buffer);
+					submit_result[x] = cmd_submitf(cmd, "%s;%d;%d;%d;%llu;%s;%s", commands[x].host_name, (sticky_ack == TRUE) ? ACKNOWLEDGEMENT_STICKY : ACKNOWLEDGEMENT_NORMAL, send_notification, persistent_comment, (long long)end_time, comment_author, temp_buffer);
 					my_free(temp_buffer);
 				} else
 					submit_result[x] = cmd_submitf(cmd, "%s;%d;%d;%d;%s;%s", commands[x].host_name, (sticky_ack == TRUE) ? ACKNOWLEDGEMENT_STICKY : ACKNOWLEDGEMENT_NORMAL, send_notification, persistent_comment, comment_author, comment_data);
@@ -2957,7 +2957,7 @@ int commit_command(int cmd) {
 				if (end_time > 0) {
 					cmd = CMD_ACKNOWLEDGE_SVC_PROBLEM_EXPIRE;
 					asprintf(&temp_buffer, "%s - The acknowledgement expires at: %s.", comment_data, end_time_string);
-					submit_result[x] = cmd_submitf(cmd, "%s;%s;%d;%d;%d;%lu;%s;%s", commands[x].host_name, commands[x].description, (sticky_ack == TRUE) ? ACKNOWLEDGEMENT_STICKY : ACKNOWLEDGEMENT_NORMAL, send_notification, persistent_comment, end_time, comment_author, temp_buffer);
+					submit_result[x] = cmd_submitf(cmd, "%s;%s;%d;%d;%d;%lld;%s;%s", commands[x].host_name, commands[x].description, (sticky_ack == TRUE) ? ACKNOWLEDGEMENT_STICKY : ACKNOWLEDGEMENT_NORMAL, send_notification, persistent_comment, (long long)end_time, comment_author, temp_buffer);
 					my_free(temp_buffer);
 				} else
 					submit_result[x] = cmd_submitf(cmd, "%s;%s;%d;%d;%d;%s;%s", commands[x].host_name, commands[x].description, (sticky_ack == TRUE) ? ACKNOWLEDGEMENT_STICKY : ACKNOWLEDGEMENT_NORMAL, send_notification, persistent_comment, comment_author, comment_data);
@@ -2996,7 +2996,7 @@ int commit_command(int cmd) {
 			if (commands[x].host_name == NULL)
 				continue;
 			if (is_authorized[x])
-				submit_result[x] = cmd_submitf(cmd, "%s;%lu;%lu;%d;%lu;%lu;%s;%s", commands[x].host_name, start_time, end_time, fixed, triggered_by, duration, comment_author, comment_data);
+				submit_result[x] = cmd_submitf(cmd, "%s;%llu;%llu;%d;%lu;%lu;%s;%s", commands[x].host_name, (long long)start_time, (long long)end_time, fixed, triggered_by, duration, comment_author, comment_data);
 		}
 		break;
 
@@ -3005,7 +3005,7 @@ int commit_command(int cmd) {
 			if (commands[x].host_name == NULL)
 				continue;
 			if (is_authorized[x])
-				submit_result[x] = cmd_submitf(cmd, "%s;%lu;%lu;%d;%lu;%lu;%s;%s", commands[x].host_name, start_time, end_time, fixed, triggered_by, duration, comment_author, comment_data);
+				submit_result[x] = cmd_submitf(cmd, "%s;%lld;%lld;%d;%lu;%lu;%s;%s", commands[x].host_name, (long long)start_time, (long long)end_time, fixed, triggered_by, duration, comment_author, comment_data);
 		}
 		break;
 
@@ -3014,7 +3014,7 @@ int commit_command(int cmd) {
 			if (commands[x].host_name == NULL)
 				continue;
 			if (is_authorized[x])
-				submit_result[x] = cmd_submitf(cmd, "%s;%s;%lu;%lu;%d;%lu;%lu;%s;%s", commands[x].host_name, commands[x].description, start_time, end_time, fixed, triggered_by, duration, comment_author, comment_data);
+				submit_result[x] = cmd_submitf(cmd, "%s;%s;%lld;%lld;%d;%lu;%lu;%s;%s", commands[x].host_name, commands[x].description, (long long)start_time, (long long)end_time, fixed, triggered_by, duration, comment_author, comment_data);
 		}
 		break;
 
@@ -3025,7 +3025,7 @@ int commit_command(int cmd) {
 			if (commands[x].host_name == NULL)
 				continue;
 			if (is_authorized[x])
-				submit_result[x] = cmd_submitf(cmd, "%s;%lu", commands[x].host_name, start_time);
+				submit_result[x] = cmd_submitf(cmd, "%s;%lld", commands[x].host_name, (long long)start_time);
 		}
 		break;
 
@@ -3080,15 +3080,15 @@ int commit_command(int cmd) {
 
 	case CMD_SCHEDULE_HOSTGROUP_HOST_DOWNTIME:
 		if (is_authorized[x])
-			submit_result[x] = cmd_submitf(cmd, "%s;%lu;%lu;%d;0;%lu;%s;%s", hostgroup_name, start_time, end_time, fixed, duration, comment_author, comment_data);
+			submit_result[x] = cmd_submitf(cmd, "%s;%lld;%lld;%d;0;%lu;%s;%s", hostgroup_name, (long long)start_time, (long long)end_time, fixed, duration, comment_author, comment_data);
 		break;
 
 	case CMD_SCHEDULE_HOSTGROUP_SVC_DOWNTIME:
 		if (is_authorized[x])
-			submit_result[x] = cmd_submitf(cmd, "%s;%lu;%lu;%d;0;%lu;%s;%s", hostgroup_name, start_time, end_time, fixed, duration, comment_author, comment_data);
+			submit_result[x] = cmd_submitf(cmd, "%s;%lld;%lld;%d;0;%lu;%s;%s", hostgroup_name, (long long)start_time, (long long)end_time, fixed, duration, comment_author, comment_data);
 		if (affect_host_and_services == TRUE) {
 			if (is_authorized[x])
-				submit_result[x] |= cmd_submitf(CMD_SCHEDULE_HOSTGROUP_HOST_DOWNTIME, "%s;%lu;%lu;%d;0;%lu;%s;%s", hostgroup_name, start_time, end_time, fixed, duration, comment_author, comment_data);
+				submit_result[x] |= cmd_submitf(CMD_SCHEDULE_HOSTGROUP_HOST_DOWNTIME, "%s;%lld;%lld;%d;0;%lu;%s;%s", hostgroup_name, (long long)start_time, (long long)end_time, fixed, duration, comment_author, comment_data);
 		}
 		break;
 
@@ -3125,15 +3125,15 @@ int commit_command(int cmd) {
 
 	case CMD_SCHEDULE_SERVICEGROUP_HOST_DOWNTIME:
 		if (is_authorized[x])
-			submit_result[x] = cmd_submitf(cmd, "%s;%lu;%lu;%d;0;%lu;%s;%s", servicegroup_name, start_time, end_time, fixed, duration, comment_author, comment_data);
+			submit_result[x] = cmd_submitf(cmd, "%s;%lld;%lld;%d;0;%lu;%s;%s", servicegroup_name, (long long)start_time, (long long)end_time, fixed, duration, comment_author, comment_data);
 		break;
 
 	case CMD_SCHEDULE_SERVICEGROUP_SVC_DOWNTIME:
 		if (is_authorized[x])
-			submit_result[x] = cmd_submitf(cmd, "%s;%lu;%lu;%d;0;%lu;%s;%s", servicegroup_name, start_time, end_time, fixed, duration, comment_author, comment_data);
+			submit_result[x] = cmd_submitf(cmd, "%s;%lld;%lld;%d;0;%lu;%s;%s", servicegroup_name, (long long)start_time, (long long)end_time, fixed, duration, comment_author, comment_data);
 		if (affect_host_and_services == TRUE) {
 			if (is_authorized[x])
-				submit_result[x] |= cmd_submitf(CMD_SCHEDULE_SERVICEGROUP_HOST_DOWNTIME, "%s;%lu;%lu;%d;0;%lu;%s;%s", servicegroup_name, start_time, end_time, fixed, duration, comment_author, comment_data);
+				submit_result[x] |= cmd_submitf(CMD_SCHEDULE_SERVICEGROUP_HOST_DOWNTIME, "%s;%lld;%lld;%d;0;%lu;%s;%s", servicegroup_name, (long long)start_time, (long long)end_time, fixed, duration, comment_author, comment_data);
 		}
 		break;
 
@@ -3164,7 +3164,7 @@ int commit_command(int cmd) {
 			if (is_authorized[x]) {
 				submit_result[x] = cmd_submitf(CMD_CHANGE_NORMAL_HOST_CHECK_INTERVAL, "%s;%lf", commands[x].host_name, interval);
 				submit_result[x] = cmd_submitf(CMD_CHANGE_RETRY_HOST_CHECK_INTERVAL, "%s;%lf", commands[x].host_name, interval);
-				submit_result[x] = cmd_submitf(CMD_SCHEDULE_FORCED_HOST_CHECK, "%s;%lu", commands[x].host_name, time(NULL));
+				submit_result[x] = cmd_submitf(CMD_SCHEDULE_FORCED_HOST_CHECK, "%s;%lld", commands[x].host_name, (long long)time(NULL));
 			}
 		}
 		break;
@@ -3177,7 +3177,7 @@ int commit_command(int cmd) {
 				/* check interval, retry interval, forced rescheduled check */
 				submit_result[x] = cmd_submitf(CMD_CHANGE_NORMAL_SVC_CHECK_INTERVAL, "%s;%s;%lf", commands[x].host_name, commands[x].description, interval);
 				submit_result[x] = cmd_submitf(CMD_CHANGE_RETRY_SVC_CHECK_INTERVAL, "%s;%s;%lf", commands[x].host_name, commands[x].description, interval);
-				submit_result[x] = cmd_submitf(CMD_SCHEDULE_FORCED_SVC_CHECK, "%s;%s;%lu", commands[x].host_name, commands[x].description, time(NULL));
+				submit_result[x] = cmd_submitf(CMD_SCHEDULE_FORCED_SVC_CHECK, "%s;%s;%lld", commands[x].host_name, commands[x].description, (long long)time(NULL));
 			}
 		}
 		break;
