1
0
forked from pool/sysuser-tools

Accepting request 504523 from home:kukuk:sysusers

- Put helper script into own subpackage
- Convert sysusers config file to shadow arguments and use
  shadow suite to create user and groups. Fixes [bsc#1041497] and
  serveral dependency loops.

OBS-URL: https://build.opensuse.org/request/show/504523
OBS-URL: https://build.opensuse.org/package/show/Base:System/sysuser-tools?expand=0&rev=7
This commit is contained in:
Thorsten Kukuk 2017-06-19 06:26:55 +00:00 committed by Git OBS Bridge
parent 99f6895172
commit c35174b874
5 changed files with 79 additions and 4 deletions

View File

@ -13,8 +13,8 @@
#
###
# This is for systemctl
%sysusers_requires Requires(pre): systemd
# This is for useradd/usermod/groupadd
%sysusers_requires Requires(pre): shadow sysuser-shadow
%sysusers_generate_pre() \
%{_prefix}/lib/rpm/sysusers-generate-pre "%1" > "%2".pre

View File

@ -1,3 +1,15 @@
-------------------------------------------------------------------
Sun Jun 18 18:07:24 CEST 2017 - kukuk@suse.de
- Put helper script into own subpackage
-------------------------------------------------------------------
Sat Jun 17 09:20:09 CEST 2017 - kukuk@suse.de
- Convert sysusers config file to shadow arguments and use
shadow suite to create user and groups. Fixes [bsc#1041497] and
serveral dependency loops.
-------------------------------------------------------------------
Tue May 30 10:07:45 CEST 2017 - kukuk@suse.de

View File

@ -17,7 +17,7 @@
Name: sysuser-tools
Version: 1.1
Version: 2.0
Release: 0
Summary: Auto provides for system users
License: MIT
@ -26,11 +26,21 @@ Source: sysusers.prov
Source1: sysusers.attr
Source2: sysusers-generate-pre
Source3: macros.sysusers
Source4: sysusers2shadow.sh
BuildArch: noarch
%description
Generate auto provides for system users.
%package -n sysuser-shadow
Summary: Tool to execute sysusers.d with shadow utilities
Group: System/Packages
%description -n sysuser-shadow
This package contians a tool, which expects as input a sysusers.d
configuration file and uses the shadow suite to create the users
and groups from it like systemd-sysusers would do.
%prep
%setup -qcT
@ -41,6 +51,7 @@ 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
install -D -m 755 %{SOURCE4} %{buildroot}%{_sbindir}/sysusers2shadow
%files
%defattr(-,root,root)
@ -49,4 +60,8 @@ install -D -m 644 %{SOURCE3} %{buildroot}%{_sysconfdir}/rpm/macros.sysusers
%{_prefix}/lib/rpm/fileattrs/sysusers.attr
%{_prefix}/lib/rpm/sysusers-generate-pre
%files -n sysuser-shadow
%defattr(-,root,root)
%{_sbindir}/sysusers2shadow
%changelog

View File

@ -18,7 +18,7 @@ done
lines=`wc -l < "$tmpfile"`
echo '#!/bin/bash'
echo "tail -n $lines \$0 | /usr/bin/systemd-sysusers -"
echo "tail -n $lines \$0 | /usr/sbin/sysusers2shadow"
echo "exit 0"
echo '######## data below ########'
cat "$tmpfile"

48
sysusers2shadow.sh Normal file
View File

@ -0,0 +1,48 @@
#!/bin/bash
while read LINE
do
case "$LINE" in
\#*|"")
;;
g*)
eval arr=( $LINE )
ARGUMENTS="${arr[1]}"
if [ ! -z "${arr[2]}" -a "${arr[2]}" != "-" ]; then
ARGUMENTS="-g ${arr[2]} $ARGUMENTS"
fi
echo "groupadd -r $ARGUMENTS"
/usr/bin/getent group "${arr[1]}" >> /dev/null || /usr/sbin/groupadd -r $ARGUMENTS
;;
u*)
eval arr=( $LINE )
ARGUMENTS="${arr[1]}"
if [ ! -z "${arr[2]}" -a "${arr[2]}" != "-" ]; then
ARGUMENTS="-u ${arr[2]} $ARGUMENTS"
fi
if [ ! -z "${arr[4]}" -a "${arr[4]}" != "-" ]; then
ARGUMENTS="-d ${arr[4]} $ARGUMENTS"
fi
/usr/bin/getent group ${arr[1]} >> /dev/null
if [ $? -eq 0 ]; then
ARGUMENTS="-g ${arr[1]} $ARGUMENTS"
else
ARGUMENTS="-U $ARGUMENTS"
fi
echo "useradd -r -s /sbin/nologin -c \"${arr[3]}\" $ARGUMENTS"
/usr/bin/getent passwd ${arr[1]} >> /dev/null || /usr/sbin/useradd -r -s /sbin/nologin -c "${arr[3]}" $ARGUMENTS
;;
m*)
eval arr=( $LINE )
echo "usermod -a -G ${arr[2]} ${arr[1]}"
/usr/sbin/usermod -a -G ${arr[2]} ${arr[1]}
;;
r*)
echo "range option ignored: \"$LINE\""
;;
*)
echo "Syntax Error: \"$LINE\""
exit 1
;;
esac
done