]> git.ipfire.org Git - ipfire-3.x.git/commitdiff
lldpd: Update to 0.5.4.
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 1 Nov 2011 19:35:50 +0000 (20:35 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 1 Nov 2011 19:35:50 +0000 (20:35 +0100)
The os-release patch was accepted upstream.

References #280.

lldpd/lldpd.nm
lldpd/lldpd.tmpfiles
lldpd/patches/lldpd-0.52.x-os-release.patch [deleted file]
lldpd/systemd/lldpd.service

index 271e9ad5fa19b550357a4e42e8f6e22ae7ca7246..3521db8ee68a87234acc86dbfa50e84f999170ea 100644 (file)
@@ -4,8 +4,8 @@
 ###############################################################################
 
 name       = lldpd
-version    = 0.5.2
-release    = 5
+version    = 0.5.4
+release    = 1
 
 groups     = Networking/Tools
 url        = https://trac.luffy.cx/lldpd/
@@ -13,7 +13,7 @@ license    = GPL
 summary    = Utilities for the Link Layer Discovery Protocol.
 
 description
-       The LLDPD project aims to provide a comprehensive implementation of \
+       The LLDPD project aims to provide a comprehensive implementation of
        the IEEE standard 802.1AB Link Layer Discovery Protocol.
 end
 
@@ -23,6 +23,7 @@ build
        requires
                libxml2-devel
                pkg-config
+               shadow-utils
                zlib-devel
        end
 
@@ -30,9 +31,48 @@ build
                --with-xml \
                --with-privsep-user=lldpd \
                --with-privsep-group=lldpd
+
+       prepare_cmds
+               %{create_user}
+       end
+
+       install_cmds
+               # Create tmp directory.
+               mkdir -pv -m 700 %{BUILDROOT}/run/lldpd
+               chown -v lldpd.lldpd %{BUILDROOT}/run/lldpd
+       end
+end
+
+create_user
+       getent group lldpd >/dev/null || groupadd -r lldpd
+       getent passwd lldpd >/dev/null || \
+               useradd -r -g lldpd -d / -s /sbin/nologin lldpd
 end
 
 packages
        package %{name}
+               prerequires = shadow-utils systemd-units
+
+               script prein
+                       %{create_user}
+               end
+
+               script postin
+                       /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+               end
+
+               script preun
+                       /bin/systemctl --no-reload disable lldpd.service >/dev/null 2>&1 || :
+                       /bin/systemctl stop lldpd.service >/dev/null 2>&1 || :
+               end
+
+               script postun
+                       /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+               end
+
+               script postup
+                       /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+                       /bin/systemctl try-restart lldpd.service >/dev/null 2>&1 || :
+               end
        end
 end
index 0e95b5a11273bca7e3ed3aabdf168a3be89c4ee9..5e3af548a5811f01c4d15134255a92e19cae61cb 100644 (file)
@@ -1 +1 @@
-d /var/run/lldpd 0700 lldpd lldpd -
+d /run/lldpd 0700 lldpd lldpd -
diff --git a/lldpd/patches/lldpd-0.52.x-os-release.patch b/lldpd/patches/lldpd-0.52.x-os-release.patch
deleted file mode 100644 (file)
index 3d45fee..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-commit ae87586a12eaf4e8329b88f6e0c629e7b14f27bc
-Author: Michael Tremer <michael.tremer@ipfire.org>
-Date:   Sat May 28 14:29:33 2011 +0200
-
-    Add support to read /etc/os-release for system information.
-    
-    /etc/os-release is introduced with systemd which will be in all the
-    major distributions, soon. For backwards-compatibility, the lsb_release
-    method is still there and will be used if no /etc/os-release is available.
-
-diff --git a/src/lldpd.c b/src/lldpd.c
-index b19af11..1641f13 100644
---- a/src/lldpd.c
-+++ b/src/lldpd.c
-@@ -89,6 +89,7 @@ static void           lldpd_decode(struct lldpd *, char *, int,
- static void            lldpd_update_chassis(struct lldpd_chassis *,
-                           const struct lldpd_chassis *);
- static char           *lldpd_get_lsb_release(void);
-+static char           *lldpd_get_os_release(void);
- #ifdef ENABLE_LLDPMED
- static void            lldpd_med(struct lldpd_chassis *);
- #endif
-@@ -553,6 +554,46 @@ lldpd_get_lsb_release() {
-       return NULL;
- }
-+/* Same like lldpd_get_lsb_release but reads /etc/os-release for PRETTY_NAME=. */
-+static char *
-+lldpd_get_os_release() {
-+      static char release[1024];
-+
-+      FILE *fp = fopen("/etc/os-release", "r");
-+      if (!fp) {
-+              LLOG_WARN("Could not open /etc/os-release to read system information");
-+              return NULL;
-+      }
-+
-+      char line[1024];
-+      char *key, *val;
-+
-+      while ((fgets(line, 1024, fp) != NULL)) {
-+              key = strtok(line, "=");
-+              val = strtok(NULL, "=");
-+
-+              if (strncmp(key, "PRETTY_NAME", 1024) == 0) {
-+                      strncpy(release, val, 1024);
-+                      break;
-+              }
-+      }
-+      fclose(fp);
-+
-+      /* Remove trailing newline and all " in the string. */
-+      char *ptr1 = release;
-+      char *ptr2 = release;
-+      while (*ptr1 != 0) {
-+              if ((*ptr1 == '"') || (*ptr1 == '\n')) {
-+                      ++ptr1;
-+              } else {
-+                      *ptr2++ = *ptr1++;
-+              }
-+      }
-+      *ptr2 = 0;
-+
-+      return release;
-+}
-+
- int
- lldpd_callback_add(struct lldpd *cfg, int fd, void(*fn)(CALLBACK_SIG), void *data)
- {
-@@ -889,7 +930,7 @@ lldpd_update_localchassis(struct lldpd *cfg)
-                       fatal("failed to set full system description");
-         } else {
-               if (cfg->g_advertise_version) {
--                      if (asprintf(&LOCAL_CHASSIS(cfg)->c_descr, "%s%s %s %s",
-+                      if (asprintf(&LOCAL_CHASSIS(cfg)->c_descr, "%s %s %s %s",
-                               cfg->g_lsb_release?cfg->g_lsb_release:"",
-                               un.sysname, un.release, un.machine)
-                                 == -1)
-@@ -1189,7 +1230,12 @@ lldpd_main(int argc, char *argv[])
-               close(pid);
-       }
--      lsb_release = lldpd_get_lsb_release();
-+      /* Try to read system information from /etc/os-release if possible.
-+         Fall back to lsb_release for compatibility. */
-+      lsb_release = lldpd_get_os_release();
-+      if (!lsb_release) {
-+              lsb_release = lldpd_get_lsb_release();
-+      }
-       priv_init(PRIVSEP_CHROOT);
index 49b454b9c9f8d959ee5279525f38029fb8c6b498..fed63a575b80f55b90c5c27cb39eaff73fedd393 100644 (file)
@@ -5,7 +5,8 @@ After=network.target
 [Service]
 RemainAfterExit=yes
 ExecStartPre=/sbin/modprobe 8021q
-ExecStart=/usr/sbin/lldpd -c
+ExecStart=/usr/sbin/lldpd -d -c
+Restart=on-failure
 
 [Install]
 WantedBy=multi-user.target