From e0f1d84375d26ab18c377a50adc2efa3ec02b774b423fdad2085058775d4fd38 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Tue, 6 Feb 2024 21:17:42 +0000 Subject: [PATCH 1/3] Accepting request 1144719 from home:adkorte:branches:server:http - Use sysuser-tools to generate varnish user OBS-URL: https://build.opensuse.org/request/show/1144719 OBS-URL: https://build.opensuse.org/package/show/server:http/varnish?expand=0&rev=127 --- varnish-user.conf | 2 ++ varnish.changes | 5 +++++ varnish.spec | 18 +++++++++--------- 3 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 varnish-user.conf diff --git a/varnish-user.conf b/varnish-user.conf new file mode 100644 index 0000000..ac67ead --- /dev/null +++ b/varnish-user.conf @@ -0,0 +1,2 @@ +#Type Name ID GECOS Home directory Shell +u varnish - "User for Varnish" /var/lib/varnish - diff --git a/varnish.changes b/varnish.changes index 3c97ba9..f2270b9 100644 --- a/varnish.changes +++ b/varnish.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Tue Feb 6 19:45:13 UTC 2024 - Arjen de Korte + +- Use sysuser-tools to generate varnish user + ------------------------------------------------------------------- Fri Dec 1 09:34:39 UTC 2023 - Dirk Müller diff --git a/varnish.spec b/varnish.spec index d0bdb20..1b356b9 100644 --- a/varnish.spec +++ b/varnish.spec @@ -1,7 +1,7 @@ # # spec file for package varnish # -# Copyright (c) 2023 SUSE LLC +# Copyright (c) 2024 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -33,6 +33,7 @@ Group: Productivity/Networking/Web/Proxy URL: https://varnish-cache.org/ #Git-Web: https://github.com/varnishcache/varnish-cache Source: https://varnish-cache.org/_downloads/%name-%version.tgz +Source2: %{name}-user.conf Source3: varnish.sysconfig Source5: varnish.logrotate Source7: varnish.service @@ -44,12 +45,13 @@ BuildRequires: ncurses-devel BuildRequires: python3-Sphinx BuildRequires: python3-docutils BuildRequires: readline-devel -BuildRequires: systemd-rpm-macros +BuildRequires: sysuser-tools BuildRequires: xz BuildRequires: pkgconfig(libpcre2-8) Requires: c_compiler -Requires(pre): shadow Recommends: logrotate +%{?sysusers_requires} +%{?systemd_ordering} %description Varnish is an HTTP accelerator. Often called Reverse Proxy, it is an @@ -93,6 +95,7 @@ This package holds the development files for varnish. %autosetup -p1 %build +%sysusers_generate_pre %{SOURCE2} %{name} %{name}-user.conf %define _lto_cflags %nil export CFLAGS="%optflags -fcommon -fstack-protector" %ifarch %ix86 @@ -113,6 +116,7 @@ install -dm 0755 "$b"/{%pkg_logdir,%pkg_home} install -Dpm 0644 "%SOURCE5" "$b/%_sysconfdir/logrotate.d/varnish" # ##init scripts +install -Dpm 0644 "%SOURCE2" "$b/%_sysusersdir/%{name}-user.conf" install -Dpm 0644 "%SOURCE3" "$b/%_fillupdir/sysconfig.%name" install -Dpm 0644 "%SOURCE7" "$b/%_unitdir/varnish.service" install -Dpm 0644 "%SOURCE8" "$b/%_unitdir/varnishlog.service" @@ -140,12 +144,7 @@ if ! %make_build check; then exit "$x" fi -%pre -%_bindir/getent group varnish >/dev/null || \ - %_sbindir/groupadd -r varnish -%_bindir/getent passwd varnish >/dev/null || \ - %_sbindir/useradd -g varnish -s /bin/false -r -c "user for Varnish" \ - -d %pkg_home varnish +%pre -f %{name}.pre %service_add_pre varnish.service varnishlog.service %post @@ -176,6 +175,7 @@ fi %dir %attr(0750,varnish,varnish) %pkg_cachedir %dir %attr(0750,varnish,varnish) %pkg_logdir %_fillupdir/sysconfig.%name +%_sysusersdir/%{name}-user.conf %files -n %library_name %_libdir/libvarnishapi.so.3* From afb54fef80bbadb2c6eb7a507909d282c713588eeb7ac37b061140130f628b22 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Tue, 6 Feb 2024 22:10:52 +0000 Subject: [PATCH 2/3] use sysusers fragment from solanum OBS-URL: https://build.opensuse.org/package/show/server:http/varnish?expand=0&rev=128 --- varnish-user.conf | 2 -- varnish.spec | 15 +++++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) delete mode 100644 varnish-user.conf diff --git a/varnish-user.conf b/varnish-user.conf deleted file mode 100644 index ac67ead..0000000 --- a/varnish-user.conf +++ /dev/null @@ -1,2 +0,0 @@ -#Type Name ID GECOS Home directory Shell -u varnish - "User for Varnish" /var/lib/varnish - diff --git a/varnish.spec b/varnish.spec index 1b356b9..fe12095 100644 --- a/varnish.spec +++ b/varnish.spec @@ -33,7 +33,6 @@ Group: Productivity/Networking/Web/Proxy URL: https://varnish-cache.org/ #Git-Web: https://github.com/varnishcache/varnish-cache Source: https://varnish-cache.org/_downloads/%name-%version.tgz -Source2: %{name}-user.conf Source3: varnish.sysconfig Source5: varnish.logrotate Source7: varnish.service @@ -45,12 +44,13 @@ BuildRequires: ncurses-devel BuildRequires: python3-Sphinx BuildRequires: python3-docutils BuildRequires: readline-devel +BuildRequires: systemd-rpm-macros BuildRequires: sysuser-tools BuildRequires: xz BuildRequires: pkgconfig(libpcre2-8) Requires: c_compiler +%sysusers_requires Recommends: logrotate -%{?sysusers_requires} %{?systemd_ordering} %description @@ -95,7 +95,6 @@ This package holds the development files for varnish. %autosetup -p1 %build -%sysusers_generate_pre %{SOURCE2} %{name} %{name}-user.conf %define _lto_cflags %nil export CFLAGS="%optflags -fcommon -fstack-protector" %ifarch %ix86 @@ -116,7 +115,6 @@ install -dm 0755 "$b"/{%pkg_logdir,%pkg_home} install -Dpm 0644 "%SOURCE5" "$b/%_sysconfdir/logrotate.d/varnish" # ##init scripts -install -Dpm 0644 "%SOURCE2" "$b/%_sysusersdir/%{name}-user.conf" install -Dpm 0644 "%SOURCE3" "$b/%_fillupdir/sysconfig.%name" install -Dpm 0644 "%SOURCE7" "$b/%_unitdir/varnish.service" install -Dpm 0644 "%SOURCE8" "$b/%_unitdir/varnishlog.service" @@ -137,6 +135,11 @@ cp -a doc/changes.rst LICENSE README.rst "$b/%_docdir/%name/" perl -i -pe 's{^#!/usr/bin/env python}{#!/usr/bin/python}g' \ "$b/%_datadir/varnish/vmodtool.py" "$b/%_datadir/varnish/vsctool.py" +mkdir -p "$b/%_sysusersdir" +echo 'u - "user for Varnish" %pkg_home' >system-user-varnish.conf +cp -a system-user-varnish.conf "$b/%_sysusersdir/" +%sysusers_generate_pre system-user-varnish.conf random system-user-varnish.conf + %check if ! %make_build check; then x="$?" @@ -144,7 +147,7 @@ if ! %make_build check; then exit "$x" fi -%pre -f %{name}.pre +%pre -f random.pre %service_add_pre varnish.service varnishlog.service %post @@ -175,7 +178,7 @@ fi %dir %attr(0750,varnish,varnish) %pkg_cachedir %dir %attr(0750,varnish,varnish) %pkg_logdir %_fillupdir/sysconfig.%name -%_sysusersdir/%{name}-user.conf +%_sysusersdir/* %files -n %library_name %_libdir/libvarnishapi.so.3* From 090382cbf59d31bbaa6464cf8ebf3473667ade85eeca9d6409190e61e9b2e092 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Tue, 6 Feb 2024 22:11:08 +0000 Subject: [PATCH 3/3] OBS-URL: https://build.opensuse.org/package/show/server:http/varnish?expand=0&rev=129 --- varnish.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/varnish.spec b/varnish.spec index fe12095..1224219 100644 --- a/varnish.spec +++ b/varnish.spec @@ -136,7 +136,7 @@ perl -i -pe 's{^#!/usr/bin/env python}{#!/usr/bin/python}g' \ "$b/%_datadir/varnish/vmodtool.py" "$b/%_datadir/varnish/vsctool.py" mkdir -p "$b/%_sysusersdir" -echo 'u - "user for Varnish" %pkg_home' >system-user-varnish.conf +echo 'u varnish - "user for Varnish" %pkg_home' >system-user-varnish.conf cp -a system-user-varnish.conf "$b/%_sysusersdir/" %sysusers_generate_pre system-user-varnish.conf random system-user-varnish.conf