summaryrefslogtreecommitdiffstats
path: root/web/attachments/280264-check_ups.diff
blob: 595353e31023e7a370ee2a352e69766e4ba6c20c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
=== plugins/check_ups.c
==================================================================
--- plugins/check_ups.c	(revision 2)
+++ plugins/check_ups.c	(revision 4)
@@ -393,13 +393,13 @@
 	/*  char command[MAX_INPUT_BUFFER]; */
 	char temp_buffer[MAX_INPUT_BUFFER];
 	char send_buffer[MAX_INPUT_BUFFER];
-	char *ptr;
+	char *ptr, *end = NULL;
 	int len;
 
 	*buf=0;
 	
 	/* create the command string to send to the UPS daemon */
-	sprintf (send_buffer, "GET VAR %s %s\n", ups_name, varname);
+	sprintf (send_buffer, "GET VAR %s %s\nLOGOUT\n", ups_name, varname);
 
 	/* send the command to the daemon and get a response back */
 	if (process_tcp_request
@@ -433,6 +433,9 @@
 	}
 
 	ptr = temp_buffer + strlen (varname) + strlen (ups_name) + 6;
+	end = strchr(ptr, '\n');
+	if (end)
+		*end = 0;
 	len = strlen(ptr);
 	if (len < 2 || ptr[0] != '"' || ptr[len-1] != '"') {
 		printf ("%s\n", _("Error: unable to parse variable"));