Regards managers,
I have found a weakness in the /sbin/init.d/lpd script for 3.2. I'm
posting this because I could not find anything in the archives
addressing this problem.
The weakness is present in both 3.2C and G so I assume it is present in
the earlier releases also. I have not been able to check 4.0x as we have
no systems up and running on 4.0x yet.
The flaw manifests itself when trying to shutdown lpd remotely, ie "rsh
alphahost '/sbin/init.d/lpd stop;/sbin/init.d/lpd start'". The reason we
want to do this is that we update printer setup networkwise and thus
have to shutdown and restart lpd remotely. This sequence works sometimes
and sometimes not. I investigated a bit further and found that the pid
variable was set to the wrong value when executing /sbin/init.d/lpd stop
remotely, ie
pid=`/bin/ps -e | grep lpd | sed -e 's/^ *//' -e 's/ .*//' |
head -1`
gave the wrong answer. The reason is that the 'grep' also can catch the
'sh -c /sbin/init.d/lpd', 'sh /sbin/init.d/lpd' forks and also the grep
for lpd itself from the remotely executed script. This gives
inconsistent values for $pid.
The following is a workaround
.
.
.
'stop')
/bin/ps -e | grep lpd | grep -Ev 'sh|grep'|sed -e 's/^ *//' -e
's/ .*//' | xargs kill >/dev/null 2>&1
# if [ "X$pid" != "X" ]
# then
# /bin/kill $pid
# fi
;;
--
******************************************************************
* Knut Hellebų | DAMN GOOD COFFEE !! *
* Norsk Hydro a.s | (and hot too) *
* Phone: +47 55 996870, Fax: +47 55 996342 | *
* Cellular Phone: +47 93092402 | *
* E-mail: Knut.Hellebo_at_nho.hydro.com | Dale Cooper, FBI *
******************************************************************
Received on Tue May 20 1997 - 11:29:55 NZST