Bug#888743: pidofproc returns PIDs in foreign chroots and containers
Package: lsb-base
Version: 9.20161125
Apparently pidofproc returns the PIDs of programs running
in a chroot or in a container, if there is no local PID file.
This is a *huge* problem for me, because either the init
scripts on the host fail to restart services, or they affect
services running in a container/chroot.
Sample session:
root@mydb01a:~# . /lib/lsb/init-functions
root@mydb01a:~# pidofproc /usr/sbin/smtpd
26623
root@mydb01a:~# ps -ef | grep smtp[d]
root 1689 1541 0 Jan17 ? 00:00:00 /usr/sbin/smtpd
uml-net 1690 1689 0 Jan17 ? 00:00:00 smtpd: klondike
uml-net 1691 1689 0 Jan17 ? 00:00:00 smtpd: control
uml-net 1692 1689 0 Jan17 ? 00:00:00 smtpd: lookup
uml-net 1693 1689 0 Jan17 ? 00:00:00 smtpd: pony express
lxc-dns+ 1694 1689 0 Jan17 ? 00:00:00 smtpd: queue
uml-net 1695 1689 0 Jan17 ? 00:00:00 smtpd: scheduler
root 4193 4032 0 Jan10 ? 00:00:00 /usr/sbin/smtpd
lxc-dns+ 4194 4193 0 Jan10 ? 00:00:00 smtpd: klondike
lxc-dns+ 4195 4193 0 Jan10 ? 00:00:00 smtpd: control
lxc-dns+ 4196 4193 0 Jan10 ? 00:00:00 smtpd: lookup
lxc-dns+ 4197 4193 0 Jan10 ? 00:00:00 smtpd: pony express
zabbix 4198 4193 0 Jan10 ? 00:00:00 smtpd: queue
lxc-dns+ 4199 4193 0 Jan10 ? 00:00:00 smtpd: scheduler
root 26623 1 0 14:06 ? 00:00:00 /usr/sbin/smtpd
opensmt+ 26625 26623 0 14:06 ? 00:00:00 smtpd: klondike
opensmt+ 26626 26623 0 14:06 ? 00:00:00 smtpd: control
opensmt+ 26627 26623 0 14:06 ? 00:00:00 smtpd: lookup
opensmt+ 26628 26623 0 14:06 ? 00:00:00 smtpd: pony express
opensmt+ 26629 26623 0 14:06 ? 00:00:00 smtpd: queue
opensmt+ 26630 26623 0 14:06 ? 00:00:00 smtpd: scheduler
Please note the smtpds running in 2 LXC containers. If I kill
the local smtpd, then pidofproc finds the foreign smtpds:
root@mydb01a:~# kill 26623
root@mydb01a:~# pidofproc /usr/sbin/smtpd
4199 4198 4197 4196 4195 4194 4193 1695 1694 1693 1692 1691 1690 1689
root@mydb01a:~# echo $?
0
If pidofproc would use "pidof -c" internally, then it should work as
expected:
root@mydb01a:~# /bin/pidof -o %PPID -x /usr/sbin/smtpd
4199 4198 4197 4196 4195 4194 4193 1695 1694 1693 1692 1691 1690 1689
root@mydb01a:~# /bin/pidof -c -o %PPID -x /usr/sbin/smtpd
root@mydb01a:~# echo $?
1
lsb-base version 9.20170808 has the same problem. I would highly
appreciate a fix for stretch and sid.
Regards
Harri
Reply to: