Merge lp:~shuff/ubuntu/precise/net-snmp/fix-for-701944 into lp:ubuntu/precise/net-snmp

Proposed by Steve Huff
Status: Needs review
Proposed branch: lp:~shuff/ubuntu/precise/net-snmp/fix-for-701944
Merge into: lp:ubuntu/precise/net-snmp
Diff against target: 89 lines (+33/-14)
4 files modified
debian/changelog (+9/-0)
debian/control (+1/-1)
debian/snmpd.postinst (+9/-3)
debian/snmpd.postrm (+14/-10)
To merge this branch: bzr merge lp:~shuff/ubuntu/precise/net-snmp/fix-for-701944
Reviewer Review Type Date Requested Status
Ian Hayton Pending
Review via email: mp+91678@code.launchpad.net

Description of the change

This branch fixes bug #701944.

The fundamental issue is that the postinst and postrm scripts for the snmpd package attempt to add and remove the 'snmp' user and group, and these scripts fail when that user and/or group are not defined locally on the system, but rather are provided by a directory service. My fix adds additional checks for local definition of user and group by grepping /etc/passwd and /etc/group.

I am submitting this patch against the current trunk of net-snmp; however, given that this issue affects previous distributions, I am particularly interested in seeing this fix backported to lucid (as it is a bugfix, not an enhancement). I'm not entirely sure how to make this happen, and I'd appreciate any help you can provide.

To post a comment you must log in.
59. By Steve Huff

typo fix - /etc/group instead of /etc/passwd

Unmerged revisions

59. By Steve Huff

typo fix - /etc/group instead of /etc/passwd

58. By Steve Huff

updated changelog

57. By Steve Huff

add dependency on grep to support script modifications

56. By Steve Huff

make sure snmp user/group are local before trying to modify (#710944)

the postinst and postrm scripts fail in an environment where the 'snmp' user
and group are provided via a directory service (e.g. LDAP). this patch adds a
check to make sure the user and group are local before attempting to remove or
create them.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2012-01-23 09:44:25 +0000
3+++ debian/changelog 2012-07-17 20:50:24 +0000
4@@ -1,3 +1,12 @@
5+net-snmp (5.4.3~dfsg-2.4ubuntu2) precise; urgency=low
6+
7+ * Modify snmpd.postinst and snmpd.postrm scripts
8+ - don't try to add/remove 'snmp' user and group if they are not defined
9+ locally (e.g. provided by a directory service) (LP: #701944)
10+ - add dependency on grep to support above modification
11+
12+ -- Steve Huff <shuff@vecna.org> Mon, 6 Feb 2012 11:40:00 -0500
13+
14 net-snmp (5.4.3~dfsg-2.4ubuntu1) precise; urgency=low
15
16 * Merge from Debian testing. Remaining changes:
17
18=== modified file 'debian/control'
19--- debian/control 2011-12-14 15:48:05 +0000
20+++ debian/control 2012-07-17 20:50:24 +0000
21@@ -15,7 +15,7 @@
22 Section: net
23 Priority: optional
24 Architecture: any
25-Depends: ${shlibs:Depends}, ${misc:Depends}, adduser, debconf, lsb-base (>= 3.2-13)
26+Depends: ${shlibs:Depends}, ${misc:Depends}, adduser, debconf, grep, lsb-base (>= 3.2-13)
27 Description: SNMP (Simple Network Management Protocol) agents
28 The Simple Network Management Protocol (SNMP) provides a framework
29 for the exchange of management information between agents (servers)
30
31=== modified file 'debian/snmpd.postinst'
32--- debian/snmpd.postinst 2010-06-22 14:04:48 +0000
33+++ debian/snmpd.postinst 2012-07-17 20:50:24 +0000
34@@ -7,10 +7,16 @@
35
36 if [ "x$1" = xconfigure ]; then
37 if [ ! `getent group snmp >/dev/null` ]; then
38- deluser --quiet --system snmp
39+ if [ `grep -q -c snmp /etc/group` ]; then
40+ deluser --quiet --system snmp
41+ fi
42 fi
43- adduser --quiet --system --group --no-create-home --home /var/lib/snmp snmp
44- chown -R snmp:snmp /var/lib/snmp
45+ if [ ! `getent passwd snmp >/dev/null` ]; then
46+ if [ `grep -q -c snmp /etc/passwd` ]; then
47+ adduser --quiet --system --group --no-create-home --home /var/lib/snmp snmp
48+ fi
49+ chown -R snmp:snmp /var/lib/snmp
50+ fi
51 fi
52
53 # Remove shutdown and reboot links; this init script does not need them.
54
55=== modified file 'debian/snmpd.postrm'
56--- debian/snmpd.postrm 2009-11-26 01:27:00 +0000
57+++ debian/snmpd.postrm 2012-07-17 20:50:24 +0000
58@@ -11,18 +11,22 @@
59 rm -f /var/run/snmpd.pid
60 rm -f /var/run/snmptrapd.pid
61 if getent passwd snmp >/dev/null; then
62- if [ -x /usr/sbin/deluser ]; then
63- deluser --quiet --system snmp
64- else
65- echo "Can't remove user snmp. Please remove this user by hand."
66- fi
67+ if [ `grep -q -c snmp /etc/passwd` ]; then
68+ if [ -x /usr/sbin/deluser ]; then
69+ deluser --quiet --system snmp
70+ else
71+ echo "Can't remove user snmp. Please remove this user by hand."
72+ fi
73+ fi
74 fi
75 if getent group snmp >/dev/null; then
76- if [ -x /usr/sbin/delgroup ]; then
77- delgroup --quiet --system snmp
78- else
79- echo "Can't remove group snmp. Please remove this group by hand."
80- fi
81+ if [ `grep -q -c snmp /etc/group` ]; then
82+ if [ -x /usr/sbin/delgroup ]; then
83+ delgroup --quiet --system snmp
84+ else
85+ echo "Can't remove group snmp. Please remove this group by hand."
86+ fi
87+ fi
88 fi
89 fi
90

Subscribers

People subscribed via source and target branches

to all changes: