[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [xymon] Problem with file owner/group check



Henrik,
    Thanks for such a quick response! I can confirm that the patch works, but only if you test against the numeric uid's and gid's. If you try to test against the names then you get the same result I was seeing before; the MAN page for hobbit-clients.cfg says you can use either but that doesn't appear to be the case.... I'd prefer to use the user and group names if possible, just so that it makes more sense to the less experienced members of the support team!


Thank you,
Ian Marsh
 
IT Service Operations - Network Services


-----Original Message-----
From: Henrik "Størner [mailto:henrik (at) hswn.dk] 
Sent: 14 January 2011 12:06
To: xymon (at) xymon.com
Subject: Re: [xymon] Problem with file owner/group check

In <E59BC4D3B3BA7B4790CFD721B5991FD40261F5C7 (at) EXVSRVB3.it2000.hants.gov.uk> "Marsh, Ian" <ian.marsh (at) hants.gov.uk> writes:

Hi Ian,

>In the hobbit-client.cfg file we have a test like this:

>	FILE /var/somefile mode=755 owner=root groupid=root yellow

>The owner test works fine but the group test doesn't, instead it say 
>that the file should be owned by group 'd=root'. Further investigation 
>shows that the owner test also fails in the same way if we use the 
>'ownerid=root' variation of the owner test. It's almost as if the code 
>is assuming that the first 6 characters of the token is the name and 
>everything else is the value.

your analysis is spot-on. Classical cut-and-paste error, I'm afraid, and it is also present in the current 4.3.0 code. So I'm glad You spotted it!

A diff for 4.2.3 is below. For 4.3.0, I'll commit a change later today - there are some other fixes in the same area of code that I am working on (relating to the Windows client SVC checks).

Regards,
Henrik

Index: hobbitd/client_config.c
===================================================================
--- hobbitd/client_config.c	(revision 6333)
+++ hobbitd/client_config.c	(working copy)
@@ -827,10 +827,11 @@
 					}
 					else if ((strncasecmp(tok, "owner=", 6) == 0) ||
 						 (strncasecmp(tok, "ownerid=", 8) == 0)) {
-						char *eptr;
+						char *p, *eptr;
 						int uid;
-						
-						uid = strtol(tok+6, &eptr, 10);
+
+						p = strchr(tok, '=');
+						uid = strtol(p+1, &eptr, 10);
 						if (*eptr == '\0') {
 							/* All numeric */
 							currule->flags |= FCHK_OWNERID;
@@ -843,10 +844,11 @@
 					}
 					else if (strncasecmp(tok, "groupid=", 8) == 0) {
 						/* Cannot use "group" because that is reserved */
-						char *eptr;
+						char *p, *eptr;
 						int uid;
-						
-						uid = strtol(tok+6, &eptr, 10);
+
+						p = strchr(tok, '=');
+						uid = strtol(p+1, &eptr, 10);
 						if (*eptr == '\0') {
 							/* All numeric */
 							currule->flags |= FCHK_GROUPID;



To unsubscribe from the xymon list, send an e-mail to xymon-unsubscribe (at) xymon.com