Date: Sun, 17 Jun 2001 15:00:50 -0600 From: Chris Wasser <cwasser@v-wave.com> To: arch@FreeBSD.org Subject: netbsd rc system diff Message-ID: <20010617150050.F582@skunkworks.arpa.mil>
next in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
I'm not sure how many people will agree with this, but here's a diff to
rc.subr that applies the following premise:
a) services started from init generally will be started with absolute
path. For example:
in /etc/rc.conf:
sshd_enable="YES"
sshd_program="/usr/sbin/sshd"
sshd_flags="-p 22"
A process report will show that indeed, sshd has been started with
absolute path:
# ps -ax -o 'pid,command' | grep sshd
PID COMMAND
25063 /usr/sbin/sshd -p 22
38124 grep sshd
b) some processes use setproctitle(3) to change how the process
report will show up in a report, to overcome this problem, we
sort the process report so that () and // are placed first in the
report, reducing potential false positive matches:
# ps -ax -o 'pid,command' | sort +1
4 (bufdaemon)
2 (pagedaemon)
0 (swapper)
5 (syncer)
3 (vmdaemon)
157 /sbin/dhclient dc0
1 /sbin/init --
15041 /sbin/ipmon -Ds
30809 /usr/sbin/cron
16699 /usr/sbin/inetd -wW -l -c 100 -C 10
18072 /usr/sbin/named -u bind -g bind
60441 /usr/sbin/sshd -p 2222
22947 /usr/sbin/syslogd -ss
PID COMMAND
24 adjkerntz -i
44231 ps -ax -o pid,command
17173 sshd: flatline (sshd)
34624 sshd: flatline (sshd)
34630 sshd: flatline (sshd)
44219 sshd: flatline@ttyp0 (sshd)
...etc
Attached is a diff to rc.subr which applies the aforementioned
implementation. Ofcourse this isn't a end-all-be-all solution, ideally a
specialized tool would be used to differentiate which is an actual
parent process and which are children/threads.
- Chris
[-- Attachment #2 --]
--- rc.subr Sun Jun 17 14:14:16 2001
+++ rc.subr.new Sun Jun 17 14:29:23 2001
@@ -116,12 +116,13 @@
return
fi
_procnamebn=${_procname##*/}
- ps -p $_pid -o 'pid,command' | while read _npid _arg0 _argv; do
+ ps -p $_pid -o 'pid,command' | sort +1 | while read _npid _arg0 _argv; do
if [ "$_npid" = "PID" ]; then
continue
fi
if [ "$_arg0" = "$_procname" \
-o "$_arg0" = "$_procnamebn" \
+ -o "$_arg0" = "/${_procnamebn}" \
-o "$_arg0" = "${_procnamebn}:" \
-o "$_arg0" = "(${_procnamebn})" ]; then
echo $_npid
@@ -143,12 +144,13 @@
fi
_procnamebn=${_procname##*/}
_pref=
- ps -ax -o 'pid,command' | while read _npid _arg0 _argv; do
+ ps -ax -o 'pid,command' | sort +1 | while read _npid _arg0 _argv; do
if [ "$_npid" = "PID" ]; then
continue
fi
if [ "$_arg0" = "$_procname" \
-o "$_arg0" = "$_procnamebn" \
+ -o "$_arg0" = "/${_procnamebn}" \
-o "$_arg0" = "${_procnamebn}:" \
-o "$_arg0" = "(${_procnamebn})" ]; then
echo -n "$_pref$_npid"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010617150050.F582>
