Xymon Mailing List Archive search

Problem with file owner/group check

list Henrik Størner
Fri, 14 Jan 2011 12:06:03 +0000 (UTC)
Message-Id: <igpe7b$oj8$user-b57323b9108e@xymon.invalid>

In <user-336f30b07a30@xymon.invalid> "Marsh, Ian" <user-ba159ca7ed42@xymon.invalid> 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;