summaryrefslogtreecommitdiffstats
path: root/meta-networking/recipes-protocols
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2013-04-22 08:45:45 +0000
committerMartin Jansa <Martin.Jansa@gmail.com>2013-04-26 10:00:32 +0200
commit9e7327e446d16a8bd70f93d5d68cdf267e3d2106 (patch)
treec7b80ce3e0389f561ca0ac18accd544a34d2c28f /meta-networking/recipes-protocols
parent9d68ba4fc2b2f862bfb9619f74e082c88ab68604 (diff)
downloadmeta-openembedded-9e7327e446d16a8bd70f93d5d68cdf267e3d2106.tar.gz
net-snmp: move to meta-networking and tweak
* Set SUMMARY instead of DESCRIPTION * Move SRC_URI checksums under SRC_URI * Move packaging definitions to the end Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Diffstat (limited to 'meta-networking/recipes-protocols')
-rw-r--r--meta-networking/recipes-protocols/net-snmp/files/ifmib.patch66
-rwxr-xr-xmeta-networking/recipes-protocols/net-snmp/files/init63
-rw-r--r--meta-networking/recipes-protocols/net-snmp/files/snmpd.conf422
-rw-r--r--meta-networking/recipes-protocols/net-snmp/files/snmptrapd.conf18
-rw-r--r--meta-networking/recipes-protocols/net-snmp/net-snmp/snmpd.service13
-rw-r--r--meta-networking/recipes-protocols/net-snmp/net-snmp/snmptrapd.service13
-rw-r--r--meta-networking/recipes-protocols/net-snmp/net-snmp/systemd-support.patch1616
-rw-r--r--meta-networking/recipes-protocols/net-snmp/net-snmp_5.7.2.bb118
8 files changed, 2329 insertions, 0 deletions
diff --git a/meta-networking/recipes-protocols/net-snmp/files/ifmib.patch b/meta-networking/recipes-protocols/net-snmp/files/ifmib.patch
new file mode 100644
index 000000000..859c52c3e
--- /dev/null
+++ b/meta-networking/recipes-protocols/net-snmp/files/ifmib.patch
@@ -0,0 +1,66 @@
1Signed-off-by: Jack Mitchell <jack@embed.me.uk>
2Upstream-Status: Pending
3Bug-Report: http://sourceforge.net/p/net-snmp/bugs/2449/
4
5diff --git a/agent/mibgroup/if-mib/data_access/interface_linux.c b/agent/mibgroup/if-mib/data_access/interface_linux.c
6index 3419811..d6eb91a 100644
7--- a/agent/mibgroup/if-mib/data_access/interface_linux.c
8+++ b/agent/mibgroup/if-mib/data_access/interface_linux.c
9@@ -18,7 +18,31 @@ netsnmp_feature_require(interface_ioctl_flags_set)
10
11 #ifdef HAVE_PCI_LOOKUP_NAME
12 #include <pci/pci.h>
13+#include <setjmp.h>
14 static struct pci_access *pci_access;
15+
16+/* Avoid letting libpci call exit(1) when no PCI bus is available. */
17+static int do_longjmp =0;
18+static jmp_buf err_buf;
19+static void
20+netsnmp_pci_error(char *msg, ...)
21+{
22+ va_list args;
23+ char *buf;
24+ int buflen;
25+
26+ va_start(args, msg);
27+ buflen = strlen("pcilib: ")+strlen(msg)+2;
28+ buf = malloc(buflen);
29+ snprintf(buf, buflen, "pcilib: %s\n", msg);
30+ snmp_vlog(LOG_ERR, buf, args);
31+ free(buf);
32+ va_end(args);
33+ if (do_longjmp)
34+ longjmp(err_buf, 1);
35+ else
36+ exit(1);
37+}
38 #endif
39
40 #ifdef HAVE_LINUX_ETHTOOL_H
41@@ -147,10 +171,22 @@ netsnmp_arch_interface_init(void)
42
43 #ifdef HAVE_PCI_LOOKUP_NAME
44 pci_access = pci_alloc();
45- if (pci_access)
46+ if (!pci_access) {
47+ snmp_log(LOG_ERR, "pcilib: pci_alloc failed\n");
48+ return;
49+ }
50+
51+ pci_access->error = netsnmp_pci_error;
52+
53+ do_longjmp = 1;
54+ if (setjmp(err_buf)) {
55+ pci_cleanup(pci_access);
56+ snmp_log(LOG_ERR, "pcilib: pci_init failed\n");
57+ pci_access = NULL;
58+ }
59+ else if (pci_access)
60 pci_init(pci_access);
61- else
62- snmp_log(LOG_ERR, "Unable to create pci access method\n");
63+ do_longjmp = 0;
64 #endif
65 }
66
diff --git a/meta-networking/recipes-protocols/net-snmp/files/init b/meta-networking/recipes-protocols/net-snmp/files/init
new file mode 100755
index 000000000..434b2fa3f
--- /dev/null
+++ b/meta-networking/recipes-protocols/net-snmp/files/init
@@ -0,0 +1,63 @@
1#! /bin/sh
2# /etc/init.d/snmpd: start snmp daemon.
3
4test -x /usr/sbin/snmpd || exit 0
5test -x /usr/sbin/snmptrapd || exit 0
6
7# Defaults
8export MIBDIRS=/usr/share/snmp/mibs
9SNMPDRUN=yes
10SNMPDOPTS='-Lsd -Lf /dev/null -p /var/run/snmpd.pid'
11TRAPDRUN=no
12TRAPDOPTS='-Lsd -p /var/run/snmptrapd.pid'
13
14# Cd to / before starting any daemons.
15cd /
16
17case "$1" in
18 start)
19 echo -n "Starting network management services:"
20 if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then
21 start-stop-daemon -S -x /usr/sbin/snmpd \
22 -- $SNMPDOPTS
23 echo -n " snmpd"
24 fi
25 if [ "$TRAPDRUN" = "yes" -a -f /etc/snmp/snmptrapd.conf ]; then
26 start-stop-daemon -S -x /usr/sbin/snmptrapd \
27 -- $TRAPDOPTS
28 echo -n " snmptrapd"
29 fi
30 echo "."
31 ;;
32 stop)
33 echo -n "Stopping network management services:"
34 start-stop-daemon -K -x /usr/sbin/snmpd
35 echo -n " snmpd"
36 start-stop-daemon -K -x /usr/sbin/snmptrapd
37 echo -n " snmptrapd"
38 echo "."
39 ;;
40 restart|reload|force-reload)
41 echo -n "Restarting network management services:"
42 start-stop-daemon -K -x /usr/sbin/snmpd
43 start-stop-daemon -K -x /usr/sbin/snmptrapd
44 # Allow the daemons time to exit completely.
45 sleep 2
46 if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then
47 start-stop-daemon -S -x /usr/sbin/snmpd -- $SNMPDOPTS
48 echo -n " snmpd"
49 fi
50 if [ "$TRAPDRUN" = "yes" -a -f /etc/snmp/snmptrapd.conf ]; then
51 # Allow snmpd time to start up.
52 sleep 1
53 start-stop-daemon -S -x /usr/sbin/snmptrapd -- $TRAPDOPTS
54 echo -n " snmptrapd"
55 fi
56 echo "."
57 ;;
58 *)
59 echo "Usage: /etc/init.d/snmpd {start|stop|restart|reload|force-reload}"
60 exit 1
61esac
62
63exit 0
diff --git a/meta-networking/recipes-protocols/net-snmp/files/snmpd.conf b/meta-networking/recipes-protocols/net-snmp/files/snmpd.conf
new file mode 100644
index 000000000..728171c42
--- /dev/null
+++ b/meta-networking/recipes-protocols/net-snmp/files/snmpd.conf
@@ -0,0 +1,422 @@
1###############################################################################
2#
3# EXAMPLE.conf:
4# An example configuration file for configuring the ucd-snmp snmpd agent.
5#
6###############################################################################
7#
8# This file is intended to only be an example. If, however, you want
9# to use it, it should be placed in /etc/snmp/snmpd.conf.
10# When the snmpd agent starts up, this is where it will look for it.
11#
12# You might be interested in generating your own snmpd.conf file using
13# the "snmpconf" program (perl script) instead. It's a nice menu
14# based interface to writing well commented configuration files. Try it!
15#
16# Note: This file is automatically generated from EXAMPLE.conf.def.
17# Do NOT read the EXAMPLE.conf.def file! Instead, after you have run
18# configure & make, and then make sure you read the EXAMPLE.conf file
19# instead, as it will tailor itself to your configuration.
20
21# All lines beginning with a '#' are comments and are intended for you
22# to read. All other lines are configuration commands for the agent.
23
24#
25# PLEASE: read the snmpd.conf(5) manual page as well!
26#
27
28
29###############################################################################
30# Access Control
31###############################################################################
32
33# YOU SHOULD CHANGE THE "COMMUNITY" TOKEN BELOW TO A NEW KEYWORD ONLY
34# KNOWN AT YOUR SITE. YOU *MUST* CHANGE THE NETWORK TOKEN BELOW TO
35# SOMETHING REFLECTING YOUR LOCAL NETWORK ADDRESS SPACE.
36
37# By far, the most common question I get about the agent is "why won't
38# it work?", when really it should be "how do I configure the agent to
39# allow me to access it?"
40#
41# By default, the agent responds to the "public" community for read
42# only access, if run out of the box without any configuration file in
43# place. The following examples show you other ways of configuring
44# the agent so that you can change the community names, and give
45# yourself write access as well.
46#
47# The following lines change the access permissions of the agent so
48# that the COMMUNITY string provides read-only access to your entire
49# NETWORK (EG: 10.10.10.0/24), and read/write access to only the
50# localhost (127.0.0.1, not its real ipaddress).
51#
52# For more information, read the FAQ as well as the snmpd.conf(5)
53# manual page.
54
55####
56# First, map the community name (COMMUNITY) into a security name
57# (local and mynetwork, depending on where the request is coming
58# from):
59
60# sec.name source community
61com2sec paranoid default public
62#com2sec readonly default public
63#com2sec readwrite default private
64
65####
66# Second, map the security names into group names:
67
68# sec.model sec.name
69group MyROSystem v1 paranoid
70group MyROSystem v2c paranoid
71group MyROSystem usm paranoid
72group MyROGroup v1 readonly
73group MyROGroup v2c readonly
74group MyROGroup usm readonly
75group MyRWGroup v1 readwrite
76group MyRWGroup v2c readwrite
77group MyRWGroup usm readwrite
78
79####
80# Third, create a view for us to let the groups have rights to:
81
82# incl/excl subtree mask
83view all included .1 80
84view system included .iso.org.dod.internet.mgmt.mib-2.system
85
86####
87# Finally, grant the 2 groups access to the 1 view with different
88# write permissions:
89
90# context sec.model sec.level match read write notif
91access MyROSystem "" any noauth exact system none none
92access MyROGroup "" any noauth exact all none none
93access MyRWGroup "" any noauth exact all all none
94
95# -----------------------------------------------------------------------------
96
97
98###############################################################################
99# System contact information
100#
101
102# It is also possible to set the sysContact and sysLocation system
103# variables through the snmpd.conf file. **PLEASE NOTE** that setting
104# the value of these objects here makes these objects READ-ONLY
105# (regardless of any access control settings). Any attempt to set the
106# value of an object whose value is given here will fail with an error
107# status of notWritable.
108
109syslocation Unknown (configure /etc/snmp/snmpd.local.conf)
110syscontact Root <root@localhost> (configure /etc/snmp/snmpd.local.conf)
111
112# Example output of snmpwalk:
113# % snmpwalk -v 1 -c public localhost system
114# system.sysDescr.0 = "SunOS name sun4c"
115# system.sysObjectID.0 = OID: enterprises.ucdavis.ucdSnmpAgent.sunos4
116# system.sysUpTime.0 = Timeticks: (595637548) 68 days, 22:32:55
117# system.sysContact.0 = "Me <me@somewhere.org>"
118# system.sysName.0 = "name"
119# system.sysLocation.0 = "Right here, right now."
120# system.sysServices.0 = 72
121
122
123# -----------------------------------------------------------------------------
124
125
126###############################################################################
127# Process checks.
128#
129# The following are examples of how to use the agent to check for
130# processes running on the host. The syntax looks something like:
131#
132# proc NAME [MAX=0] [MIN=0]
133#
134# NAME: the name of the process to check for. It must match
135# exactly (ie, http will not find httpd processes).
136# MAX: the maximum number allowed to be running. Defaults to 0.
137# MIN: the minimum number to be running. Defaults to 0.
138
139#
140# Examples:
141#
142
143# Make sure mountd is running
144#proc mountd
145
146# Make sure there are no more than 4 ntalkds running, but 0 is ok too.
147#proc ntalkd 4
148
149# Make sure at least one sendmail, but less than or equal to 10 are running.
150#proc sendmail 10 1
151
152# A snmpwalk of the prTable would look something like this:
153#
154# % snmpwalk -v 1 -c public localhost .1.3.6.1.4.1.2021.2
155# enterprises.ucdavis.procTable.prEntry.prIndex.1 = 1
156# enterprises.ucdavis.procTable.prEntry.prIndex.2 = 2
157# enterprises.ucdavis.procTable.prEntry.prIndex.3 = 3
158# enterprises.ucdavis.procTable.prEntry.prNames.1 = "mountd"
159# enterprises.ucdavis.procTable.prEntry.prNames.2 = "ntalkd"
160# enterprises.ucdavis.procTable.prEntry.prNames.3 = "sendmail"
161# enterprises.ucdavis.procTable.prEntry.prMin.1 = 0
162# enterprises.ucdavis.procTable.prEntry.prMin.2 = 0
163# enterprises.ucdavis.procTable.prEntry.prMin.3 = 1
164# enterprises.ucdavis.procTable.prEntry.prMax.1 = 0
165# enterprises.ucdavis.procTable.prEntry.prMax.2 = 4
166# enterprises.ucdavis.procTable.prEntry.prMax.3 = 10
167# enterprises.ucdavis.procTable.prEntry.prCount.1 = 0
168# enterprises.ucdavis.procTable.prEntry.prCount.2 = 0
169# enterprises.ucdavis.procTable.prEntry.prCount.3 = 1
170# enterprises.ucdavis.procTable.prEntry.prErrorFlag.1 = 1
171# enterprises.ucdavis.procTable.prEntry.prErrorFlag.2 = 0
172# enterprises.ucdavis.procTable.prEntry.prErrorFlag.3 = 0
173# enterprises.ucdavis.procTable.prEntry.prErrMessage.1 = "No mountd process running."
174# enterprises.ucdavis.procTable.prEntry.prErrMessage.2 = ""
175# enterprises.ucdavis.procTable.prEntry.prErrMessage.3 = ""
176# enterprises.ucdavis.procTable.prEntry.prErrFix.1 = 0
177# enterprises.ucdavis.procTable.prEntry.prErrFix.2 = 0
178# enterprises.ucdavis.procTable.prEntry.prErrFix.3 = 0
179#
180# Note that the errorFlag for mountd is set to 1 because one is not
181# running (in this case an rpc.mountd is, but thats not good enough),
182# and the ErrMessage tells you what's wrong. The configuration
183# imposed in the snmpd.conf file is also shown.
184#
185# Special Case: When the min and max numbers are both 0, it assumes
186# you want a max of infinity and a min of 1.
187#
188
189
190# -----------------------------------------------------------------------------
191
192
193###############################################################################
194# Executables/scripts
195#
196
197#
198# You can also have programs run by the agent that return a single
199# line of output and an exit code. Here are two examples.
200#
201# exec NAME PROGRAM [ARGS ...]
202#
203# NAME: A generic name.
204# PROGRAM: The program to run. Include the path!
205# ARGS: optional arguments to be passed to the program
206
207# a simple hello world
208#exec echotest /bin/echo hello world
209
210# Run a shell script containing:
211#
212# #!/bin/sh
213# echo hello world
214# echo hi there
215# exit 35
216#
217# Note: this has been specifically commented out to prevent
218# accidental security holes due to someone else on your system writing
219# a /tmp/shtest before you do. Uncomment to use it.
220#
221#exec shelltest /bin/sh /tmp/shtest
222
223# Then,
224# % snmpwalk -v 1 -c public localhost .1.3.6.1.4.1.2021.8
225# enterprises.ucdavis.extTable.extEntry.extIndex.1 = 1
226# enterprises.ucdavis.extTable.extEntry.extIndex.2 = 2
227# enterprises.ucdavis.extTable.extEntry.extNames.1 = "echotest"
228# enterprises.ucdavis.extTable.extEntry.extNames.2 = "shelltest"
229# enterprises.ucdavis.extTable.extEntry.extCommand.1 = "/bin/echo hello world"
230# enterprises.ucdavis.extTable.extEntry.extCommand.2 = "/bin/sh /tmp/shtest"
231# enterprises.ucdavis.extTable.extEntry.extResult.1 = 0
232# enterprises.ucdavis.extTable.extEntry.extResult.2 = 35
233# enterprises.ucdavis.extTable.extEntry.extOutput.1 = "hello world."
234# enterprises.ucdavis.extTable.extEntry.extOutput.2 = "hello world."
235# enterprises.ucdavis.extTable.extEntry.extErrFix.1 = 0
236# enterprises.ucdavis.extTable.extEntry.extErrFix.2 = 0
237
238# Note that the second line of the /tmp/shtest shell script is cut
239# off. Also note that the exit status of 35 was returned.
240
241# -----------------------------------------------------------------------------
242
243
244###############################################################################
245# disk checks
246#
247
248# The agent can check the amount of available disk space, and make
249# sure it is above a set limit.
250
251# disk PATH [MIN=DEFDISKMINIMUMSPACE]
252#
253# PATH: mount path to the disk in question.
254# MIN: Disks with space below this value will have the Mib's errorFlag set.
255# Default value = DEFDISKMINIMUMSPACE.
256
257# Check the / partition and make sure it contains at least 10 megs.
258
259#disk / 10000
260
261# % snmpwalk -v 1 -c public localhost .1.3.6.1.4.1.2021.9
262# enterprises.ucdavis.diskTable.dskEntry.diskIndex.1 = 0
263# enterprises.ucdavis.diskTable.dskEntry.diskPath.1 = "/" Hex: 2F
264# enterprises.ucdavis.diskTable.dskEntry.diskDevice.1 = "/dev/dsk/c201d6s0"
265# enterprises.ucdavis.diskTable.dskEntry.diskMinimum.1 = 10000
266# enterprises.ucdavis.diskTable.dskEntry.diskTotal.1 = 837130
267# enterprises.ucdavis.diskTable.dskEntry.diskAvail.1 = 316325
268# enterprises.ucdavis.diskTable.dskEntry.diskUsed.1 = 437092
269# enterprises.ucdavis.diskTable.dskEntry.diskPercent.1 = 58
270# enterprises.ucdavis.diskTable.dskEntry.diskErrorFlag.1 = 0
271# enterprises.ucdavis.diskTable.dskEntry.diskErrorMsg.1 = ""
272
273# -----------------------------------------------------------------------------
274
275
276###############################################################################
277# load average checks
278#
279
280# load [1MAX=DEFMAXLOADAVE] [5MAX=DEFMAXLOADAVE] [15MAX=DEFMAXLOADAVE]
281#
282# 1MAX: If the 1 minute load average is above this limit at query
283# time, the errorFlag will be set.
284# 5MAX: Similar, but for 5 min average.
285# 15MAX: Similar, but for 15 min average.
286
287# Check for loads:
288#load 12 14 14
289
290# % snmpwalk -v 1 -c public localhost .1.3.6.1.4.1.2021.10
291# enterprises.ucdavis.loadTable.laEntry.loadaveIndex.1 = 1
292# enterprises.ucdavis.loadTable.laEntry.loadaveIndex.2 = 2
293# enterprises.ucdavis.loadTable.laEntry.loadaveIndex.3 = 3
294# enterprises.ucdavis.loadTable.laEntry.loadaveNames.1 = "Load-1"
295# enterprises.ucdavis.loadTable.laEntry.loadaveNames.2 = "Load-5"
296# enterprises.ucdavis.loadTable.laEntry.loadaveNames.3 = "Load-15"
297# enterprises.ucdavis.loadTable.laEntry.loadaveLoad.1 = "0.49" Hex: 30 2E 34 39
298# enterprises.ucdavis.loadTable.laEntry.loadaveLoad.2 = "0.31" Hex: 30 2E 33 31
299# enterprises.ucdavis.loadTable.laEntry.loadaveLoad.3 = "0.26" Hex: 30 2E 32 36
300# enterprises.ucdavis.loadTable.laEntry.loadaveConfig.1 = "12.00"
301# enterprises.ucdavis.loadTable.laEntry.loadaveConfig.2 = "14.00"
302# enterprises.ucdavis.loadTable.laEntry.loadaveConfig.3 = "14.00"
303# enterprises.ucdavis.loadTable.laEntry.loadaveErrorFlag.1 = 0
304# enterprises.ucdavis.loadTable.laEntry.loadaveErrorFlag.2 = 0
305# enterprises.ucdavis.loadTable.laEntry.loadaveErrorFlag.3 = 0
306# enterprises.ucdavis.loadTable.laEntry.loadaveErrMessage.1 = ""
307# enterprises.ucdavis.loadTable.laEntry.loadaveErrMessage.2 = ""
308# enterprises.ucdavis.loadTable.laEntry.loadaveErrMessage.3 = ""
309
310# -----------------------------------------------------------------------------
311
312
313###############################################################################
314# Extensible sections.
315#
316
317# This alleviates the multiple line output problem found in the
318# previous executable mib by placing each mib in its own mib table:
319
320# Run a shell script containing:
321#
322# #!/bin/sh
323# echo hello world
324# echo hi there
325# exit 35
326#
327# Note: this has been specifically commented out to prevent
328# accidental security holes due to someone else on your system writing
329# a /tmp/shtest before you do. Uncomment to use it.
330#
331# exec .1.3.6.1.4.1.2021.50 shelltest /bin/sh /tmp/shtest
332
333# % snmpwalk -v 1 -c public localhost .1.3.6.1.4.1.2021.50
334# enterprises.ucdavis.50.1.1 = 1
335# enterprises.ucdavis.50.2.1 = "shelltest"
336# enterprises.ucdavis.50.3.1 = "/bin/sh /tmp/shtest"
337# enterprises.ucdavis.50.100.1 = 35
338# enterprises.ucdavis.50.101.1 = "hello world."
339# enterprises.ucdavis.50.101.2 = "hi there."
340# enterprises.ucdavis.50.102.1 = 0
341
342# Now the Output has grown to two lines, and we can see the 'hi
343# there.' output as the second line from our shell script.
344#
345# Note that you must alter the mib.txt file to be correct if you want
346# the .50.* outputs above to change to reasonable text descriptions.
347
348# Other ideas:
349#
350# exec .1.3.6.1.4.1.2021.51 ps /bin/ps
351# exec .1.3.6.1.4.1.2021.52 top /usr/local/bin/top
352# exec .1.3.6.1.4.1.2021.53 mailq /usr/bin/mailq
353
354# -----------------------------------------------------------------------------
355
356
357###############################################################################
358# Pass through control.
359#
360
361# Usage:
362# pass MIBOID EXEC-COMMAND
363#
364# This will pass total control of the mib underneath the MIBOID
365# portion of the mib to the EXEC-COMMAND.
366#
367# Note: You'll have to change the path of the passtest script to your
368# source directory or install it in the given location.
369#
370# Example: (see the script for details)
371# (commented out here since it requires that you place the
372# script in the right location. (its not installed by default))
373
374# pass .1.3.6.1.4.1.2021.255 /bin/sh /usr/local/passtest
375
376# % snmpwalk -v 1 -c public localhost .1.3.6.1.4.1.2021.255
377# enterprises.ucdavis.255.1 = "life the universe and everything"
378# enterprises.ucdavis.255.2.1 = 42
379# enterprises.ucdavis.255.2.2 = OID: 42.42.42
380# enterprises.ucdavis.255.3 = Timeticks: (363136200) 42 days, 0:42:42
381# enterprises.ucdavis.255.4 = IpAddress: 127.0.0.1
382# enterprises.ucdavis.255.5 = 42
383# enterprises.ucdavis.255.6 = Gauge: 42
384#
385# % snmpget -v 1 -c public localhost .1.3.6.1.4.1.2021.255.5
386# enterprises.ucdavis.255.5 = 42
387#
388# % snmpset -v 1 -c public localhost .1.3.6.1.4.1.2021.255.1 s "New string"
389# enterprises.ucdavis.255.1 = "New string"
390#
391
392# For specific usage information, see the man/snmpd.conf.5 manual page
393# as well as the local/passtest script used in the above example.
394
395###############################################################################
396# Subagent control
397#
398
399# The agent can support subagents using a number of extension mechanisms.
400# From the 4.2.1 release, AgentX support is being compiled in by default.
401# However, this is still experimental code, so should not be used on
402# critical production systems.
403# Please see the file README.agentx for more details.
404#
405# If having read, marked, learnt and inwardly digested this information,
406# you decide that you do wish to make use of this mechanism, simply
407# uncomment the following directive.
408#
409# master agentx
410#
411# I repeat - this is *NOT* regarded as suitable for front-line production
412# systems, though it is probably stable enough for day-to-day use.
413# Probably.
414#
415# No refunds will be given.
416
417###############################################################################
418# Further Information
419#
420# See the snmpd.conf manual page, and the output of "snmpd -H".
421# MUCH more can be done with the snmpd.conf than is shown as an
422# example here.
diff --git a/meta-networking/recipes-protocols/net-snmp/files/snmptrapd.conf b/meta-networking/recipes-protocols/net-snmp/files/snmptrapd.conf
new file mode 100644
index 000000000..8d2e4375e
--- /dev/null
+++ b/meta-networking/recipes-protocols/net-snmp/files/snmptrapd.conf
@@ -0,0 +1,18 @@
1###############################################################################
2#
3# EXAMPLE.conf:
4# An example configuration file for configuring the ucd-snmp snmptrapd agent.
5#
6###############################################################################
7#
8# This file is intended to only be an example. If, however, you want
9# to use it, it should be placed in /etc/snmp/snmptrapd.conf.
10# When the snmptrapd agent starts up, this is where it will look for it.
11#
12# All lines beginning with a '#' are comments and are intended for you
13# to read. All other lines are configuration commands for the agent.
14
15#
16# PLEASE: read the snmptrapd.conf(5) manual page as well!
17#
18
diff --git a/meta-networking/recipes-protocols/net-snmp/net-snmp/snmpd.service b/meta-networking/recipes-protocols/net-snmp/net-snmp/snmpd.service
new file mode 100644
index 000000000..10a1eb212
--- /dev/null
+++ b/meta-networking/recipes-protocols/net-snmp/net-snmp/snmpd.service
@@ -0,0 +1,13 @@
1[Unit]
2Description=Simple Network Management Protocol (SNMP) Daemon.
3After=syslog.target network.target
4
5[Service]
6Type=notify
7Environment=OPTIONS="-LS0-6d"
8EnvironmentFile=-/etc/default/snmpd
9ExecStart=/usr/sbin/snmpd $OPTIONS -f
10ExecReload=/bin/kill -HUP $MAINPID
11
12[Install]
13WantedBy=multi-user.target
diff --git a/meta-networking/recipes-protocols/net-snmp/net-snmp/snmptrapd.service b/meta-networking/recipes-protocols/net-snmp/net-snmp/snmptrapd.service
new file mode 100644
index 000000000..951f9f270
--- /dev/null
+++ b/meta-networking/recipes-protocols/net-snmp/net-snmp/snmptrapd.service
@@ -0,0 +1,13 @@
1[Unit]
2Description=Simple Network Management Protocol (SNMP) Trap Daemon.
3After=syslog.target network.target
4
5[Service]
6Type=notify
7Environment=OPTIONS="-Lsd"
8EnvironmentFile=-/etc/default/snmptrapd
9ExecStart=/usr/sbin/snmptrapd $OPTIONS -f
10ExecReload=/bin/kill -HUP $MAINPID
11
12[Install]
13WantedBy=multi-user.target
diff --git a/meta-networking/recipes-protocols/net-snmp/net-snmp/systemd-support.patch b/meta-networking/recipes-protocols/net-snmp/net-snmp/systemd-support.patch
new file mode 100644
index 000000000..18955f29e
--- /dev/null
+++ b/meta-networking/recipes-protocols/net-snmp/net-snmp/systemd-support.patch
@@ -0,0 +1,1616 @@
1Systemd support backported from the master branch as of 23/04/2012 (post 5.7.1, pre 5.8).
2
3The following commits have been cherry-picked:
4
519499c3c90bf9d7b2b9e5d08baa26cc6bba28a11
6fef6cddfdb94da1a6b1fb768af62918b80f11fd3
70641e43c694c485cbbffef0556efc4641bd3ff50
876530a89f1c8bbd0b63acce63e10d5d4812a1a16 (conflict resolved)
9bf108d7f1354f6276fc43c129963f2c49b9fc242
1074412748067c685e1d8ab6ed3bcc3ca9c2774844
1186132e3f1e6ef7b4e0b96d8fa24e37c81b71b0e0
1263557cf8986a33dba1d4429b583a901361052c4f
13
14Upstream-Status: Backport
15
16diff --git a/README.systemd b/README.systemd
17new file mode 100644
18index 0000000..f731851
19--- /dev/null
20+++ b/README.systemd
21@@ -0,0 +1,41 @@
22+README.systemd
23+--------------
24+Net-SNMP provides two daemons, which support systemd system manager.
25+See http://www.freedesktop.org/wiki/Software/systemd to learn how
26+systemd works. Both socket activation and notification is supported by these
27+daemons.
28+
29+To enable systemd support, the sources must be compiled with
30+--with-systemd configure option.
31+
32+snmpd - The SNMP agent
33+----------------------
34+Socket activation od snmpd daemon is implemented, but it's discouraged.
35+The reason is simple - snmpd not only listens and processes SNMP requests
36+from network, but also gathers system statistics counters, sends traps and
37+communicates with subagents. It even opens few netlink sockets.
38+
39+In other words, snmpd should run from system start to properly work.
40+This can be done in two ways:
41+1) either as snmpd service unit with 'Type=notification' and without a socket
42+ unit
43+2) or as snmpd service unit with 'Type=simple', appropriate socket socket unit
44+ and the snmpd service enabled. This way systemd creates the snmpd listening
45+ socket early during boot and passes the sockets to snmpd slightly later
46+ (but still during machine boot). This way systemd can paralelize start of
47+ services, which depend on snmpd. Admins must adjust the socket file manually,
48+ depending if the snmpd support AgentX, IPv6, SMUX etc.
49+
50+snmpd should be started with '-f' command line parameter to disable forking -
51+systemd does that for us automatically.
52+
53+
54+snmptrapd - The trap processing daemon
55+--------------------------------------
56+snmptrapd supports full socket activation and also notification (if needed).
57+Both 'Type=simple' (with appropriate socket unit) and 'Type=notify' services
58+will work. Again, '-f' parameter should be provided on snmptrapd command line.
59+
60+If integration with SNMP agent using AgentX protocol is enabled, snmptrapd should
61+start during boot and not after first SNMP trap arrives. Same rules as for snmpd
62+applies then.
63\ No newline at end of file
64diff --git a/agent/snmpd.c b/agent/snmpd.c
65index b177d5b..08bdfc7 100644
66--- a/agent/snmpd.c
67+++ b/agent/snmpd.c
68@@ -164,6 +164,10 @@ typedef long fd_mask;
69
70 #endif
71
72+#ifndef NETSNMP_NO_SYSTEMD
73+#include <net-snmp/library/sd-daemon.h>
74+#endif
75+
76 netsnmp_feature_want(logging_file)
77 netsnmp_feature_want(logging_stdio)
78 netsnmp_feature_want(logging_syslog)
79@@ -441,18 +445,28 @@ main(int argc, char *argv[])
80 int agent_mode = -1;
81 char *pid_file = NULL;
82 char option_compatability[] = "-Le";
83+#ifndef WIN32
84+ int prepared_sockets = 0;
85+#endif
86 #if HAVE_GETPID
87 int fd;
88 FILE *PID;
89 #endif
90
91 #ifndef WIN32
92+#ifndef NETSNMP_NO_SYSYSTEMD
93+ /* check if systemd has sockets for us and don't close them */
94+ prepared_sockets = netsnmp_sd_listen_fds(0);
95+#endif /* NETSNMP_NO_SYSYSTEMD */
96+
97 /*
98 * close all non-standard file descriptors we may have
99 * inherited from the shell.
100 */
101- for (i = getdtablesize() - 1; i > 2; --i) {
102- (void) close(i);
103+ if (!prepared_sockets) {
104+ for (i = getdtablesize() - 1; i > 2; --i) {
105+ (void) close(i);
106+ }
107 }
108 #endif /* #WIN32 */
109
110@@ -1100,6 +1114,19 @@ main(int argc, char *argv[])
111 netsnmp_addrcache_initialise();
112
113 /*
114+ * Let systemd know we're up.
115+ */
116+#ifndef NETSNMP_NO_SYSTEMD
117+ netsnmp_sd_notify(1, "READY=1\n");
118+ if (prepared_sockets)
119+ /*
120+ * Clear the environment variable, we already processed all the sockets
121+ * by now.
122+ */
123+ netsnmp_sd_listen_fds(1);
124+#endif
125+
126+ /*
127 * Forever monitor the dest_port for incoming PDUs.
128 */
129 DEBUGMSGTL(("snmpd/main", "We're up. Starting to process data.\n"));
130diff --git a/apps/snmptrapd.c b/apps/snmptrapd.c
131index 1a52080..0857ae1 100644
132--- a/apps/snmptrapd.c
133+++ b/apps/snmptrapd.c
134@@ -125,6 +125,10 @@ SOFTWARE.
135
136 #include <net-snmp/net-snmp-features.h>
137
138+#ifndef NETSNMP_NO_SYSTEMD
139+#include <net-snmp/library/sd-daemon.h>
140+#endif
141+
142 #ifndef BSD4_3
143 #define BSD4_2
144 #endif
145@@ -655,15 +659,24 @@ main(int argc, char *argv[])
146 int agentx_subagent = 1;
147 #endif
148 netsnmp_trapd_handler *traph;
149+#ifndef WIN32
150+ int prepared_sockets = 0;
151+#endif
152
153
154 #ifndef WIN32
155+#ifndef NETSNMP_NO_SYSTEMD
156+ /* check if systemd has sockets for us and don't close them */
157+ prepared_sockets = netsnmp_sd_listen_fds(0);
158+#endif
159 /*
160 * close all non-standard file descriptors we may have
161 * inherited from the shell.
162 */
163- for (i = getdtablesize() - 1; i > 2; --i) {
164- (void) close(i);
165+ if (!prepared_sockets) {
166+ for (i = getdtablesize() - 1; i > 2; --i) {
167+ (void) close(i);
168+ }
169 }
170 #endif /* #WIN32 */
171
172@@ -1311,6 +1324,19 @@ main(int argc, char *argv[])
173 #endif
174 #endif
175
176+ /*
177+ * Let systemd know we're up.
178+ */
179+#ifndef NETSNMP_NO_SYSTEMD
180+ netsnmp_sd_notify(1, "READY=1\n");
181+ if (prepared_sockets)
182+ /*
183+ * Clear the environment variable, we already processed all the sockets
184+ * by now.
185+ */
186+ netsnmp_sd_listen_fds(1);
187+#endif
188+
189 #ifdef WIN32SERVICE
190 trapd_status = SNMPTRAPD_RUNNING;
191 #endif
192diff --git a/configure.d/config_modules_lib b/configure.d/config_modules_lib
193index b6609c1..5849072 100644
194--- a/configure.d/config_modules_lib
195+++ b/configure.d/config_modules_lib
196@@ -53,6 +53,14 @@ if test "x$PARTIALTARGETOS" = "xmingw32" -o "x$PARTIALTARGETOS" = "xmingw32msvc"
197 other_ftobjs_list="$other_ftobjs_list winpipe.ft"
198 fi
199
200+# Linux systemd
201+if test "x$with_systemd" == "xyes"; then
202+ other_src_list="$other_src_list sd-daemon.c"
203+ other_objs_list="$other_objs_list sd-daemon.o"
204+ other_lobjs_list="$other_lobjs_list sd-daemon.lo"
205+ other_ftobjs_list="$other_ftobjs_list sd-daemon.ft"
206+fi
207+
208 AC_SUBST(other_src_list)
209 AC_SUBST(other_objs_list)
210 AC_SUBST(other_lobjs_list)
211diff --git a/configure.d/config_project_with_enable b/configure.d/config_project_with_enable
212index 8b46ad2..59d6d5c 100644
213--- a/configure.d/config_project_with_enable
214+++ b/configure.d/config_project_with_enable
215@@ -689,6 +689,15 @@ if test "x$with_dummy_values" != "xyes"; then
216 data for])
217 fi
218
219+NETSNMP_ARG_WITH(systemd,
220+[ --with-systemd Provide systemd support. See README.systemd
221+ for details.])
222+# Define unless specifically suppressed (i.e., option defaults to false).
223+if test "x$with_systemd" != "xyes"; then
224+ AC_DEFINE(NETSNMP_NO_SYSTEMD, 1,
225+ [If you don't want to integrate with systemd.])
226+fi
227+
228 NETSNMP_ARG_ENABLE(set-support,
229 [ --disable-set-support Do not allow SNMP set requests.])
230 if test "x$enable_set_support" = "xno"; then
231diff --git a/dist/snmpd.service b/dist/snmpd.service
232new file mode 100644
233index 0000000..31391e5
234--- /dev/null
235+++ b/dist/snmpd.service
236@@ -0,0 +1,18 @@
237+#
238+# SNMP agent service file for systemd
239+#
240+#
241+# The service should be enabled, i.e. snmpd should start during machine boot.
242+# Socket activation shall not be used. See README.systemd for details.
243+
244+[Unit]
245+Description=Simple Network Management Protocol (SNMP) daemon.
246+After=syslog.target network.target
247+
248+[Service]
249+# Type=notify is also supported. It should be set when snmpd.socket is not used.
250+Type=simple
251+ExecStart=/usr/sbin/snmpd -f
252+
253+[Install]
254+WantedBy=multi-user.target
255diff --git a/dist/snmpd.socket b/dist/snmpd.socket
256new file mode 100644
257index 0000000..7f3a2d9
258--- /dev/null
259+++ b/dist/snmpd.socket
260@@ -0,0 +1,17 @@
261+[Unit]
262+Description=Socket listening for SNMP and AgentX messages
263+
264+[Socket]
265+ListenDatagram=0.0.0.0:161
266+# Uncomment other listening addresses as needed - TCP, UDP6, TCP6.
267+# It must match listening addresses/ports defined in snmpd.service
268+# or snmpd.conf.
269+# ListenStream=0.0.0.0:161
270+# ListenDatagram=[::]:161
271+# ListenStream=[::]:161
272+#
273+# Uncomment AgentX socket if snmpd.conf enables AgentX protocol.
274+# ListenStream=/var/agentx/master
275+
276+[Install]
277+WantedBy=sockets.target
278diff --git a/dist/snmptrapd.service b/dist/snmptrapd.service
279new file mode 100644
280index 0000000..e88a5b4
281--- /dev/null
282+++ b/dist/snmptrapd.service
283@@ -0,0 +1,16 @@
284+#
285+# SNMP trap-processing service file for systemd
286+#
287+
288+[Unit]
289+Description=Simple Network Management Protocol (SNMP) Trap daemon.
290+After=syslog.target network.target
291+
292+[Service]
293+# Type=notify is also supported. It should be set when snmptrapd.socket is not
294+# used.
295+Type=simple
296+ExecStart=/usr/sbin/snmptrapd -f
297+
298+[Install]
299+WantedBy=multi-user.target
300diff --git a/dist/snmptrapd.socket b/dist/snmptrapd.socket
301new file mode 100644
302index 0000000..0fc8a7c
303--- /dev/null
304+++ b/dist/snmptrapd.socket
305@@ -0,0 +1,14 @@
306+[Unit]
307+Description=Socket listening for SNMP trap messages
308+
309+[Socket]
310+ListenDatagram=0.0.0.0:162
311+# Uncomment other listening addresses as needed - TCP, UDP6, TCP6.
312+# It must match listening addresses/ports defined in snmptrapd.service
313+# or snmptrapd.conf.
314+# ListenStream=0.0.0.0:162
315+# ListenDatagram=[::]:162
316+# ListenStream=[::]:162
317+
318+[Install]
319+WantedBy=sockets.target
320diff --git a/include/net-snmp/library/sd-daemon.h b/include/net-snmp/library/sd-daemon.h
321new file mode 100644
322index 0000000..85274c9
323--- /dev/null
324+++ b/include/net-snmp/library/sd-daemon.h
325@@ -0,0 +1,290 @@
326+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
327+
328+#ifndef SNMPD_SD_DAEMON_H
329+#define SNMPD_SD_DAEMON_H
330+
331+/***
332+ Copyright 2010 Lennart Poettering
333+
334+ Permission is hereby granted, free of charge, to any person
335+ obtaining a copy of this software and associated documentation files
336+ (the "Software"), to deal in the Software without restriction,
337+ including without limitation the rights to use, copy, modify, merge,
338+ publish, distribute, sublicense, and/or sell copies of the Software,
339+ and to permit persons to whom the Software is furnished to do so,
340+ subject to the following conditions:
341+
342+ The above copyright notice and this permission notice shall be
343+ included in all copies or substantial portions of the Software.
344+
345+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
346+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
347+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
348+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
349+ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
350+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
351+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
352+ SOFTWARE.
353+***/
354+
355+#ifdef HAVE_SYS_TYPES_H
356+#include <sys/types.h>
357+#endif
358+#ifdef HAVE_INTTYPES_H
359+#include <inttypes.h>
360+#endif
361+
362+#ifdef __cplusplus
363+extern "C" {
364+#endif
365+
366+/*
367+ Reference implementation of a few systemd related interfaces for
368+ writing daemons. These interfaces are trivial to implement. To
369+ simplify porting we provide this reference implementation.
370+ Applications are welcome to reimplement the algorithms described
371+ here if they do not want to include these two source files.
372+
373+ The following functionality is provided:
374+
375+ - Support for logging with log levels on stderr
376+ - File descriptor passing for socket-based activation
377+ - Daemon startup and status notification
378+ - Detection of systemd boots
379+
380+ You may compile this with -DDISABLE_SYSTEMD to disable systemd
381+ support. This makes all those calls NOPs that are directly related to
382+ systemd (i.e. only sd_is_xxx() will stay useful).
383+
384+ Since this is drop-in code we don't want any of our symbols to be
385+ exported in any case. Hence we declare hidden visibility for all of
386+ them.
387+
388+ You may find an up-to-date version of these source files online:
389+
390+ http://cgit.freedesktop.org/systemd/plain/src/sd-daemon.h
391+ http://cgit.freedesktop.org/systemd/plain/src/sd-daemon.c
392+
393+ This should compile on non-Linux systems, too, but with the
394+ exception of the sd_is_xxx() calls all functions will become NOPs.
395+
396+ See sd-daemon(7) for more information.
397+*/
398+
399+#ifndef _sd_printf_attr_
400+#if __GNUC__ >= 4
401+#define _sd_printf_attr_(a,b) __attribute__ ((format (printf, a, b)))
402+#else
403+#define _sd_printf_attr_(a,b)
404+#endif
405+#endif
406+
407+/*
408+ Log levels for usage on stderr:
409+
410+ fprintf(stderr, SD_NOTICE "Hello World!\n");
411+
412+ This is similar to printk() usage in the kernel.
413+*/
414+#define SD_EMERG "<0>" /* system is unusable */
415+#define SD_ALERT "<1>" /* action must be taken immediately */
416+#define SD_CRIT "<2>" /* critical conditions */
417+#define SD_ERR "<3>" /* error conditions */
418+#define SD_WARNING "<4>" /* warning conditions */
419+#define SD_NOTICE "<5>" /* normal but significant condition */
420+#define SD_INFO "<6>" /* informational */
421+#define SD_DEBUG "<7>" /* debug-level messages */
422+
423+/* The first passed file descriptor is fd 3 */
424+#define SD_LISTEN_FDS_START 3
425+
426+/*
427+ Returns how many file descriptors have been passed, or a negative
428+ errno code on failure. Optionally, removes the $LISTEN_FDS and
429+ $LISTEN_PID file descriptors from the environment (recommended, but
430+ problematic in threaded environments). If r is the return value of
431+ this function you'll find the file descriptors passed as fds
432+ SD_LISTEN_FDS_START to SD_LISTEN_FDS_START+r-1. Returns a negative
433+ errno style error code on failure. This function call ensures that
434+ the FD_CLOEXEC flag is set for the passed file descriptors, to make
435+ sure they are not passed on to child processes. If FD_CLOEXEC shall
436+ not be set, the caller needs to unset it after this call for all file
437+ descriptors that are used.
438+
439+ See sd_listen_fds(3) for more information.
440+*/
441+int netsnmp_sd_listen_fds(int unset_environment);
442+
443+/*
444+ Helper call for identifying a passed file descriptor. Returns 1 if
445+ the file descriptor is a FIFO in the file system stored under the
446+ specified path, 0 otherwise. If path is NULL a path name check will
447+ not be done and the call only verifies if the file descriptor
448+ refers to a FIFO. Returns a negative errno style error code on
449+ failure.
450+
451+ See sd_is_fifo(3) for more information.
452+*/
453+int netsnmp_sd_is_fifo(int fd, const char *path);
454+
455+/*
456+ Helper call for identifying a passed file descriptor. Returns 1 if
457+ the file descriptor is a special character device on the file
458+ system stored under the specified path, 0 otherwise.
459+ If path is NULL a path name check will not be done and the call
460+ only verifies if the file descriptor refers to a special character.
461+ Returns a negative errno style error code on failure.
462+
463+ See sd_is_special(3) for more information.
464+*/
465+int netsnmp_sd_is_special(int fd, const char *path);
466+
467+/*
468+ Helper call for identifying a passed file descriptor. Returns 1 if
469+ the file descriptor is a socket of the specified family (AF_INET,
470+ ...) and type (SOCK_DGRAM, SOCK_STREAM, ...), 0 otherwise. If
471+ family is 0 a socket family check will not be done. If type is 0 a
472+ socket type check will not be done and the call only verifies if
473+ the file descriptor refers to a socket. If listening is > 0 it is
474+ verified that the socket is in listening mode. (i.e. listen() has
475+ been called) If listening is == 0 it is verified that the socket is
476+ not in listening mode. If listening is < 0 no listening mode check
477+ is done. Returns a negative errno style error code on failure.
478+
479+ See sd_is_socket(3) for more information.
480+*/
481+int netsnmp_sd_is_socket(int fd, int family, int type, int listening);
482+
483+/*
484+ Helper call for identifying a passed file descriptor. Returns 1 if
485+ the file descriptor is an Internet socket, of the specified family
486+ (either AF_INET or AF_INET6) and the specified type (SOCK_DGRAM,
487+ SOCK_STREAM, ...), 0 otherwise. If version is 0 a protocol version
488+ check is not done. If type is 0 a socket type check will not be
489+ done. If port is 0 a socket port check will not be done. The
490+ listening flag is used the same way as in sd_is_socket(). Returns a
491+ negative errno style error code on failure.
492+
493+ See sd_is_socket_inet(3) for more information.
494+*/
495+int netsnmp_sd_is_socket_inet(int fd, int family, int type, int listening, uint16_t port);
496+
497+/*
498+ Helper call for identifying a passed file descriptor. Returns 1 if
499+ the file descriptor is an AF_UNIX socket of the specified type
500+ (SOCK_DGRAM, SOCK_STREAM, ...) and path, 0 otherwise. If type is 0
501+ a socket type check will not be done. If path is NULL a socket path
502+ check will not be done. For normal AF_UNIX sockets set length to
503+ 0. For abstract namespace sockets set length to the length of the
504+ socket name (including the initial 0 byte), and pass the full
505+ socket path in path (including the initial 0 byte). The listening
506+ flag is used the same way as in sd_is_socket(). Returns a negative
507+ errno style error code on failure.
508+
509+ See sd_is_socket_unix(3) for more information.
510+*/
511+int netsnmp_sd_is_socket_unix(int fd, int type, int listening, const char *path, size_t length);
512+
513+/*
514+ Informs systemd about changed daemon state. This takes a number of
515+ newline separated environment-style variable assignments in a
516+ string. The following variables are known:
517+
518+ READY=1 Tells systemd that daemon startup is finished (only
519+ relevant for services of Type=notify). The passed
520+ argument is a boolean "1" or "0". Since there is
521+ little value in signaling non-readiness the only
522+ value daemons should send is "READY=1".
523+
524+ STATUS=... Passes a single-line status string back to systemd
525+ that describes the daemon state. This is free-from
526+ and can be used for various purposes: general state
527+ feedback, fsck-like programs could pass completion
528+ percentages and failing programs could pass a human
529+ readable error message. Example: "STATUS=Completed
530+ 66% of file system check..."
531+
532+ ERRNO=... If a daemon fails, the errno-style error code,
533+ formatted as string. Example: "ERRNO=2" for ENOENT.
534+
535+ BUSERROR=... If a daemon fails, the D-Bus error-style error
536+ code. Example: "BUSERROR=org.freedesktop.DBus.Error.TimedOut"
537+
538+ MAINPID=... The main pid of a daemon, in case systemd did not
539+ fork off the process itself. Example: "MAINPID=4711"
540+
541+ Daemons can choose to send additional variables. However, it is
542+ recommended to prefix variable names not listed above with X_.
543+
544+ Returns a negative errno-style error code on failure. Returns > 0
545+ if systemd could be notified, 0 if it couldn't possibly because
546+ systemd is not running.
547+
548+ Example: When a daemon finished starting up, it could issue this
549+ call to notify systemd about it:
550+
551+ sd_notify(0, "READY=1");
552+
553+ See sd_notifyf() for more complete examples.
554+
555+ See sd_notify(3) for more information.
556+*/
557+int netsnmp_sd_notify(int unset_environment, const char *state);
558+
559+/*
560+ Similar to sd_notify() but takes a format string.
561+
562+ Example 1: A daemon could send the following after initialization:
563+
564+ sd_notifyf(0, "READY=1\n"
565+ "STATUS=Processing requests...\n"
566+ "MAINPID=%lu",
567+ (unsigned long) getpid());
568+
569+ Example 2: A daemon could send the following shortly before
570+ exiting, on failure:
571+
572+ sd_notifyf(0, "STATUS=Failed to start up: %s\n"
573+ "ERRNO=%i",
574+ strerror(errno),
575+ errno);
576+
577+ See sd_notifyf(3) for more information.
578+*/
579+int netsnmp_sd_notifyf(int unset_environment, const char *format, ...) _sd_printf_attr_(2,3);
580+
581+/*
582+ Returns > 0 if the system was booted with systemd. Returns < 0 on
583+ error. Returns 0 if the system was not booted with systemd. Note
584+ that all of the functions above handle non-systemd boots just
585+ fine. You should NOT protect them with a call to this function. Also
586+ note that this function checks whether the system, not the user
587+ session is controlled by systemd. However the functions above work
588+ for both user and system services.
589+
590+ See sd_booted(3) for more information.
591+*/
592+int netsnmp_sd_booted(void);
593+
594+/**
595+ * Find an socket with given parameters. See man sd_is_socket_inet for
596+ * description of the arguments.
597+ *
598+ * Returns the file descriptor if it is found, 0 otherwise.
599+ */
600+int netsnmp_sd_find_inet_socket(int family, int type, int listening, int port);
601+
602+/**
603+ * Find an unix socket with given parameters. See man sd_is_socket_unix for
604+ * description of the arguments.
605+ *
606+ * Returns the file descriptor if it is found, 0 otherwise.
607+ */
608+int
609+netsnmp_sd_find_unix_socket(int type, int listening, const char *path);
610+
611+#ifdef __cplusplus
612+}
613+#endif
614+
615+#endif /* SNMPD_SD_DAEMON_H */
616diff --git a/snmplib/sd-daemon.c b/snmplib/sd-daemon.c
617new file mode 100644
618index 0000000..42dba29
619--- /dev/null
620+++ b/snmplib/sd-daemon.c
621@@ -0,0 +1,532 @@
622+/*
623+ * Systemd integration parts.
624+ *
625+ * Most of this file is directly copied from systemd sources.
626+ * Changes:
627+ * - all functions were renamed to have netsnmp_ prefix
628+ * - includes were changed to match Net-SNMP style.
629+ * - removed gcc export macros
630+ * - removed POSIX message queues
631+ */
632+
633+#include <net-snmp/net-snmp-config.h>
634+#include <net-snmp/net-snmp-features.h>
635+#include <net-snmp/types.h>
636+#include <net-snmp/library/snmp_debug.h>
637+
638+#ifndef NETSNMP_NO_SYSTEMD
639+
640+/***
641+ Copyright 2010 Lennart Poettering
642+
643+ Permission is hereby granted, free of charge, to any person
644+ obtaining a copy of this software and associated documentation files
645+ (the "Software"), to deal in the Software without restriction,
646+ including without limitation the rights to use, copy, modify, merge,
647+ publish, distribute, sublicense, and/or sell copies of the Software,
648+ and to permit persons to whom the Software is furnished to do so,
649+ subject to the following conditions:
650+
651+ The above copyright notice and this permission notice shall be
652+ included in all copies or substantial portions of the Software.
653+
654+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
655+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
656+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
657+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
658+ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
659+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
660+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
661+ SOFTWARE.
662+***/
663+
664+#ifndef _GNU_SOURCE
665+#define _GNU_SOURCE
666+#endif
667+
668+#include <sys/types.h>
669+#include <sys/stat.h>
670+#include <sys/socket.h>
671+#include <sys/un.h>
672+#include <sys/fcntl.h>
673+#include <netinet/in.h>
674+#include <stdlib.h>
675+#include <errno.h>
676+#include <unistd.h>
677+#include <string.h>
678+#include <stdarg.h>
679+#include <stdio.h>
680+#include <stddef.h>
681+#include <limits.h>
682+
683+#include <net-snmp/library/sd-daemon.h>
684+
685+int netsnmp_sd_listen_fds(int unset_environment) {
686+
687+ int r, fd;
688+ const char *e;
689+ char *p = NULL;
690+ unsigned long l;
691+
692+ if (!(e = getenv("LISTEN_PID"))) {
693+ r = 0;
694+ goto finish;
695+ }
696+
697+ errno = 0;
698+ l = strtoul(e, &p, 10);
699+
700+ if (errno != 0) {
701+ r = -errno;
702+ goto finish;
703+ }
704+
705+ if (!p || *p || l <= 0) {
706+ r = -EINVAL;
707+ goto finish;
708+ }
709+
710+ /* Is this for us? */
711+ if (getpid() != (pid_t) l) {
712+ r = 0;
713+ goto finish;
714+ }
715+
716+ if (!(e = getenv("LISTEN_FDS"))) {
717+ r = 0;
718+ goto finish;
719+ }
720+
721+ errno = 0;
722+ l = strtoul(e, &p, 10);
723+
724+ if (errno != 0) {
725+ r = -errno;
726+ goto finish;
727+ }
728+
729+ if (!p || *p) {
730+ r = -EINVAL;
731+ goto finish;
732+ }
733+
734+ for (fd = SD_LISTEN_FDS_START; fd < SD_LISTEN_FDS_START + (int) l; fd ++) {
735+ int flags;
736+
737+ if ((flags = fcntl(fd, F_GETFD)) < 0) {
738+ r = -errno;
739+ goto finish;
740+ }
741+
742+ if (flags & FD_CLOEXEC)
743+ continue;
744+
745+ if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) < 0) {
746+ r = -errno;
747+ goto finish;
748+ }
749+ }
750+
751+ r = (int) l;
752+
753+finish:
754+ if (unset_environment) {
755+ unsetenv("LISTEN_PID");
756+ unsetenv("LISTEN_FDS");
757+ }
758+
759+ return r;
760+}
761+
762+int netsnmp_sd_is_fifo(int fd, const char *path) {
763+ struct stat st_fd;
764+
765+ if (fd < 0)
766+ return -EINVAL;
767+
768+ memset(&st_fd, 0, sizeof(st_fd));
769+ if (fstat(fd, &st_fd) < 0)
770+ return -errno;
771+
772+ if (!S_ISFIFO(st_fd.st_mode))
773+ return 0;
774+
775+ if (path) {
776+ struct stat st_path;
777+
778+ memset(&st_path, 0, sizeof(st_path));
779+ if (stat(path, &st_path) < 0) {
780+
781+ if (errno == ENOENT || errno == ENOTDIR)
782+ return 0;
783+
784+ return -errno;
785+ }
786+
787+ return
788+ st_path.st_dev == st_fd.st_dev &&
789+ st_path.st_ino == st_fd.st_ino;
790+ }
791+
792+ return 1;
793+}
794+
795+int netsnmp_sd_is_special(int fd, const char *path) {
796+ struct stat st_fd;
797+
798+ if (fd < 0)
799+ return -EINVAL;
800+
801+ if (fstat(fd, &st_fd) < 0)
802+ return -errno;
803+
804+ if (!S_ISREG(st_fd.st_mode) && !S_ISCHR(st_fd.st_mode))
805+ return 0;
806+
807+ if (path) {
808+ struct stat st_path;
809+
810+ if (stat(path, &st_path) < 0) {
811+
812+ if (errno == ENOENT || errno == ENOTDIR)
813+ return 0;
814+
815+ return -errno;
816+ }
817+
818+ if (S_ISREG(st_fd.st_mode) && S_ISREG(st_path.st_mode))
819+ return
820+ st_path.st_dev == st_fd.st_dev &&
821+ st_path.st_ino == st_fd.st_ino;
822+ else if (S_ISCHR(st_fd.st_mode) && S_ISCHR(st_path.st_mode))
823+ return st_path.st_rdev == st_fd.st_rdev;
824+ else
825+ return 0;
826+ }
827+
828+ return 1;
829+}
830+
831+static int sd_is_socket_internal(int fd, int type, int listening) {
832+ struct stat st_fd;
833+
834+ if (fd < 0 || type < 0)
835+ return -EINVAL;
836+
837+ if (fstat(fd, &st_fd) < 0)
838+ return -errno;
839+
840+ if (!S_ISSOCK(st_fd.st_mode))
841+ return 0;
842+
843+ if (type != 0) {
844+ int other_type = 0;
845+ socklen_t l = sizeof(other_type);
846+
847+ if (getsockopt(fd, SOL_SOCKET, SO_TYPE, &other_type, &l) < 0)
848+ return -errno;
849+
850+ if (l != sizeof(other_type))
851+ return -EINVAL;
852+
853+ if (other_type != type)
854+ return 0;
855+ }
856+
857+ if (listening >= 0) {
858+ int accepting = 0;
859+ socklen_t l = sizeof(accepting);
860+
861+ if (getsockopt(fd, SOL_SOCKET, SO_ACCEPTCONN, &accepting, &l) < 0)
862+ return -errno;
863+
864+ if (l != sizeof(accepting))
865+ return -EINVAL;
866+
867+ if (!accepting != !listening)
868+ return 0;
869+ }
870+
871+ return 1;
872+}
873+
874+union sockaddr_union {
875+ struct sockaddr sa;
876+ struct sockaddr_in in4;
877+ struct sockaddr_in6 in6;
878+ struct sockaddr_un un;
879+ struct sockaddr_storage storage;
880+};
881+
882+int netsnmp_sd_is_socket(int fd, int family, int type, int listening) {
883+ int r;
884+
885+ if (family < 0)
886+ return -EINVAL;
887+
888+ if ((r = sd_is_socket_internal(fd, type, listening)) <= 0)
889+ return r;
890+
891+ if (family > 0) {
892+ union sockaddr_union sockaddr;
893+ socklen_t l;
894+
895+ memset(&sockaddr, 0, sizeof(sockaddr));
896+ l = sizeof(sockaddr);
897+
898+ if (getsockname(fd, &sockaddr.sa, &l) < 0)
899+ return -errno;
900+
901+ if (l < sizeof(sa_family_t))
902+ return -EINVAL;
903+
904+ return sockaddr.sa.sa_family == family;
905+ }
906+
907+ return 1;
908+}
909+
910+int netsnmp_sd_is_socket_inet(int fd, int family, int type, int listening, uint16_t port) {
911+ union sockaddr_union sockaddr;
912+ socklen_t l;
913+ int r;
914+
915+ if (family != 0 && family != AF_INET && family != AF_INET6)
916+ return -EINVAL;
917+
918+ if ((r = sd_is_socket_internal(fd, type, listening)) <= 0)
919+ return r;
920+
921+ memset(&sockaddr, 0, sizeof(sockaddr));
922+ l = sizeof(sockaddr);
923+
924+ if (getsockname(fd, &sockaddr.sa, &l) < 0)
925+ return -errno;
926+
927+ if (l < sizeof(sa_family_t))
928+ return -EINVAL;
929+
930+ if (sockaddr.sa.sa_family != AF_INET &&
931+ sockaddr.sa.sa_family != AF_INET6)
932+ return 0;
933+
934+ if (family > 0)
935+ if (sockaddr.sa.sa_family != family)
936+ return 0;
937+
938+ if (port > 0) {
939+ if (sockaddr.sa.sa_family == AF_INET) {
940+ if (l < sizeof(struct sockaddr_in))
941+ return -EINVAL;
942+
943+ return htons(port) == sockaddr.in4.sin_port;
944+ } else {
945+ if (l < sizeof(struct sockaddr_in6))
946+ return -EINVAL;
947+
948+ return htons(port) == sockaddr.in6.sin6_port;
949+ }
950+ }
951+
952+ return 1;
953+}
954+
955+int netsnmp_sd_is_socket_unix(int fd, int type, int listening, const char *path, size_t length) {
956+ union sockaddr_union sockaddr;
957+ socklen_t l;
958+ int r;
959+
960+ if ((r = sd_is_socket_internal(fd, type, listening)) <= 0)
961+ return r;
962+
963+ memset(&sockaddr, 0, sizeof(sockaddr));
964+ l = sizeof(sockaddr);
965+
966+ if (getsockname(fd, &sockaddr.sa, &l) < 0)
967+ return -errno;
968+
969+ if (l < sizeof(sa_family_t))
970+ return -EINVAL;
971+
972+ if (sockaddr.sa.sa_family != AF_UNIX)
973+ return 0;
974+
975+ if (path) {
976+ if (length <= 0)
977+ length = strlen(path);
978+
979+ if (length <= 0)
980+ /* Unnamed socket */
981+ return l == offsetof(struct sockaddr_un, sun_path);
982+
983+ if (path[0])
984+ /* Normal path socket */
985+ return
986+ (l >= offsetof(struct sockaddr_un, sun_path) + length + 1) &&
987+ memcmp(path, sockaddr.un.sun_path, length+1) == 0;
988+ else
989+ /* Abstract namespace socket */
990+ return
991+ (l == offsetof(struct sockaddr_un, sun_path) + length) &&
992+ memcmp(path, sockaddr.un.sun_path, length) == 0;
993+ }
994+
995+ return 1;
996+}
997+
998+int netsnmp_sd_notify(int unset_environment, const char *state) {
999+ int fd = -1, r;
1000+ struct msghdr msghdr;
1001+ struct iovec iovec;
1002+ union sockaddr_union sockaddr;
1003+ const char *e;
1004+
1005+ if (!state) {
1006+ r = -EINVAL;
1007+ goto finish;
1008+ }
1009+
1010+ if (!(e = getenv("NOTIFY_SOCKET")))
1011+ return 0;
1012+
1013+ /* Must be an abstract socket, or an absolute path */
1014+ if ((e[0] != '@' && e[0] != '/') || e[1] == 0) {
1015+ r = -EINVAL;
1016+ goto finish;
1017+ }
1018+
1019+ if ((fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0)) < 0) {
1020+ r = -errno;
1021+ goto finish;
1022+ }
1023+
1024+ memset(&sockaddr, 0, sizeof(sockaddr));
1025+ sockaddr.sa.sa_family = AF_UNIX;
1026+ strncpy(sockaddr.un.sun_path, e, sizeof(sockaddr.un.sun_path));
1027+
1028+ if (sockaddr.un.sun_path[0] == '@')
1029+ sockaddr.un.sun_path[0] = 0;
1030+
1031+ memset(&iovec, 0, sizeof(iovec));
1032+ iovec.iov_base = (char *)state;
1033+ iovec.iov_len = strlen(state);
1034+
1035+ memset(&msghdr, 0, sizeof(msghdr));
1036+ msghdr.msg_name = &sockaddr;
1037+ msghdr.msg_namelen = offsetof(struct sockaddr_un, sun_path) + strlen(e);
1038+
1039+ if (msghdr.msg_namelen > sizeof(struct sockaddr_un))
1040+ msghdr.msg_namelen = sizeof(struct sockaddr_un);
1041+
1042+ msghdr.msg_iov = &iovec;
1043+ msghdr.msg_iovlen = 1;
1044+
1045+ if (sendmsg(fd, &msghdr, MSG_NOSIGNAL) < 0) {
1046+ r = -errno;
1047+ goto finish;
1048+ }
1049+
1050+ r = 1;
1051+
1052+finish:
1053+ if (unset_environment)
1054+ unsetenv("NOTIFY_SOCKET");
1055+
1056+ if (fd >= 0)
1057+ close(fd);
1058+
1059+ return r;
1060+}
1061+
1062+int netsnmp_sd_notifyf(int unset_environment, const char *format, ...) {
1063+ va_list ap;
1064+ char *p = NULL;
1065+ int r;
1066+
1067+ va_start(ap, format);
1068+ r = vasprintf(&p, format, ap);
1069+ va_end(ap);
1070+
1071+ if (r < 0 || !p)
1072+ return -ENOMEM;
1073+
1074+ r = netsnmp_sd_notify(unset_environment, p);
1075+ free(p);
1076+
1077+ return r;
1078+}
1079+
1080+int netsnmp_sd_booted(void) {
1081+ struct stat a, b;
1082+
1083+ /* We simply test whether the systemd cgroup hierarchy is
1084+ * mounted */
1085+
1086+ if (lstat("/sys/fs/cgroup", &a) < 0)
1087+ return 0;
1088+
1089+ if (lstat("/sys/fs/cgroup/systemd", &b) < 0)
1090+ return 0;
1091+
1092+ return a.st_dev != b.st_dev;
1093+}
1094+
1095+/* End of original sd-daemon.c from systemd sources */
1096+
1097+int
1098+netsnmp_sd_find_inet_socket(int family, int type, int listening, int port)
1099+{
1100+ int count, fd;
1101+
1102+ count = netsnmp_sd_listen_fds(0);
1103+ if (count <= 0) {
1104+ DEBUGMSGTL(("systemd:find_inet_socket", "No LISTEN_FDS found.\n"));
1105+ return 0;
1106+ }
1107+ DEBUGMSGTL(("systemd:find_inet_socket", "LISTEN_FDS reports %d sockets.\n",
1108+ count));
1109+
1110+ for (fd = 3; fd < 3+count; fd++) {
1111+ int rc = netsnmp_sd_is_socket_inet(fd, family, type, listening, port);
1112+ if (rc < 0)
1113+ DEBUGMSGTL(("systemd:find_inet_socket",
1114+ "sd_is_socket_inet error: %d\n", rc));
1115+ if (rc > 0) {
1116+ DEBUGMSGTL(("systemd:find_inet_socket",
1117+ "Found the socket in LISTEN_FDS\n"));
1118+ return fd;
1119+ }
1120+ }
1121+ DEBUGMSGTL(("systemd:find_inet_socket", "Socket not found in LISTEN_FDS\n"));
1122+ return 0;
1123+}
1124+
1125+int
1126+netsnmp_sd_find_unix_socket(int type, int listening, const char *path)
1127+{
1128+ int count, fd;
1129+
1130+ count = netsnmp_sd_listen_fds(0);
1131+ if (count <= 0) {
1132+ DEBUGMSGTL(("systemd:find_unix_socket", "No LISTEN_FDS found.\n"));
1133+ return 0;
1134+ }
1135+ DEBUGMSGTL(("systemd:find_unix_socket", "LISTEN_FDS reports %d sockets.\n",
1136+ count));
1137+
1138+ for (fd = 3; fd < 3+count; fd++) {
1139+ int rc = netsnmp_sd_is_socket_unix(fd, type, listening, path, 0);
1140+ if (rc < 0)
1141+ DEBUGMSGTL(("systemd:find_unix_socket",
1142+ "netsnmp_sd_is_socket_unix error: %d\n", rc));
1143+ if (rc > 0) {
1144+ DEBUGMSGTL(("systemd:find_unix_socket",
1145+ "Found the socket in LISTEN_FDS\n"));
1146+ return fd;
1147+ }
1148+ }
1149+ DEBUGMSGTL(("systemd:find_unix_socket", "Socket not found in LISTEN_FDS\n"));
1150+ return 0;
1151+}
1152+
1153+#endif /* ! NETSNMP_NO_SYSTEMD */
1154diff --git a/snmplib/transports/snmpTCPDomain.c b/snmplib/transports/snmpTCPDomain.c
1155index b8bdba4..ab7f3a1 100644
1156--- a/snmplib/transports/snmpTCPDomain.c
1157+++ b/snmplib/transports/snmpTCPDomain.c
1158@@ -43,6 +43,10 @@
1159 #include <net-snmp/library/snmpTCPBaseDomain.h>
1160 #include <net-snmp/library/tools.h>
1161
1162+#ifndef NETSNMP_NO_SYSTEMD
1163+#include <net-snmp/library/sd-daemon.h>
1164+#endif
1165+
1166 /*
1167 * needs to be in sync with the definitions in snmplib/snmpUDPDomain.c
1168 * and perl/agent/agent.xs
1169@@ -149,6 +153,7 @@ netsnmp_tcp_transport(struct sockaddr_in *addr, int local)
1170 netsnmp_transport *t = NULL;
1171 netsnmp_udp_addr_pair *addr_pair = NULL;
1172 int rc = 0;
1173+ int socket_initialized = 0;
1174
1175 #ifdef NETSNMP_NO_LISTEN_SUPPORT
1176 if (local)
1177@@ -178,7 +183,19 @@ netsnmp_tcp_transport(struct sockaddr_in *addr, int local)
1178 t->domain_length =
1179 sizeof(netsnmp_snmpTCPDomain) / sizeof(netsnmp_snmpTCPDomain[0]);
1180
1181- t->sock = socket(PF_INET, SOCK_STREAM, 0);
1182+#ifndef NETSNMP_NO_SYSTEMD
1183+ /*
1184+ * Maybe the socket was already provided by systemd...
1185+ */
1186+ if (local) {
1187+ t->sock = netsnmp_sd_find_inet_socket(PF_INET, SOCK_STREAM, 1,
1188+ ntohs(addr->sin_port));
1189+ if (t->sock)
1190+ socket_initialized = 1;
1191+ }
1192+#endif
1193+ if (!socket_initialized)
1194+ t->sock = socket(PF_INET, SOCK_STREAM, 0);
1195 if (t->sock < 0) {
1196 netsnmp_transport_free(t);
1197 return NULL;
1198@@ -215,11 +232,13 @@ netsnmp_tcp_transport(struct sockaddr_in *addr, int local)
1199 setsockopt(t->sock, SOL_SOCKET, SO_REUSEADDR, (void *)&opt,
1200 sizeof(opt));
1201
1202- rc = bind(t->sock, (struct sockaddr *)addr, sizeof(struct sockaddr));
1203- if (rc != 0) {
1204- netsnmp_socketbase_close(t);
1205- netsnmp_transport_free(t);
1206- return NULL;
1207+ if (!socket_initialized) {
1208+ rc = bind(t->sock, (struct sockaddr *)addr, sizeof(struct sockaddr));
1209+ if (rc != 0) {
1210+ netsnmp_socketbase_close(t);
1211+ netsnmp_transport_free(t);
1212+ return NULL;
1213+ }
1214 }
1215
1216 /*
1217@@ -235,12 +254,13 @@ netsnmp_tcp_transport(struct sockaddr_in *addr, int local)
1218 /*
1219 * Now sit here and wait for connections to arrive.
1220 */
1221-
1222- rc = listen(t->sock, NETSNMP_STREAM_QUEUE_LEN);
1223- if (rc != 0) {
1224- netsnmp_socketbase_close(t);
1225- netsnmp_transport_free(t);
1226- return NULL;
1227+ if (!socket_initialized) {
1228+ rc = listen(t->sock, NETSNMP_STREAM_QUEUE_LEN);
1229+ if (rc != 0) {
1230+ netsnmp_socketbase_close(t);
1231+ netsnmp_transport_free(t);
1232+ return NULL;
1233+ }
1234 }
1235
1236 /*
1237diff --git a/snmplib/transports/snmpTCPIPv6Domain.c b/snmplib/transports/snmpTCPIPv6Domain.c
1238index 3c96856..305a861 100644
1239--- a/snmplib/transports/snmpTCPIPv6Domain.c
1240+++ b/snmplib/transports/snmpTCPIPv6Domain.c
1241@@ -49,6 +49,10 @@
1242 #include <net-snmp/library/snmpTCPBaseDomain.h>
1243 #include <net-snmp/library/tools.h>
1244
1245+#ifndef NETSNMP_NO_SYSTEMD
1246+#include <net-snmp/library/sd-daemon.h>
1247+#endif
1248+
1249 #include "inet_ntop.h"
1250
1251 oid netsnmp_TCPIPv6Domain[] = { TRANSPORT_DOMAIN_TCP_IPV6 };
1252@@ -140,6 +144,8 @@ netsnmp_tcp6_transport(struct sockaddr_in6 *addr, int local)
1253 {
1254 netsnmp_transport *t = NULL;
1255 int rc = 0;
1256+ char *str = NULL;
1257+ int socket_initialized = 0;
1258
1259 #ifdef NETSNMP_NO_LISTEN_SUPPORT
1260 if (local)
1261@@ -174,7 +180,19 @@ netsnmp_tcp6_transport(struct sockaddr_in6 *addr, int local)
1262 t->domain = netsnmp_TCPIPv6Domain;
1263 t->domain_length = sizeof(netsnmp_TCPIPv6Domain) / sizeof(oid);
1264
1265- t->sock = socket(PF_INET6, SOCK_STREAM, 0);
1266+#ifndef NETSNMP_NO_SYSTEMD
1267+ /*
1268+ * Maybe the socket was already provided by systemd...
1269+ */
1270+ if (local) {
1271+ t->sock = netsnmp_sd_find_inet_socket(PF_INET6, SOCK_STREAM, 1,
1272+ ntohs(addr->sin6_port));
1273+ if (t->sock)
1274+ socket_initialized = 1;
1275+ }
1276+#endif
1277+ if (!socket_initialized)
1278+ t->sock = socket(PF_INET6, SOCK_STREAM, 0);
1279 if (t->sock < 0) {
1280 netsnmp_transport_free(t);
1281 return NULL;
1282@@ -220,12 +238,14 @@ netsnmp_tcp6_transport(struct sockaddr_in6 *addr, int local)
1283
1284 setsockopt(t->sock, SOL_SOCKET, SO_REUSEADDR, (void *)&opt, sizeof(opt));
1285
1286- rc = bind(t->sock, (struct sockaddr *) addr,
1287- sizeof(struct sockaddr_in6));
1288- if (rc != 0) {
1289- netsnmp_socketbase_close(t);
1290- netsnmp_transport_free(t);
1291- return NULL;
1292+ if (!socket_initialized) {
1293+ rc = bind(t->sock, (struct sockaddr *) addr,
1294+ sizeof(struct sockaddr_in6));
1295+ if (rc != 0) {
1296+ netsnmp_socketbase_close(t);
1297+ netsnmp_transport_free(t);
1298+ return NULL;
1299+ }
1300 }
1301
1302 /*
1303@@ -242,11 +262,13 @@ netsnmp_tcp6_transport(struct sockaddr_in6 *addr, int local)
1304 * Now sit here and wait for connections to arrive.
1305 */
1306
1307- rc = listen(t->sock, NETSNMP_STREAM_QUEUE_LEN);
1308- if (rc != 0) {
1309- netsnmp_socketbase_close(t);
1310- netsnmp_transport_free(t);
1311- return NULL;
1312+ if (!socket_initialized) {
1313+ rc = listen(t->sock, NETSNMP_STREAM_QUEUE_LEN);
1314+ if (rc != 0) {
1315+ netsnmp_socketbase_close(t);
1316+ netsnmp_transport_free(t);
1317+ return NULL;
1318+ }
1319 }
1320
1321 /*
1322diff --git a/snmplib/transports/snmpUDPIPv4BaseDomain.c b/snmplib/transports/snmpUDPIPv4BaseDomain.c
1323index c67427b..428e6d6 100644
1324--- a/snmplib/transports/snmpUDPIPv4BaseDomain.c
1325+++ b/snmplib/transports/snmpUDPIPv4BaseDomain.c
1326@@ -40,6 +40,10 @@
1327
1328 #include <net-snmp/library/snmpSocketBaseDomain.h>
1329
1330+#ifndef NETSNMP_NO_SYSTEMD
1331+#include <net-snmp/library/sd-daemon.h>
1332+#endif
1333+
1334 #if (defined(linux) && defined(IP_PKTINFO)) \
1335 || defined(IP_RECVDSTADDR) && HAVE_STRUCT_MSGHDR_MSG_CONTROL \
1336 && HAVE_STRUCT_MSGHDR_MSG_FLAGS
1337@@ -67,6 +71,7 @@ netsnmp_udpipv4base_transport(struct sockaddr_in *addr, int local)
1338 char *client_socket = NULL;
1339 netsnmp_indexed_addr_pair addr_pair;
1340 socklen_t local_addr_len;
1341+ int socket_initialized = 0;
1342
1343 #ifdef NETSNMP_NO_LISTEN_SUPPORT
1344 if (local)
1345@@ -91,7 +96,19 @@ netsnmp_udpipv4base_transport(struct sockaddr_in *addr, int local)
1346 free(str);
1347 }
1348
1349- t->sock = socket(PF_INET, SOCK_DGRAM, 0);
1350+#ifndef NETSNMP_NO_SYSTEMD
1351+ /*
1352+ * Maybe the socket was already provided by systemd...
1353+ */
1354+ if (local) {
1355+ t->sock = netsnmp_sd_find_inet_socket(PF_INET, SOCK_DGRAM, -1,
1356+ ntohs(addr->sin_port));
1357+ if (t->sock)
1358+ socket_initialized = 1;
1359+ }
1360+#endif
1361+ if (!socket_initialized)
1362+ t->sock = socket(PF_INET, SOCK_DGRAM, 0);
1363 DEBUGMSGTL(("UDPBase", "openned socket %d as local=%d\n", t->sock, local));
1364 if (t->sock < 0) {
1365 netsnmp_transport_free(t);
1366@@ -141,12 +158,14 @@ netsnmp_udpipv4base_transport(struct sockaddr_in *addr, int local)
1367 DEBUGMSGTL(("netsnmp_udp", "set IP_RECVDSTADDR\n"));
1368 }
1369 #endif
1370- rc = bind(t->sock, (struct sockaddr *) addr,
1371- sizeof(struct sockaddr));
1372- if (rc != 0) {
1373- netsnmp_socketbase_close(t);
1374- netsnmp_transport_free(t);
1375- return NULL;
1376+ if (!socket_initialized) {
1377+ rc = bind(t->sock, (struct sockaddr *) addr,
1378+ sizeof(struct sockaddr));
1379+ if (rc != 0) {
1380+ netsnmp_socketbase_close(t);
1381+ netsnmp_transport_free(t);
1382+ return NULL;
1383+ }
1384 }
1385 t->data = NULL;
1386 t->data_length = 0;
1387diff --git a/snmplib/transports/snmpUDPIPv6Domain.c b/snmplib/transports/snmpUDPIPv6Domain.c
1388index b3eaae4..35b617f 100644
1389--- a/snmplib/transports/snmpUDPIPv6Domain.c
1390+++ b/snmplib/transports/snmpUDPIPv6Domain.c
1391@@ -67,6 +67,10 @@ static const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT;
1392 #include <net-snmp/library/snmpSocketBaseDomain.h>
1393 #include <net-snmp/library/tools.h>
1394
1395+#ifndef NETSNMP_NO_SYSTEMD
1396+#include <net-snmp/library/sd-daemon.h>
1397+#endif
1398+
1399 #include "inet_ntop.h"
1400 #include "inet_pton.h"
1401
1402@@ -190,6 +194,8 @@ netsnmp_udp6_transport(struct sockaddr_in6 *addr, int local)
1403 {
1404 netsnmp_transport *t = NULL;
1405 int rc = 0;
1406+ char *str = NULL;
1407+ int socket_initialized = 0;
1408
1409 #ifdef NETSNMP_NO_LISTEN_SUPPORT
1410 if (local)
1411@@ -217,7 +223,19 @@ netsnmp_udp6_transport(struct sockaddr_in6 *addr, int local)
1412 t->domain_length =
1413 sizeof(netsnmp_UDPIPv6Domain) / sizeof(netsnmp_UDPIPv6Domain[0]);
1414
1415- t->sock = socket(PF_INET6, SOCK_DGRAM, 0);
1416+#ifndef NETSNMP_NO_SYSTEMD
1417+ /*
1418+ * Maybe the socket was already provided by systemd...
1419+ */
1420+ if (local) {
1421+ t->sock = netsnmp_sd_find_inet_socket(PF_INET6, SOCK_DGRAM, -1,
1422+ ntohs(addr->sin6_port));
1423+ if (t->sock)
1424+ socket_initialized = 1;
1425+ }
1426+#endif
1427+ if (!socket_initialized)
1428+ t->sock = socket(PF_INET6, SOCK_DGRAM, 0);
1429 if (t->sock < 0) {
1430 netsnmp_transport_free(t);
1431 return NULL;
1432@@ -242,13 +260,14 @@ netsnmp_udp6_transport(struct sockaddr_in6 *addr, int local)
1433 }
1434 }
1435 #endif
1436-
1437- rc = bind(t->sock, (struct sockaddr *) addr,
1438- sizeof(struct sockaddr_in6));
1439- if (rc != 0) {
1440- netsnmp_socketbase_close(t);
1441- netsnmp_transport_free(t);
1442- return NULL;
1443+ if (!socket_initialized) {
1444+ rc = bind(t->sock, (struct sockaddr *) addr,
1445+ sizeof(struct sockaddr_in6));
1446+ if (rc != 0) {
1447+ netsnmp_socketbase_close(t);
1448+ netsnmp_transport_free(t);
1449+ return NULL;
1450+ }
1451 }
1452 t->local = (unsigned char*)malloc(18);
1453 if (t->local == NULL) {
1454diff --git a/snmplib/transports/snmpUnixDomain.c b/snmplib/transports/snmpUnixDomain.c
1455index 674dc2b..9f3d3cb 100644
1456--- a/snmplib/transports/snmpUnixDomain.c
1457+++ b/snmplib/transports/snmpUnixDomain.c
1458@@ -37,6 +37,10 @@
1459 #include <net-snmp/library/system.h> /* mkdirhier */
1460 #include <net-snmp/library/tools.h>
1461
1462+#ifndef NETSNMP_NO_SYSTEMD
1463+#include <net-snmp/library/sd-daemon.h>
1464+#endif
1465+
1466 netsnmp_feature_child_of(transport_unix_socket_all, transport_all)
1467 netsnmp_feature_child_of(unix_socket_paths, transport_unix_socket_all)
1468
1469@@ -295,6 +299,8 @@ netsnmp_unix_transport(struct sockaddr_un *addr, int local)
1470 netsnmp_transport *t = NULL;
1471 sockaddr_un_pair *sup = NULL;
1472 int rc = 0;
1473+ char *string = NULL;
1474+ int socket_initialized = 0;
1475
1476 #ifdef NETSNMP_NO_LISTEN_SUPPORT
1477 /* SPECIAL CIRCUMSTANCE: We still want AgentX to be able to operate,
1478@@ -333,7 +339,18 @@ netsnmp_unix_transport(struct sockaddr_un *addr, int local)
1479 t->data_length = sizeof(sockaddr_un_pair);
1480 sup = (sockaddr_un_pair *) t->data;
1481
1482- t->sock = socket(PF_UNIX, SOCK_STREAM, 0);
1483+#ifndef NETSNMP_NO_SYSTEMD
1484+ /*
1485+ * Maybe the socket was already provided by systemd...
1486+ */
1487+ if (local) {
1488+ t->sock = netsnmp_sd_find_unix_socket(SOCK_STREAM, 1, addr->sun_path);
1489+ if (t->sock)
1490+ socket_initialized = 1;
1491+ }
1492+#endif
1493+ if (!socket_initialized)
1494+ t->sock = socket(PF_UNIX, SOCK_STREAM, 0);
1495 if (t->sock < 0) {
1496 netsnmp_transport_free(t);
1497 return NULL;
1498@@ -357,25 +374,26 @@ netsnmp_unix_transport(struct sockaddr_un *addr, int local)
1499
1500 t->flags |= NETSNMP_TRANSPORT_FLAG_LISTEN;
1501
1502- unlink(addr->sun_path);
1503- rc = bind(t->sock, (struct sockaddr *) addr, SUN_LEN(addr));
1504-
1505- if (rc != 0 && errno == ENOENT && create_path) {
1506- rc = mkdirhier(addr->sun_path, create_mode, 1);
1507+ if (!socket_initialized) {
1508+ unlink(addr->sun_path);
1509+ rc = bind(t->sock, (struct sockaddr *) addr, SUN_LEN(addr));
1510+ if (rc != 0 && errno == ENOENT && create_path) {
1511+ rc = mkdirhier(addr->sun_path, create_mode, 1);
1512+ if (rc != 0) {
1513+ netsnmp_unix_close(t);
1514+ netsnmp_transport_free(t);
1515+ return NULL;
1516+ }
1517+ rc = bind(t->sock, (struct sockaddr *) addr, SUN_LEN(addr));
1518+ }
1519 if (rc != 0) {
1520+ DEBUGMSGTL(("netsnmp_unix_transport",
1521+ "couldn't bind \"%s\", errno %d (%s)\n",
1522+ addr->sun_path, errno, strerror(errno)));
1523 netsnmp_unix_close(t);
1524 netsnmp_transport_free(t);
1525 return NULL;
1526 }
1527- rc = bind(t->sock, (struct sockaddr *) addr, SUN_LEN(addr));
1528- }
1529- if (rc != 0) {
1530- DEBUGMSGTL(("netsnmp_unix_transport",
1531- "couldn't bind \"%s\", errno %d (%s)\n",
1532- addr->sun_path, errno, strerror(errno)));
1533- netsnmp_unix_close(t);
1534- netsnmp_transport_free(t);
1535- return NULL;
1536 }
1537
1538 /*
1539@@ -391,16 +409,17 @@ netsnmp_unix_transport(struct sockaddr_un *addr, int local)
1540 * Now sit here and listen for connections to arrive.
1541 */
1542
1543- rc = listen(t->sock, NETSNMP_STREAM_QUEUE_LEN);
1544- if (rc != 0) {
1545- DEBUGMSGTL(("netsnmp_unix_transport",
1546- "couldn't listen to \"%s\", errno %d (%s)\n",
1547- addr->sun_path, errno, strerror(errno)));
1548- netsnmp_unix_close(t);
1549- netsnmp_transport_free(t);
1550- return NULL;
1551+ if (!socket_initialized) {
1552+ rc = listen(t->sock, NETSNMP_STREAM_QUEUE_LEN);
1553+ if (rc != 0) {
1554+ DEBUGMSGTL(("netsnmp_unix_transport",
1555+ "couldn't listen to \"%s\", errno %d (%s)\n",
1556+ addr->sun_path, errno, strerror(errno)));
1557+ netsnmp_unix_close(t);
1558+ netsnmp_transport_free(t);
1559+ return NULL;
1560+ }
1561 }
1562-
1563 } else {
1564 t->remote = (u_char *)malloc(strlen(addr->sun_path));
1565 if (t->remote == NULL) {
1566diff --git a/win32/libsnmp/Makefile.in b/win32/libsnmp/Makefile.in
1567index 98d83c8..dd5689b 100644
1568--- a/win32/libsnmp/Makefile.in
1569+++ b/win32/libsnmp/Makefile.in
1570@@ -42,6 +42,7 @@ LIB32_OBJS= \
1571 "$(INTDIR)\read_config.obj" \
1572 "$(INTDIR)\readdir.obj" \
1573 "$(INTDIR)\scapi.obj" \
1574+ "$(INTDIR)\sd-daemon.obj" \
1575 "$(INTDIR)\snmp-tc.obj" \
1576 "$(INTDIR)\snmp.obj" \
1577 "$(INTDIR)\snmpCallbackDomain.obj" \
1578@@ -307,6 +308,12 @@ SOURCE=..\..\snmplib\scapi.c
1579 $(CPP) $(CPP_PROJ) $(SOURCE)
1580
1581
1582+SOURCE=..\..\snmplib\sd-daemon.c
1583+
1584+"$(INTDIR)\sd-daemon.obj" : $(SOURCE) "$(INTDIR)"
1585+ $(CPP) $(CPP_PROJ) $(SOURCE)
1586+
1587+
1588 SOURCE="..\..\snmplib\snmp-tc.c"
1589
1590 "$(INTDIR)\snmp-tc.obj" : $(SOURCE) "$(INTDIR)"
1591diff --git a/win32/net-snmp/net-snmp-config.h b/win32/net-snmp/net-snmp-config.h
1592index 7791ee0..1eccf42 100644
1593--- a/win32/net-snmp/net-snmp-config.h
1594+++ b/win32/net-snmp/net-snmp-config.h
1595@@ -1705,6 +1705,8 @@ enum {
1596 #define DMALLOC_FUNC_CHECK
1597 #endif
1598
1599+#define NETSNMP_NO_SYSTEMD
1600+
1601 /* #undef NETSNMP_ENABLE_LOCAL_SMUX */
1602
1603 /* define if agentx transport is to use domain sockets only */
1604diff --git a/win32/net-snmp/net-snmp-config.h.in b/win32/net-snmp/net-snmp-config.h.in
1605index 5215865..1607bfa 100644
1606--- a/win32/net-snmp/net-snmp-config.h.in
1607+++ b/win32/net-snmp/net-snmp-config.h.in
1608@@ -1705,6 +1705,8 @@ enum {
1609 #define DMALLOC_FUNC_CHECK
1610 #endif
1611
1612+#define NETSNMP_NO_SYSTEMD
1613+
1614 /* #undef NETSNMP_ENABLE_LOCAL_SMUX */
1615
1616 /* define if agentx transport is to use domain sockets only */
diff --git a/meta-networking/recipes-protocols/net-snmp/net-snmp_5.7.2.bb b/meta-networking/recipes-protocols/net-snmp/net-snmp_5.7.2.bb
new file mode 100644
index 000000000..4c3939a7e
--- /dev/null
+++ b/meta-networking/recipes-protocols/net-snmp/net-snmp_5.7.2.bb
@@ -0,0 +1,118 @@
1SUMMARY = "Various tools relating to the Simple Network Management Protocol"
2HOMEPAGE = "http://www.net-snmp.org/"
3LICENSE = "BSD"
4
5LIC_FILES_CHKSUM = "file://README;beginline=3;endline=8;md5=7f7f00ba639ac8e8deb5a622ea24634e"
6
7DEPENDS = "openssl libnl pciutils"
8
9SRC_URI = "${SOURCEFORGE_MIRROR}/net-snmp/net-snmp-${PV}.tar.gz \
10 file://init \
11 file://snmpd.conf \
12 file://snmptrapd.conf \
13 file://systemd-support.patch \
14 file://snmpd.service \
15 file://snmptrapd.service \
16 file://ifmib.patch \
17"
18
19SRC_URI[md5sum] = "5bddd02e2f82b62daa79f82717737a14"
20SRC_URI[sha256sum] = "09ed31b4cc1f3c0411ef9a16eff79ef3b30d89c32ca46d5a01a41826c4ceb816"
21
22inherit autotools update-rc.d siteinfo systemd
23
24EXTRA_OEMAKE = "INSTALL_PREFIX=${D}"
25
26PARALLEL_MAKE = ""
27CCACHE = ""
28
29TARGET_CC_ARCH += "${LDFLAGS}"
30
31EXTRA_OECONF = "--disable-embedded-perl \
32 --with-perl-modules=no \
33 --enable-shared \
34 --disable-manuals \
35 --with-defaults \
36 ${@base_conditional('SITEINFO_ENDIANNESS', 'le', '--with-endianness=little', '--with-endianness=big', d)}"
37
38do_install_append() {
39 install -d ${D}${sysconfdir}/snmp
40 install -d ${D}${sysconfdir}/init.d
41 install -m 755 ${WORKDIR}/init ${D}${sysconfdir}/init.d/snmpd
42 install -m 644 ${WORKDIR}/snmpd.conf ${D}${sysconfdir}/snmp/
43 install -m 644 ${WORKDIR}/snmptrapd.conf ${D}${sysconfdir}/snmp/
44 install -d ${STAGING_BINDIR}
45 install -m 0755 ${D}${bindir}/net-snmp-config ${STAGING_BINDIR}/
46 sed -e "s@-I/usr/include@@g" \
47 -e "s@^prefix=.*@prefix=${STAGING_DIR_HOST}@g" \
48 -e "s@^exec_prefix=.*@exec_prefix=${STAGING_DIR_HOST}@g" \
49 -e "s@^includedir=.*@includedir=${STAGING_INCDIR}@g" \
50 -e "s@^libdir=.*@libdir=${STAGING_LIBDIR}@g" \
51 -i ${STAGING_BINDIR}/net-snmp-config
52 install -d ${D}${systemd_unitdir}/system
53 install -m 0644 ${WORKDIR}/snmpd.service ${D}${systemd_unitdir}/system
54 install -m 0644 ${WORKDIR}/snmptrapd.service ${D}${systemd_unitdir}/system
55}
56
57PACKAGES = "${PN}-dbg ${PN}-doc ${PN}-dev ${PN}-staticdev ${PN}-static ${PN}-libs \
58 ${PN}-mibs ${PN}-server ${PN}-client ${PN}-server-snmpd ${PN}-server-snmptrapd"
59
60ALLOW_EMPTY_${PN}-server = "1"
61
62FILES_${PN}-libs = "${libdir}/lib*${SOLIBS}"
63FILES_${PN}-mibs = "${datadir}/snmp/mibs"
64FILES_${PN}-server-snmpd = "${sbindir}/snmpd \
65 ${sysconfdir}/snmp/snmpd.conf \
66 ${sysconfdir}/init.d \
67 ${systemd_unitdir}/system/snmpd.service \
68"
69
70FILES_${PN}-server-snmptrapd = "${sbindir}/snmptrapd \
71 ${sysconfdir}/snmp/snmptrapd.conf \
72 ${systemd_unitdir}/system/snmptrapd.service \
73"
74
75FILES_${PN}-client = "${bindir}/* ${datadir}/snmp/"
76FILES_${PN}-dbg += "${libdir}/.debug/ ${sbindir}/.debug/ ${bindir}/.debug/"
77FILES_${PN}-dev += "${bindir}/net-snmp-config ${bindir}/mib2c ${bindir}/mib2c-update"
78
79CONFFILES_${PN}-server-snmpd = "${sysconfdir}/snmp/snmpd.conf"
80CONFFILES_${PN}-server-snmptrapd = "${sysconfdir}/snmp/snmptrapd.conf"
81
82INITSCRIPT_PACKAGES = "${PN}-server"
83INITSCRIPT_NAME_${PN}-server = "snmpd"
84INITSCRIPT_PARAMS_${PN}-server = "defaults"
85
86EXTRA_OECONF += "${@base_contains('DISTRO_FEATURES', 'systemd', '--with-systemd', '--without-systemd', d)}"
87
88SYSTEMD_PACKAGES = "${PN}-server-snmpd \
89 ${PN}-server-snmptrapd"
90
91SYSTEMD_SERVICE_${PN}-server-snmpd = "snmpd.service"
92SYSTEMD_SERVICE_${PN}-server-snmptrapd = "snmptrapd.service"
93
94RDEPENDS_${PN}-server-snmpd += "net-snmp-mibs"
95RDEPENDS_${PN}-server-snmptrapd += "net-snmp-server-snmpd"
96RDEPENDS_${PN}-server += "net-snmp-server-snmpd net-snmp-server-snmptrapd"
97RDEPENDS_${PN}-client += "net-snmp-mibs"
98RDEPENDS_${PN}-dev = "net-snmp-client (= ${EXTENDPKGV}) net-snmp-server (= ${EXTENDPKGV})"
99RRECOMMENDS_${PN}-dbg = "net-snmp-client (= ${EXTENDPKGV}) net-snmp-server (= ${EXTENDPKGV})"
100
101RPROVIDES_${PN}-server-snmpd += "${PN}-server-snmpd-systemd"
102RREPLACES_${PN}-server-snmpd += "${PN}-server-snmpd-systemd"
103RCONFLICTS_${PN}-server-snmpd += "${PN}-server-snmpd-systemd"
104
105RPROVIDES_${PN}-server-snmptrapd += "${PN}-server-snmptrapd-systemd"
106RREPLACES_${PN}-server-snmptrapd += "${PN}-server-snmptrapd-systemd"
107RCONFLICTS_${PN}-server-snmptrapd += "${PN}-server-snmptrapd-systemd"
108
109LEAD_SONAME = "libnetsnmp.so"
110
111pkg_postrm_${PN}-server() {
112 if test "x$D" != "x"; then
113 OPT="-r $D "
114 else
115 OPT=""
116 /etc/init.d/snmpd stop
117 fi
118}