From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <96078612210477.tru64-unix-managers.marc@archive.invalid> From: "Knut =?iso-8859-1?Q?Helleb=F8?=" Date: Tue, 20 May 1997 09:10:33 +0000 To: tru64-unix-managers Subject: Weakness in /sbin/init.d/lpd for 3.2 X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=96078612210477 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=3D`/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 =2E =2E =2E 'stop') /bin/ps -e | grep lpd | grep -Ev 'sh|grep'|sed -e 's/^ *//' -e 's/ .*//' | xargs kill >/dev/null 2>&1 # if [ "X$pid" !=3D "X" ] # then # /bin/kill $pid # fi ;; --=20 ****************************************************************** * Knut Helleb=F8 | 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@nho.hydro.com | Dale Cooper, FBI * ******************************************************************