commit 20ab9219b9a9422a04d1763ce5d7f027b0741900f67620a30bd6cc26e4172759 Author: Ludwig Nussel Date: Thu Feb 16 15:08:58 2017 +0000 Accepting request 457437 from home:kukuk:sysusers Initial tool package for the new system user proposal OBS-URL: https://build.opensuse.org/request/show/457437 OBS-URL: https://build.opensuse.org/package/show/Base:System/sysuser-tools?expand=0&rev=1 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9b03811 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,23 @@ +## Default LFS +*.7z filter=lfs diff=lfs merge=lfs -text +*.bsp filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.gem filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.jar filter=lfs diff=lfs merge=lfs -text +*.lz filter=lfs diff=lfs merge=lfs -text +*.lzma filter=lfs diff=lfs merge=lfs -text +*.obscpio filter=lfs diff=lfs merge=lfs -text +*.oxt filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.rpm filter=lfs diff=lfs merge=lfs -text +*.tbz filter=lfs diff=lfs merge=lfs -text +*.tbz2 filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.txz filter=lfs diff=lfs merge=lfs -text +*.whl filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..57affb6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.osc diff --git a/macros.sysusers b/macros.sysusers new file mode 100644 index 0000000..eacbcf1 --- /dev/null +++ b/macros.sysusers @@ -0,0 +1,20 @@ +# -*- Mode: makefile; indent-tabs-mode: t -*- */ +# RPM macros for packages creating system accounts +# +### +# +# When a package creates a system account, it should use the following macros: +# +# add %sysusers_requires in the package section +# +# add "%sysusers_generate_pre " to build section +# +# add "%pre -f .pre" to spec file +# +### + +# This is for systemctl +%sysusers_requires Requires(pre): systemd + +%sysusers_generate_pre() \ +%{_prefix}/lib/rpm/sysusers-generate-pre "%1" > "%2".pre diff --git a/sysuser-tools.changes b/sysuser-tools.changes new file mode 100644 index 0000000..571fde9 --- /dev/null +++ b/sysuser-tools.changes @@ -0,0 +1,10 @@ +------------------------------------------------------------------- +Fri Jan 20 13:04:51 CET 2017 - kukuk@suse.de + +- Add macros.sysusers + +------------------------------------------------------------------- +Wed Dec 21 16:09:05 UTC 2016 - lnussel@suse.de + +- initial package + diff --git a/sysuser-tools.spec b/sysuser-tools.spec new file mode 100644 index 0000000..ab20bd8 --- /dev/null +++ b/sysuser-tools.spec @@ -0,0 +1,52 @@ +# +# spec file for package sysuser-tools +# +# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. +# +# All modifications and additions to the file contributed by third parties +# remain the property of their copyright owners, unless otherwise agreed +# upon. The license for this file, and modifications and additions to the +# file, is the same license as for the pristine package itself (unless the +# license for the pristine package is not an Open Source License, in which +# case the license is the MIT License). An "Open Source License" is a +# license that conforms to the Open Source Definition (Version 1.9) +# published by the Open Source Initiative. + +# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# + + +Name: sysuser-tools +Version: 1.1 +Release: 0 +Summary: Auto provides for system users +License: MIT +Group: System/Packages +Source: sysusers.prov +Source1: sysusers.attr +Source2: sysusers-generate-pre +Source3: macros.sysusers +BuildArch: noarch + +%description +Generate auto provides for system users. + +%prep +%setup -qcT + +%build + +%install +install -D -m 755 %{SOURCE0} %{buildroot}%{_prefix}/lib/rpm/sysusers.prov +install -D -m 644 %{SOURCE1} %{buildroot}%{_prefix}/lib/rpm/fileattrs/sysusers.attr +install -D -m 755 %{SOURCE2} %{buildroot}%{_prefix}/lib/rpm/sysusers-generate-pre +install -D -m 644 %{SOURCE3} %{buildroot}%{_sysconfdir}/rpm/macros.sysusers + +%files +%defattr(-,root,root) +%{_sysconfdir}/rpm/macros.sysusers +%{_prefix}/lib/rpm/sysusers.prov +%{_prefix}/lib/rpm/fileattrs/sysusers.attr +%{_prefix}/lib/rpm/sysusers-generate-pre + +%changelog diff --git a/sysusers-generate-pre b/sysusers-generate-pre new file mode 100644 index 0000000..a75a529 --- /dev/null +++ b/sysusers-generate-pre @@ -0,0 +1,24 @@ +#!/bin/bash +# pass systemd sysusers config files a as argument to this script. +# It will output a shell script that creates those users by +# appending the data to itself. + +tmpfile=`mktemp -q -t sysusers.XXXXXX` +cleanup() +{ + rm -f "$tmpfile" +} + +trap cleanup EXIT + +for i in "$@"; do + grep -e '^[ug]' "$i" >> "$tmpfile" +done + +lines=`wc -l < "$tmpfile"` + +echo '#!/bin/bash' +echo "tail -n $lines \$0 | /usr/bin/systemd-sysusers - || :" +echo "exit 0" +echo '######## data below ########' +cat "$tmpfile" diff --git a/sysusers.attr b/sysusers.attr new file mode 100644 index 0000000..c3c7e3a --- /dev/null +++ b/sysusers.attr @@ -0,0 +1,2 @@ +%__sysusers_provides %{_rpmconfigdir}/sysusers.prov +%__sysusers_path ^%{_prefix}/lib/sysusers.d/.*\\.conf$ diff --git a/sysusers.prov b/sysusers.prov new file mode 100644 index 0000000..88c8bb0 --- /dev/null +++ b/sysusers.prov @@ -0,0 +1,20 @@ +#!/bin/bash + +parse() +{ + while read line; do + [ "${line:0:1}" != '#' ] || continue + line="${line## *}" + [ -n "$line" ] || continue + set -- $line + if [ "$1" = 'g' ]; then + echo "group($2)" + elif [ "$1" = 'u' ]; then + echo "user($2)" + fi + done +} + +while read fn; do + parse < "$fn" +done