Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 26 Jan 2012 10:39:20 -0500
From:      Michael Scheidell <scheidell@freebsd.org>
To:        <perl@freebsd.org>
Cc:        ports@freebsd.org
Subject:   what is maxcmdlen? $0 len?
Message-ID:  <4F2173A8.5010803@freebsd.org>

next in thread | raw e-mail | index | archive | help
(followups set to ports@)

I am trying to track down a persistent bug in swatch.
swatch sets y $commandLineString = $0 . ' ' . join(' ', @ARGV);

, and if the len of the cmdargs is > (x?), then ps gets borked, rc 
scripts can't find it (so service status won't work), service restart 
won' t kill old one, so it just keep adding new instances.

perldoc says:

http://perldoc.perl.org/perlvar.html
"Note that there are platform-specific limitations on the maximum length 
of $0 . In the most extreme case it may be limited to the space occupied 
by the original $0 ."

(but, I searched and could not find it)

best I can tell, this number is 251. (possibly 255)

(in swatch.rc, swatch_flags -gt 222 chars), so, swatch_flags, then len 
of command (/usr/local/bin/swatch), some spacing, the '(perl)' at end...
and something else.

other than putting something like this in rc file, is there a way to 
tell, on a platform by platform basis, what this number is?

should I send patches to swatch upstream to prevent this from happening?


notes:

swatch_1_flags='-c /usr/local/etc/swatch-hackertrap.conf 
--tail-file=/var/log/eventlog_this_is_an_incredable_log_file_that_should_cause_big_problems_yes_an_op_would_never_do_this_but_it_is_so_I_can_test_if_problem_is_log_file_arg_or_log_cmd_arg_or_a_lot_of_files_or_some_thing_in_between_and_or.log  
--tail-args=-Fn0 --daemon --script-dir=/tmp/  
--pid-file=/var/run/swatch_1.pid'
swatch_enable="YES"

ps -auxww | grep swatch
root       86920  0.0  0.7  7496  6960  ??  Is    9:33AM   0:00.01 
/usr/local/bin/perl /tmp//.swatch_script.86918

  ./swatch status
      329
swatch is not running.


  ./swatch status
      223
swatch is not running.



  ./swatch status
      222
  swatch is running as pid 98668.



-- 
Michael Scheidell, CTO
o: 561-999-5000
d: 561-948-2259
 >*| *SECNAP Network Security Corporation

    * Best Mobile Solutions Product of 2011
    * Best Intrusion Prevention Product
    * Hot Company Finalist 2011
    * Best Email Security Product
    * Certified SNORT Integrator




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4F2173A8.5010803>