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

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;