From a4605cf6f2ebe88fcfa8cdc86dfdd0c9ad0573c2 Mon Sep 17 00:00:00 2001 From: Hangbin Liu Date: Tue, 26 Mar 2024 16:32:19 +0800 Subject: [PATCH] lldpd-1.0.18-4 Declare systems users so it will be possible to introspect system users. At the same time, remove all none systemd configs. Resolves: RHEL-5787 Signed-off-by: Hangbin Liu --- lldpd-systemd-sysusers.conf | 2 + lldpd-el7.service => lldpd.service | 0 lldpd.spec | 118 +++++----------------- lldpd-fedora.sysconfig => lldpd.sysconfig | 0 4 files changed, 30 insertions(+), 90 deletions(-) create mode 100644 lldpd-systemd-sysusers.conf rename lldpd-el7.service => lldpd.service (100%) rename lldpd-fedora.sysconfig => lldpd.sysconfig (100%) diff --git a/lldpd-systemd-sysusers.conf b/lldpd-systemd-sysusers.conf new file mode 100644 index 0000000..9b45295 --- /dev/null +++ b/lldpd-systemd-sysusers.conf @@ -0,0 +1,2 @@ +#Type Name ID GECOS Home directory Shell +u lldpd - "Used by the lldpd daemon" /var/lib/lldpd /sbin/nologin diff --git a/lldpd-el7.service b/lldpd.service similarity index 100% rename from lldpd-el7.service rename to lldpd.service diff --git a/lldpd.spec b/lldpd.spec index baa01c6..706a853 100644 --- a/lldpd.spec +++ b/lldpd.spec @@ -1,53 +1,29 @@ -%if 0%{?el6} -%bcond_with systemd -%global rundir /var/run/ -%else -%bcond_without systemd -%global rundir /run/ -%endif - -%global gh_owner vincentbernat - Name: lldpd Version: 1.0.18 -Release: 3%{?dist} +Release: 4%{?dist} Summary: ISC-licensed implementation of LLDP License: ISC -URL: https://%{gh_owner}.github.io/%{name}/ -# Upstream https://media.luffy.cx/files/lldpd/lldpd-%{version}.tar.gz -Source0: lldpd-%{version}-free.tar.gz -Source1: %{name}-fedora.service +URL: https://github.com/lldpd/ +# Upstream https://github.com/lldpd/lldpd/archive/v%{version}/%{name}-%{version}.tar.gz +Source0: lldpd-%{version}-free.tar.gz +Source1: %{name}.service Source2: %{name}-tmpfiles -Source3: %{name}-fedora.sysconfig -Source4: %{name}-el6.init -Source5: %{name}-el7.service +Source3: %{name}.sysconfig +Source4: %{name}-systemd-sysusers.conf Source100: lldpd-cleanup.sh -BuildRequires: gcc -BuildRequires: readline-devel BuildRequires: check-devel -BuildRequires: net-snmp-devel +BuildRequires: gcc BuildRequires: libxml2-devel -# EL6 needs libevent2 as the package -%if 0%{?el6} -BuildRequires: libevent2-devel -%else BuildRequires: libevent-devel -%endif - -%if 0%{?with_systemd} -# For systemd stuff -BuildRequires: systemd BuildRequires: make +BuildRequires: net-snmp-devel +BuildRequires: readline-devel +BuildRequires: systemd-rpm-macros %{?systemd_requires} -%else -Requires(post): chkconfig -Requires(preun): chkconfig -# This is for /sbin/service -Requires(preun): initscripts -%endif +%{?sysusers_requires_compat} Requires(pre): shadow-utils @@ -65,106 +41,69 @@ Summary: %{summary} %{name} development libraries and headers %prep -%autosetup - +%autosetup -p1 %build %configure --disable-static --with-snmp --disable-silent-rules \ --with-privsep-user=%{name} --with-privsep-group=%{name} \ - --with-privsep-chroot=%{rundir}%{name}/chroot \ - --with-lldpd-ctl-socket=%{rundir}%{name}/%{name}.socket \ -%if 0%{?with_systemd} + --with-privsep-chroot=%{_rundir}/%{name}/chroot \ + --with-lldpd-ctl-socket=%{_rundir}/%{name}/%{name}.socket \ --with-systemdsystemunitdir=%{_unitdir} --with-sysusersdir=no -%endif - -make %{?_smp_mflags} +%make_build %install %make_install -%if 0%{?with_systemd} -%if 0%{?fedora} >= 26 install -p -D -m644 %{SOURCE1} %{buildroot}%{_unitdir}/%{name}.service -%else -install -p -D -m644 %{SOURCE5} %{buildroot}%{_unitdir}/%{name}.service -%endif install -p -D -m644 %{SOURCE2} %{buildroot}%{_tmpfilesdir}/%{name}.conf -%else -install -p -D -m755 %{SOURCE4} %{buildroot}%{_initddir}/%{name} -%endif install -p -D -m644 %{SOURCE3} %{buildroot}/etc/sysconfig/%{name} +install -p -D -m644 %{SOURCE4} %{buildroot}%{_sysusersdir}/%{name}.conf -install -d -D -m 0755 %{buildroot}%{rundir}%{name}/chroot +install -d -D -m 0755 %{buildroot}%{_rundir}/%{name}/chroot install -d -m 0755 %{buildroot}%{_sharedstatedir}/%{name} # remove the docs from buildroot rm -rf %{buildroot}/usr/share/doc/%{name} - # don't include completion conf yet rm -f %{buildroot}/usr/share/bash-completion/completions/lldpcli rm -f %{buildroot}/usr/share/zsh/vendor-completions/_lldpcli rm -f %{buildroot}/usr/share/zsh/site-functions/_lldpcli # remove static libtool archive -rm -f %{buildroot}%{_libdir}/liblldpctl.la +find %{buildroot} -type f -name "*.la" -delete + +%ldconfig_scriptlets %pre -getent group %{name} >/dev/null || groupadd -r %{name} -getent passwd %{name} >/dev/null || \ - useradd -r -g %{name} -d %{_sharedstatedir}/%{name} -s /sbin/nologin \ - -c "Used by the %{name} daemon" %{name} -exit 0 +%sysusers_create_compat %{SOURCE4} %post -/sbin/ldconfig -%if 0%{?with_systemd} %systemd_post %{name}.service -%else -# This adds the proper /etc/rc*.d links for the script -/sbin/chkconfig --add %{name} -%endif %preun -%if 0%{?with_systemd} %systemd_preun %{name}.service -%else -if [ $1 -eq 0 ] ; then - /sbin/service %{name} stop >/dev/null 2>&1 - /sbin/chkconfig --del %{name} -fi -%endif %postun -/sbin/ldconfig -%if 0%{?with_systemd} %systemd_postun_with_restart %{name}.service -%else -if [ "$1" -ge "1" ] ; then - /sbin/service %{name} condrestart >/dev/null 2>&1 || : -fi -%endif %files -%doc NEWS README.md %license LICENSE +%doc NEWS README.md +%config %{_sysconfdir}/%{name}.d +%config(noreplace) %{_sysconfdir}/sysconfig/%{name} %{_sbindir}/lldpcli %{_sbindir}/lldpctl %{_sbindir}/%{name} -%config %{_sysconfdir}/%{name}.d -%config(noreplace) %{_sysconfdir}/sysconfig/%{name} %{_mandir}/man8/lldpcli.8* %{_mandir}/man8/lldpctl.8* %{_mandir}/man8/%{name}.8* %{_libdir}/liblldpctl.so.4* -%dir %{rundir}%{name} -%dir %{rundir}%{name}/chroot -%if 0%{?with_systemd} +%dir %{_rundir}/%{name} +%dir %{_rundir}/%{name}/chroot %{_unitdir}/%{name}.service %{_tmpfilesdir}/%{name}.conf -%else -%{_initddir}/%{name} -%endif +%{_sysusersdir}/%{name}.conf %dir %attr(-,lldpd,lldpd) %{_sharedstatedir}/%{name} %files devel @@ -173,7 +112,6 @@ fi %{_libdir}/liblldpctl.so %{_libdir}/pkgconfig/lldpctl.pc - %changelog * Mon May 20 2024 Hangbin Liu - 1.0.18-3 - Add lldpd-devel package [RHEL-22127] diff --git a/lldpd-fedora.sysconfig b/lldpd.sysconfig similarity index 100% rename from lldpd-fedora.sysconfig rename to lldpd.sysconfig