Uploaded image for project: 'CFEngine Community'
  1. CFEngine Community
  2. CFE-1075

processes promises fails on Solaris for long command lines



    • Type: Bug
    • Status: Done
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.6.1
    • Labels:


      From customer:
      Process matching fails on Solaris if command line is longer than 80 chars. CFEngine uses the following
      command to list currently running processes on Solaris:

      /bin/ps -eo user,pid,ppid,pgid,pcpu,pmem,vsz,pri,rss,nlwp,stime,time,args

      From man pages for ps on Solaris:

      args The command with all its arguments as a string. The
      implementation may truncate this value to the field
      width; it is implementation-dependent whether any
      further truncation occurs. It is unspecified whether
      the string represented is a version of the argument
      list as it was passed to the command when it started,
      or is a version of the arguments as they may have been
      modified by the application. Applications cannot
      depend on being able to modify their argument list and
      having that modification be reflected in the output of
      ps. The Solaris implementation limits the string to
      80 bytes; the string is the version of the argument
      list as it was passed to the command when it started.

      Consider the following tes (test.sh attached)t:

      1. ./test.sh -a this_is_a_very_long_option -b this_is_also_avery_long_option -c not_quite_there_yet -d we_should_be_over_80_chars_now &
      2. /bin/ps -eo user,pid,ppid,pgid,pcpu,pmem,vsz,pri,rss,nlwp,stime,time,args | grep test.sh
        root 687 642 687 0.0 0.5 8932 59 2364 1 13:23:41 00:00 /bin/bash ./test.sh -a this_is_a_very_long_option -b this_is_also_avery_long_op

      Now, if we create a policy to check whether or not the command is running by matching on "we_should_be_over_80_chars_now" (test.cf attached):

      Nova 2.2.3:

      1. /var/cfengine/bin/cf-agent -K -f /tmp/test.cf
        R: I have not seen a process with "i_dont_think_its_running" in its command line

      Community Core 3.5.3:

      1. /var/cfengine/bin/cf-agent -K -f /tmp/test.cf
        2014-01-07T14:34:38+0100 notice: R: I have not seen a process with "i_dont_think_its_running" in its command line

      Stopping the process and starting it with a command line less than 80 chars gives no output

      1. /tmp/test.sh -d we_should_be_over_80_chars_now &
      2. /var/cfengine/bin/cf-agent -K -f /tmp/test.cf

      The ability to match the complete command line is quite important in many cases, especially when controlling processes of Java apps.
      Solaris 8-10 are shipped with a BSD style ps with path /usr/ucb/ps. This supports the normal BSD ps flags (auxwf etc.) and doesn't truncate
      the output if w options are provided twice: /usr/ucb/ps auxww.

      Solaris 11 doesn't ship with a separate BSD style ps, but rather has support for BSD flags in the regular ps command (just like Linux).

      This has been verified on our side. Changing the binary and parameters in: https://github.com/cfengine/core/blob/3.5.3/libpromises/classes.c#L54-L78 works as expected.

      For solaris 8 9 10 check for /usr/ucb/ps if there is then use /usr/ucb/ps auxww
      For solaris 11 use /bin/ps auxww

      Longterm: It might make sense to make these configurable.


        1. cf-ps
          2 kB
        2. test.cf
          0.3 kB
        3. test.sh
          0.0 kB

          Release management

            Issue Links



                Unassigned Unassigned
                jiraadmin Old User (Inactive)
                0 Vote for this issue
                4 Start watching this issue