1
0
forked from pool/sysuser-tools
Dominique Leuenberger 2017-06-23 07:13:54 +00:00 committed by Git OBS Bridge
commit ccbb8631ff
5 changed files with 93 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,25 @@
-------------------------------------------------------------------
Mon Jun 19 14:07:51 CEST 2017 - kukuk@suse.de
- sysuser-tools needs to require sysuser-shadow
-------------------------------------------------------------------
Mon Jun 19 13:48:34 CEST 2017 - kukuk@suse.de
- Add requires for shadow to sysuser-shadow
-------------------------------------------------------------------
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,25 @@ Source: sysusers.prov
Source1: sysusers.attr
Source2: sysusers-generate-pre
Source3: macros.sysusers
Source4: sysusers2shadow.sh
BuildArch: noarch
Requires: sysuser-shadow
#!BuildIgnore: sysuser-shadow
#!BuildIgnore: sysuser-tools
%description
Generate auto provides for system users.
%package -n sysuser-shadow
Summary: Tool to execute sysusers.d with shadow utilities
Group: System/Packages
Requires: shadow
%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 +55,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 +64,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