$OpenBSD: patch-cgi_cmd_c,v 1.4 2015/07/15 20:10:58 sthen Exp $
--- cgi/cmd.c.orig	Wed Jul 15 12:04:09 2015
+++ cgi/cmd.c	Wed Jul 15 18:35:23 2015
@@ -2702,7 +2702,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;
@@ -2852,7 +2852,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;
 
@@ -2861,7 +2861,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;
 
@@ -2873,7 +2873,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;
 
@@ -2881,7 +2881,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:
@@ -2889,10 +2889,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;
@@ -2923,7 +2923,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;
 
@@ -2966,7 +2966,7 @@ int commit_command(int cmd) {
 				if (end_time > 0) {
 					cmd = CMD_ACKNOWLEDGE_HOST_PROBLEM_EXPIRE;
 					asprintf(&temp_buffer, "%s - The acknowledgement expires at: %s.", comment_data, end_time_string);
-					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;%lld;%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);
@@ -2982,7 +2982,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);
@@ -3021,7 +3021,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;
 
@@ -3030,7 +3030,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;
 
@@ -3039,7 +3039,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;
 
@@ -3050,7 +3050,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;
 
@@ -3105,15 +3105,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;
 
@@ -3150,15 +3150,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;
 
@@ -3189,7 +3189,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;
@@ -3202,7 +3202,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;
