upstart vs sysV init script pid-file-name conflict

Bug #1446103 reported by Ralf Heiringhoff on 2015-04-20
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
isc-dhcp (Ubuntu)
Undecided
Unassigned

Bug Description

Hi,

the pid-file-name for upstart is hardcoded in /etc/init/isc-dhcp-server.conf to "/run/dhcp-server/dhcpd.pid" while /etc/init.d/isc-dhcp-server tries to parse "/etc/dhcp/dhcpd.conf" (and fails due to an regex error) for the setting "pid-file-name" and defaults back to "/var/run/dhcpd.pid" (which does not exist if started by upstart).

So the sysV script reports incorrectly that the isc-dhcp-server is not running and/or that it failed to stop the already running isc-dhcp-server daemon.

----------------cut--------------------------
root@d01-svi-22:/proc/1265# ps -efa | grep dhc
dhcpd 1265 1 0 Apr07 ? 00:00:30 dhcpd -user dhcpd -group dhcpd -f -q -4 -pf /run/dhcp-server/dhcpd.pid -cf /etc/dhcp/dhcpd.conf eth0
ntp 10244 1 0 Apr14 ? 00:01:01 /usr/sbin/ntpd -p /var/run/ntpd.pid -g -c /var/lib/ntp/ntp.conf.dhcp -u 105:112
root 21809 21382 0 09:16 pts/2 00:00:00 grep --color=auto dhc
root@d01-svi-22:/proc/1265# bash -x /etc/init.d/isc-dhcp-server stop
+ PATH=/sbin:/bin:/usr/sbin:/usr/bin
+ test -f /usr/sbin/dhcpd
+ DHCPD_DEFAULT=/etc/default/isc-dhcp-server
+ '[' '!' -f /etc/default/isc-dhcp-server ']'
+ . /lib/lsb/init-functions
+++ run-parts --lsbsysinit --list /lib/lsb/init-functions.d
++ for hook in '$(run-parts --lsbsysinit --list /lib/lsb/init-functions.d 2>/dev/null)'
++ '[' -r /lib/lsb/init-functions.d/20-left-info-blocks ']'
++ . /lib/lsb/init-functions.d/20-left-info-blocks
++ for hook in '$(run-parts --lsbsysinit --list /lib/lsb/init-functions.d 2>/dev/null)'
++ '[' -r /lib/lsb/init-functions.d/50-ubuntu-logging ']'
++ . /lib/lsb/init-functions.d/50-ubuntu-logging
+++ LOG_DAEMON_MSG=
++ FANCYTTY=
++ '[' -e /etc/lsb-base-logging.sh ']'
++ true
+ '[' -f /etc/default/isc-dhcp-server ']'
+ . /etc/default/isc-dhcp-server
++ INTERFACES=eth0
+ NAME=dhcpd
+ DESC='ISC DHCP server'
+ DHCPD_CONF=/etc/dhcp/dhcpd.conf
+ '[' -z '' ']'
++ sed -n -e 's/^[ \t]*pid-file-name[ \t]*"(.*)"[ \t]*;.*$/\1/p'
++ head -n 1
+ DHCPD_PID=
+ DHCPD_PID=/var/run/dhcpd.pid
+ case "$1" in
+ log_daemon_msg 'Stopping ISC DHCP server' dhcpd
+ '[' -z 'Stopping ISC DHCP server' ']'
+ log_use_fancy_output
+ TPUT=/usr/bin/tput
+ EXPR=/usr/bin/expr
+ '[' -t 1 ']'
+ '[' xxterm-256color '!=' x ']'
+ '[' xxterm-256color '!=' xdumb ']'
+ '[' -x /usr/bin/tput ']'
+ '[' -x /usr/bin/expr ']'
+ /usr/bin/tput hpa 60
+ /usr/bin/tput setaf 1
+ '[' -z ']'
+ FANCYTTY=1
+ case "$FANCYTTY" in
+ true
+ /usr/bin/tput xenl
++ /usr/bin/tput cols
+ COLS=106
+ '[' 106 ']'
+ '[' 106 -gt 6 ']'
++ /usr/bin/expr 106 - 7
+ COL=99
+ log_use_plymouth
+ '[' n = y ']'
+ plymouth --ping
+ printf ' * Stopping ISC DHCP server dhcpd '
 * Stopping ISC DHCP server dhcpd ++ /usr/bin/expr 106 - 1
+ /usr/bin/tput hpa 105
                                                                                                         + printf ' '
 + start-stop-daemon --stop --quiet --pidfile /var/run/dhcpd.pid
+ log_end_msg 1
+ '[' -z 1 ']'
+ '[' 99 ']'
+ '[' -x /usr/bin/tput ']'
+ log_use_plymouth
+ '[' n = y ']'
+ plymouth --ping
+ printf '\r'
+ /usr/bin/tput hpa 99
                                                                                                   + '[' 1 -eq 0 ']'
+ printf '['
[+ /usr/bin/tput setaf 1
+ printf fail
fail+ /usr/bin/tput op
+ echo ']'
]
+ return 1
+ rm -f /var/run/dhcpd.pid
+ exit 0
root@d01-svi-22:/proc/1265# cat /var/run/dhcpd.pid
cat: /var/run/dhcpd.pid: No such file or directory

root@d01-svi-22:~# status isc-dhcp-server
isc-dhcp-server start/running, process 1265
root@d01-svi-22:~# stop isc-dhcp-server
isc-dhcp-server stop/waiting
root@d01-svi-22:~# status isc-dhcp-server
isc-dhcp-server stop/waiting
----------------cut--------------------------

Even if you add the pid-file-name setting to your dhcpd.conf the sysV script fails to determine the correct pidfile due to a regex error as shown below:

----------------cut--------------------------
root@d01-svi-22:/etc/dhcp# /etc/init.d/isc-dhcp-server status
Status of ISC DHCP server: dhcpd is not running.

root@d01-svi-22:/etc/dhcp# sed -n -e 's/^[ \t]*pid-file-name[ \t]*"(.*)"[ \t]*;.*$/\1/p' < /etc/dhcp/dhcpd.conf
sed: -e expression #1, char 49: invalid reference \1 on `s' command's RHS

root@d01-svi-22:/etc/dhcp# grep pid-file-name /etc/dhcp/dhcpd.conf
pid-file-name "/run/dhcp-server/dhcpd.pid";

root@d01-svi-22:/etc/dhcp# sed -n -e 's/^[ \t]*pid-file-name[ \t]*"\(.*\)"[ \t]*;.*$/\1/p' < /etc/dhcp/dhcpd.conf
/run/dhcp-server/dhcpd.pid
----------------cut--------------------------

Regards,
Ralf

PS: upstart will ignore the default config path of "/etc/dhcp/dhcpd.conf" if "/etc/ltsp/dhcpd.conf" exists, but /etc/init.d/isc-dhcp-server has no support for this.

ProblemType: Bug
DistroRelease: Ubuntu 14.04
Package: isc-dhcp-server 4.2.4-7ubuntu12
ProcVersionSignature: Ubuntu 3.13.0-48.80-generic 3.13.11-ckt16
Uname: Linux 3.13.0-48-generic x86_64
ApportVersion: 2.14.1-0ubuntu3.10
Architecture: amd64
Date: Mon Apr 20 10:18:40 2015
SourcePackage: isc-dhcp
UpgradeStatus: No upgrade log present (probably fresh install)
modified.conffile..etc.dhcp.dhcpd.conf: [modified]
mtime.conffile..etc.dhcp.dhcpd.conf: 2015-04-20T09:48:33.537686
mtime.conffile..etc.init.d.isc.dhcp.server: 2015-04-20T10:03:05.513855

Ralf Heiringhoff (frosty-geek) wrote :
Ralf Heiringhoff (frosty-geek) wrote :

Here is another Patch, I choose to disable the sysV script if upstart is being used. I "borrowed" the code from "openssh-server: /etc/init.d/ssh".

The attachment "regex fix" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers