bug-cfengine
[Top][All Lists]
Advanced

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

Re: bug in killing processes of user that contain multiple digits


From: Mark Burgess
Subject: Re: bug in killing processes of user that contain multiple digits
Date: Tue, 11 Jul 2006 16:19:55 +0200
User-agent: Mozilla Thunderbird 1.0.8 (X11/20060411)

Bas van der Vlies wrote:
Hello,

 we are using cfengine 2.1.20.

We kill all the processes of user when the job has finished on our cluster. For some reasons not all processes are killed for some usernames.

example script:
#!/usr/sbin/cfagent -K -x -f
#
# This is the cfengine clean up script for cleaning up login
#

control:

  actionsequence = ( processes )

processes:
  ".*"
        signal=kill
        action=do
        filter=kill_users

filters:

{ kill_users
  Owner: "root|postfix|daemon|ganglia|jaap|willem|bas|walter|bert|ramon"
  Result: "!Owner"
}


I have patches process.c. The diff is included as patch.

Regards

------------------------------------------------------------------------

--- process.c.org       2005-02-08 12:50:02.000000000 +0100
+++ process.c   2006-07-11 12:29:30.243631590 +0200
@@ -330,46 +330,34 @@
Debug("Matched proc[%s]\n",ip->name); - one_space = false; - for (sp = ip->name; *sp != '\0'; sp++) /* if first field contains alpha, skip */
          {
          while (true)
             {
-            while (!isdigit((int)*sp) && (*sp != '\0'))
-               {
-               if (*sp == ' ')
-                  {
-                  one_space = true;
-                  }
-               sp++;
-               }
-
-            if (!one_space)
-               {
-               while(*sp != ' ' && *sp != '\t')
+            /* HvB If start with alpha then skip it till the first space */
+           if (isalnum((int)*sp))
+              {
+              while ((*sp != ' ') && (*sp != '\0'))
                   {
                   sp++;
-                  }
-               }
- - if ((sp > ip->name) && isalnum((int)*(sp-1))) /* Username contains number*/
-               {
-               sp++;
-               }
-            else
-               {
-               break;
-               }
-            }
+                 }
+              }
+
+              /* skip spaces and tabs */
+               while ((*sp == ' ') && (*sp == '\t'))
+                 {
+                 sp++;
+                 }
+             break;
+             } /* end while */
sscanf(sp,"%d",&pid); - +
          if (pid != -1)
             {
             break;
             }
- } + } /* end for */ if (pid == -1)
          {
------------------------------------------------------------------------

_______________________________________________
Bug-cfengine mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/bug-cfengine

Bas - thanks for the patch. It looks susicously simplistic. HAve you considered the case in which a PID can overap into a user name that contains a number? Can you tell me exactly what the problem was that this patch fixes? Without more info, I do not want to accept the
patch as I am suspicious of its simplicity.

M




reply via email to

[Prev in Thread] Current Thread [Next in Thread]