Merge lp:~smoser/maas/packaging.1231693-2 into lp:~maas-maintainers/maas/packaging

Proposed by Scott Moser
Status: Rejected
Rejected by: Andres Rodriguez
Proposed branch: lp:~smoser/maas/packaging.1231693-2
Merge into: lp:~maas-maintainers/maas/packaging
Diff against target: 102 lines (+56/-26)
1 file modified
debian/maas-dhcp.maas-dhcp-server.upstart (+56/-26)
To merge this branch: bzr merge lp:~smoser/maas/packaging.1231693-2
Reviewer Review Type Date Requested Status
Andres Rodriguez (community) Disapprove
Launchpad code reviewers Pending
Review via email: mp+188967@code.launchpad.net

Description of the change

One of these 2 branches can be chosen. Either
a.
https://code.launchpad.net/~smoser/maas/packaging.1231693-2/+merge/188967
or
https://code.launchpad.net/~smoser/maas/packaging.1231693/+merge/188932

I'm really OK with either. One is more complex but supports more scenarios (this one)
the other is a simpler upstart job that only supports one version of isc-dhcp (quantal-saucy version).

To post a comment you must log in.
lp:~smoser/maas/packaging.1231693-2 updated
206. By Scott Moser

un-apply increase in isc-dhcp-server depends

207. By Scott Moser

fix user-group opts

Revision history for this message
Andres Rodriguez (andreserl) :
review: Disapprove

Unmerged revisions

207. By Scott Moser

fix user-group opts

206. By Scott Moser

un-apply increase in isc-dhcp-server depends

205. By Scott Moser

support isc-dhcp-server at 4.1 or 4.2.4 behaviors

Independent of the ubuntu release, this should figure out the behavior of
dhcpd and do the right thing.

This way we can support maas dhcp with either 4.1 or 4.2.4 on precise.
If there is a need in the future for some other behavior, and also
to support that behavior from one package, we can just add another
else branch.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/maas-dhcp.maas-dhcp-server.upstart'
2--- debian/maas-dhcp.maas-dhcp-server.upstart 2013-05-21 13:17:57 +0000
3+++ debian/maas-dhcp.maas-dhcp-server.upstart 2013-10-03 01:02:29 +0000
4@@ -5,9 +5,7 @@
5 stop on runlevel [!2345]
6
7 env CONFIG_FILE=/etc/maas/dhcpd.conf
8-env PID_DIR=/run/maas/dhcp
9 env PID_FILE=/run/maas/dhcp/dhcpd.pid
10-env LEASES_DIR=/var/lib/maas/dhcp
11 env LEASES_FILE=/var/lib/maas/dhcp/dhcpd.leases
12
13 # This is where we write what interfaces dhcpd should listen on.
14@@ -37,32 +35,64 @@
15
16 respawn
17 script
18- RELEASE=`lsb_release --codename --short`
19+ dhcpd_bugmode() {
20+ # bug 1231988 and bug 1231693 have more information.
21+ # return one of 'precise', or 'quantal'
22+ # indicating if isc-dhcp behaves like it did on precise,
23+ # like on quantal (through saucy at least)
24+
25+ local dver=""
26+ # first figure out what the version is
27+ dver=$(dpkg-query --showformat '${Version}\n' \
28+ --show isc-dhcp-server 2>/dev/null) || :
29+ if [ -z "$dver" ]; then
30+ # dpkg query failed. try --version
31+ dver=$(dhcpd --version 2>&1) && dver=${dver#isc-dhcpd-} &&
32+ [ "${dver#[456]}" != "${dver}" ] || dver=""
33+ fi
34+
35+ if [ -z "$dver" ]; then
36+ echo "FAIL: could not get dhcpd version!"
37+ exit 1
38+ fi
39+
40+ # precise shipped 4.1, quantal shipped 4.2.4
41+ if dpkg --compare-versions "$dver" lt 4.2.4; then
42+ BUGMODE="precise"
43+ else
44+ BUGMODE="quantal"
45+ fi
46+ }
47+
48 INTERFACES=`cat "${INTERFACES_FILE}"`
49
50- # Allow dhcp server to write lease and pid file.
51- mkdir -p $PID_DIR
52- chown dhcpd:dhcpd $PID_DIR
53-
54- # As of Quantal, the leases file must be owned by root:root (even though
55- # the daemon will run under an unprivileged user).
56- # In Precise, ownership was supposed to be dhcpd:dhcpd.
57- mkdir -p $LEASES_DIR
58- if [ "$RELEASE" = "precise" ]; then
59- owner_group="dhcpd:dhcpd"
60- dhcpd_owner_opts=""
61+ PID_D=${PID_FILE%/*}
62+ LEASES_D=${LEASES_FILE%/*}
63+
64+ # we operate on leases~ only if it exists
65+ LEASES_TILDA="${LEASES_FILE}~"
66+ [ -e "$LEASES_TILDA" ] || LEASES_TILDA=""
67+
68+ mkdir -p $PID_D $LEASES_D
69+ chown dhcpd:dhcpd $PID_D
70+
71+ touch $LEASES_FILE
72+
73+ dhcpd_bugmode
74+ if [ "$BUGMODE" = "precise" ]; then
75+ # the daemon runs as dhcpd even without -user and -group opts
76+ chown dhcpd:dhcpd $LEASES_D $LEASES_TILDA $LEASES_FILE
77+ USER_GROUP_OPTS=""
78+ elif [ "$BUGMODE" = "quantal" ]; then
79+ # bug 1231988 is present
80+ chown root:root $LEASES_D $LEASES_TILDA $LEASES_FILE
81+ USER_GROUP_OPTS="-user dhcpd -group dhcpd"
82 else
83- owner_group="root:root"
84- dhcpd_owner_opts="-user dhcpd -group dhcpd"
85+ echo "FAIL: unknown dhcpd_bugmode '$BUGMODE'"
86+ exit 1
87 fi
88- chown $owner_group $LEASES_DIR
89- [ -e $LEASES_FILE ] || touch $LEASES_FILE
90- for LFILE in $LEASES_FILE $LEASES_FILE~; do
91- if [ -e $LFILE ]; then
92- chown $owner_group $LFILE
93- chmod a+r $LFILE
94- fi
95- done
96-
97- exec /usr/sbin/dhcpd ${dhcpd_owner_opts} -f -q -4 -pf $PID_FILE -cf $CONFIG_FILE -lf $LEASES_FILE $INTERFACES
98+
99+ exec /usr/sbin/dhcpd $USER_GROUP_OPTS -f -q -4 -pf $PID_FILE \
100+ -cf $CONFIG_FILE -lf $LEASES_FILE $INTERFACES
101+
102 end script

Subscribers

People subscribed via source and target branches