diff options
| author | Alex Kiernan <alex.kiernan@gmail.com> | 2022-05-07 12:32:03 +0100 |
|---|---|---|
| committer | Khem Raj <raj.khem@gmail.com> | 2022-05-07 18:47:16 -0700 |
| commit | 80a5a789fb66fb6345ff35901e369b0b711b1d68 (patch) | |
| tree | d0a2e352ec0c900edc5dadbbf5b1b14bddeec9c0 /meta-networking | |
| parent | 48515bae74e78853cd13177a115eeb2988e0fde5 (diff) | |
| download | meta-openembedded-80a5a789fb66fb6345ff35901e369b0b711b1d68.tar.gz | |
ulogd2: Add recipe
ulogd-2.x provides a flexible, almost universal logging daemon for
netfilter logging. This encompasses both packet-based logging (logging
of policy violations) and flow-based logging, e.g. for accounting
purpose.
Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
Signed-off-by: Alex Kiernan <alexk@zuma.ai>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Diffstat (limited to 'meta-networking')
3 files changed, 271 insertions, 0 deletions
diff --git a/meta-networking/recipes-filter/ulogd2/ulogd2/ulogd.init b/meta-networking/recipes-filter/ulogd2/ulogd2/ulogd.init new file mode 100644 index 0000000000..05d284e725 --- /dev/null +++ b/meta-networking/recipes-filter/ulogd2/ulogd2/ulogd.init | |||
| @@ -0,0 +1,180 @@ | |||
| 1 | #! /bin/sh | ||
| 2 | ### BEGIN INIT INFO | ||
| 3 | # Provides: ulogd2 ulogd | ||
| 4 | # Required-Start: $local_fs | ||
| 5 | # Should-Start: | ||
| 6 | # Required-Stop: $local_fs | ||
| 7 | # Should-Stop: | ||
| 8 | # Default-Start: 2 3 4 5 | ||
| 9 | # Default-Stop: 0 1 6 | ||
| 10 | # Short-Description: Userspace logging daemon for netfilter/iptables | ||
| 11 | ### END INIT INFO | ||
| 12 | |||
| 13 | # The definition of actions: (From LSB 3.1.0) | ||
| 14 | # start start the service | ||
| 15 | # stop stop the service | ||
| 16 | # restart stop and restart the service if the service is already running, | ||
| 17 | # otherwise start the service | ||
| 18 | # try-restart restart the service if the service is already running | ||
| 19 | # reload cause the configuration of the service to be reloaded without | ||
| 20 | # actually stopping and restarting the service | ||
| 21 | # force-reload cause the configuration to be reloaded if the service supports | ||
| 22 | # this, otherwise restart the service if it is running | ||
| 23 | # status print the current status of the service | ||
| 24 | |||
| 25 | # The start, stop, restart, force-reload, and status actions shall be supported | ||
| 26 | # by all init scripts; the reload and the try-restart actions are optional | ||
| 27 | |||
| 28 | # PATH should only include /usr/* if it runs after the mountnfs.sh script | ||
| 29 | PATH=/sbin:/usr/sbin:/bin:/usr/bin | ||
| 30 | |||
| 31 | DESC="Userspace logging daemon for netfilter/iptables" | ||
| 32 | NAME="ulogd" | ||
| 33 | DAEMON=/usr/sbin/$NAME | ||
| 34 | DAEMON_ARGS="-d" | ||
| 35 | PIDFILE=/var/run/$NAME.pid | ||
| 36 | |||
| 37 | . /etc/init.d/functions || exit 1 | ||
| 38 | |||
| 39 | # Exit if the package is not installed | ||
| 40 | [ -x "$DAEMON" ] || exit 0 | ||
| 41 | |||
| 42 | # Read configuration variable file if it is present | ||
| 43 | [ -r /etc/default/$NAME ] && . /etc/default/$NAME | ||
| 44 | |||
| 45 | # | ||
| 46 | # Function that starts the daemon/service | ||
| 47 | # | ||
| 48 | do_start() { | ||
| 49 | local status pid | ||
| 50 | |||
| 51 | status=0 | ||
| 52 | pid=`pidofproc $NAME` || status=$? | ||
| 53 | case $status in | ||
| 54 | 0) | ||
| 55 | echo "$DESC already running ($pid)." | ||
| 56 | exit 1 | ||
| 57 | ;; | ||
| 58 | *) | ||
| 59 | echo "Starting $DESC ..." | ||
| 60 | exec $DAEMON $DAEMON_ARGS >/dev/null 2>&1 || status=$? | ||
| 61 | echo "ERROR: Failed to start $DESC." | ||
| 62 | exit $status | ||
| 63 | ;; | ||
| 64 | esac | ||
| 65 | |||
| 66 | # Add code here, if necessary, that waits for the process to be ready | ||
| 67 | # to handle requests from services started subsequently which depend | ||
| 68 | # on this one. As a last resort, sleep for some time. | ||
| 69 | } | ||
| 70 | |||
| 71 | # | ||
| 72 | # Function that stops the daemon/service | ||
| 73 | # | ||
| 74 | do_stop() { | ||
| 75 | local pid status | ||
| 76 | |||
| 77 | status=0 | ||
| 78 | pid=`pidofproc $NAME` || status=$? | ||
| 79 | case $status in | ||
| 80 | 0) | ||
| 81 | # Exit when fail to stop, the kill would complain when fail | ||
| 82 | kill -s 15 $pid >/dev/null && rm -f $PIDFILE && \ | ||
| 83 | echo "Stopped $DESC ($pid)." || exit $? | ||
| 84 | ;; | ||
| 85 | *) | ||
| 86 | echo "$DESC is not running; none killed." >&2 | ||
| 87 | ;; | ||
| 88 | esac | ||
| 89 | |||
| 90 | # Wait for children to finish too if this is a daemon that forks | ||
| 91 | # and if the daemon is only ever run from this initscript. | ||
| 92 | # If the above conditions are not satisfied then add some other code | ||
| 93 | # that waits for the process to drop all resources that could be | ||
| 94 | # needed by services started subsequently. A last resort is to | ||
| 95 | # sleep for some time. | ||
| 96 | return $status | ||
| 97 | } | ||
| 98 | |||
| 99 | # | ||
| 100 | # Function that sends a SIGHUP to the daemon/service | ||
| 101 | # | ||
| 102 | do_reload() { | ||
| 103 | local pid status | ||
| 104 | |||
| 105 | status=0 | ||
| 106 | # If the daemon can reload its configuration without | ||
| 107 | # restarting (for example, when it is sent a SIGHUP), | ||
| 108 | # then implement that here. | ||
| 109 | pid=`pidofproc $NAME` || status=$? | ||
| 110 | case $status in | ||
| 111 | 0) | ||
| 112 | echo "Reloading $DESC ..." | ||
| 113 | kill -s 1 $pid || exit $? | ||
| 114 | ;; | ||
| 115 | *) | ||
| 116 | echo "$DESC is not running; none reloaded." >&2 | ||
| 117 | ;; | ||
| 118 | esac | ||
| 119 | exit $status | ||
| 120 | } | ||
| 121 | |||
| 122 | |||
| 123 | # | ||
| 124 | # Function that shows the daemon/service status | ||
| 125 | # | ||
| 126 | status_of_proc () { | ||
| 127 | local pid status | ||
| 128 | |||
| 129 | status=0 | ||
| 130 | # pidof output null when no program is running, so no "2>/dev/null". | ||
| 131 | pid=`pidofproc $NAME` || status=$? | ||
| 132 | case $status in | ||
| 133 | 0) | ||
| 134 | echo "$DESC is running ($pid)." | ||
| 135 | exit 0 | ||
| 136 | ;; | ||
| 137 | *) | ||
| 138 | echo "$DESC is not running." >&2 | ||
| 139 | exit $status | ||
| 140 | ;; | ||
| 141 | esac | ||
| 142 | } | ||
| 143 | |||
| 144 | case "$1" in | ||
| 145 | start) | ||
| 146 | do_start | ||
| 147 | ;; | ||
| 148 | stop) | ||
| 149 | do_stop || exit $? | ||
| 150 | ;; | ||
| 151 | status) | ||
| 152 | status_of_proc | ||
| 153 | ;; | ||
| 154 | restart) | ||
| 155 | # Always start the service regardless the status of do_stop | ||
| 156 | do_stop | ||
| 157 | do_start | ||
| 158 | ;; | ||
| 159 | try-restart|force-reload) | ||
| 160 | # force-reload is the same as reload or try-restart according | ||
| 161 | # to its definition, the reload is not implemented here, so | ||
| 162 | # force-reload is the alias of try-restart here, but it should | ||
| 163 | # be the alias of reload if reload is implemented. | ||
| 164 | # | ||
| 165 | # Only start the service when do_stop succeeds | ||
| 166 | do_stop && do_start | ||
| 167 | ;; | ||
| 168 | reload) | ||
| 169 | # If the "reload" action is implemented properly, then let the | ||
| 170 | # force-reload be the alias of reload, and remove it from | ||
| 171 | # try-restart|force-reload) | ||
| 172 | # | ||
| 173 | do_reload | ||
| 174 | ;; | ||
| 175 | *) | ||
| 176 | echo "Usage: $0 {start|stop|status|restart|try-restart|force-reload}" >&2 | ||
| 177 | exit 3 | ||
| 178 | ;; | ||
| 179 | esac | ||
| 180 | |||
diff --git a/meta-networking/recipes-filter/ulogd2/ulogd2/ulogd.service b/meta-networking/recipes-filter/ulogd2/ulogd2/ulogd.service new file mode 100644 index 0000000000..cf62962a95 --- /dev/null +++ b/meta-networking/recipes-filter/ulogd2/ulogd2/ulogd.service | |||
| @@ -0,0 +1,11 @@ | |||
| 1 | [Unit] | ||
| 2 | Description=Netfilter Ulogd daemon | ||
| 3 | Before=network-pre.target | ||
| 4 | Wants=network-pre.target | ||
| 5 | |||
| 6 | [Service] | ||
| 7 | ExecStart=@SBINDIR@/ulogd | ||
| 8 | ExecReload=kill -HUP ${MAINPID} | ||
| 9 | |||
| 10 | [Install] | ||
| 11 | WantedBy=multi-user.target | ||
diff --git a/meta-networking/recipes-filter/ulogd2/ulogd2_2.0.7.bb b/meta-networking/recipes-filter/ulogd2/ulogd2_2.0.7.bb new file mode 100644 index 0000000000..7a307dc292 --- /dev/null +++ b/meta-networking/recipes-filter/ulogd2/ulogd2_2.0.7.bb | |||
| @@ -0,0 +1,80 @@ | |||
| 1 | SUMMARY = "Userspace logging daemon for netfilter/iptables" | ||
| 2 | DESCRIPTION = "ulogd-2.x provides a flexible, almost universal logging daemon for \ | ||
| 3 | netfilter logging. This encompasses both packet-based logging (logging of \ | ||
| 4 | policy violations) and flow-based logging, e.g. for accounting purpose." | ||
| 5 | HOMEPAGE = "https://www.netfilter.org/projects/ulogd/index.html" | ||
| 6 | LICENSE = "GPL-2.0-only" | ||
| 7 | LIC_FILES_CHKSUM = "file://COPYING;md5=c93c0550bd3173f4504b2cbd8991e50b" | ||
| 8 | |||
| 9 | DEPENDS = "libnfnetlink" | ||
| 10 | PROVIDES = "ulogd" | ||
| 11 | |||
| 12 | PV .= "+git${SRCPV}" | ||
| 13 | |||
| 14 | SRC_URI = "git://git.netfilter.org/ulogd2;branch=master \ | ||
| 15 | file://ulogd.init \ | ||
| 16 | file://ulogd.service \ | ||
| 17 | " | ||
| 18 | SRCREV = "5f9628c9273815b6e560603427fe86118e7cb5bb" | ||
| 19 | |||
| 20 | S = "${WORKDIR}/git" | ||
| 21 | |||
| 22 | inherit autotools manpages pkgconfig systemd update-rc.d | ||
| 23 | |||
| 24 | PACKAGECONFIG ?= "dbi json nfacct nfct nflog pcap sqlite3 ulog" | ||
| 25 | PACKAGECONFIG[dbi] = "--enable-dbi,--disable-dbi,libdbi" | ||
| 26 | PACKAGECONFIG[json] = "--enable-json,--disable-json,jansson" | ||
| 27 | PACKAGECONFIG[manpages] = "" | ||
| 28 | PACKAGECONFIG[mysql] = "--enable-mysql,--disable-mysql,mysql5" | ||
| 29 | PACKAGECONFIG[nfacct] = "--enable-nfacct,--disable-nfacct,libnetfilter-acct" | ||
| 30 | PACKAGECONFIG[nfct] = "--enable-nfct,--disable-nfct,libnetfilter-conntrack" | ||
| 31 | PACKAGECONFIG[nflog] = "--enable-nflog,--disable-nflog,libnetfilter-log" | ||
| 32 | PACKAGECONFIG[pcap] = "--enable-pcap,--disable-pcap,libpcap" | ||
| 33 | PACKAGECONFIG[pgsql] = "--enable-pgsql,--disable-pgsql,postgresql" | ||
| 34 | PACKAGECONFIG[sqlite3] = "--enable-sqlite3,--disable-sqlite3,sqlite3" | ||
| 35 | PACKAGECONFIG[ulog] = "--enable-ulog,--disable-ulog" | ||
| 36 | |||
| 37 | do_install:append () { | ||
| 38 | install -d ${D}${sysconfdir} | ||
| 39 | install -m 0644 ${B}/ulogd.conf ${D}${sysconfdir}/ulogd.conf | ||
| 40 | |||
| 41 | install -d ${D}${mandir}/man8 | ||
| 42 | install -m 0644 ${S}/ulogd.8 ${D}${mandir}/man8/ulogd.8 | ||
| 43 | |||
| 44 | install -d ${D}${systemd_system_unitdir} | ||
| 45 | install -m 0644 ${WORKDIR}/ulogd.service ${D}${systemd_system_unitdir} | ||
| 46 | sed -i -e 's,@SBINDIR@,${sbindir},g' ${D}${systemd_system_unitdir}/ulogd.service | ||
| 47 | |||
| 48 | install -d ${D}${sysconfdir}/init.d | ||
| 49 | install -m 755 ${WORKDIR}/ulogd.init ${D}${sysconfdir}/init.d/ulogd | ||
| 50 | } | ||
| 51 | |||
| 52 | PACKAGES += "${PN}-plugins" | ||
| 53 | ALLOW_EMPTY:${PN}-plugins = "1" | ||
| 54 | |||
| 55 | PACKAGES_DYNAMIC += "^${PN}-plugin-.*$" | ||
| 56 | NOAUTOPACKAGEDEBUG = "1" | ||
| 57 | |||
| 58 | CONFFILES:${PN} = "${sysconfdir}/ulogd.conf" | ||
| 59 | RRECOMMENDS:${PN} += "${PN}-plugins" | ||
| 60 | |||
| 61 | FILES:${PN}-dbg += "${sbindir}/.debug" | ||
| 62 | |||
| 63 | python split_ulogd_libs () { | ||
| 64 | libdir = d.expand('${libdir}/ulogd') | ||
| 65 | dbglibdir = os.path.join(libdir, '.debug') | ||
| 66 | |||
| 67 | split_packages = do_split_packages(d, libdir, r'^ulogd_.*\_([A-Z0-9]*).so', '${PN}-plugin-%s', 'ulogd2 %s plugin', prepend=True) | ||
| 68 | split_dbg_packages = do_split_packages(d, dbglibdir, r'^ulogd_.*\_([A-Z0-9]*).so', '${PN}-plugin-%s-dbg', 'ulogd2 %s plugin - Debugging files', prepend=True, extra_depends='${PN}-dbg') | ||
| 69 | |||
| 70 | if split_packages: | ||
| 71 | pn = d.getVar('PN') | ||
| 72 | d.setVar('RRECOMMENDS:' + pn + '-plugins', ' '.join(split_packages)) | ||
| 73 | d.appendVar('RRECOMMENDS:' + pn + '-dbg', ' ' + ' '.join(split_dbg_packages)) | ||
| 74 | } | ||
| 75 | PACKAGESPLITFUNCS:prepend = "split_ulogd_libs " | ||
| 76 | |||
| 77 | SYSTEMD_SERVICE:${PN} = "ulogd.service" | ||
| 78 | |||
| 79 | INITSCRIPT_NAME = "ulogd" | ||
| 80 | INITSCRIPT_PARAMS = "defaults" | ||
