SHA256
3
0
forked from pool/shadow

Accepting request 1065945 from home:lnussel:branches:Base:System

- remove scripts that claim to be config but are in /usr (boo#1191578)

OBS-URL: https://build.opensuse.org/request/show/1065945
OBS-URL: https://build.opensuse.org/package/show/Base:System/shadow?expand=0&rev=139
This commit is contained in:
Michael Vetter 2023-02-16 09:21:12 +00:00 committed by Git OBS Bridge
parent 4c6bdfaa5d
commit e2af94b0ed
6 changed files with 5 additions and 220 deletions

View File

@ -1,3 +1,8 @@
-------------------------------------------------------------------
Wed Feb 15 10:49:33 UTC 2023 - Ludwig Nussel <lnussel@suse.de>
- remove scripts that claim to be config but are in /usr (boo#1191578)
-------------------------------------------------------------------
Fri Jan 13 08:21:46 UTC 2023 - Michael Vetter <mvetter@suse.com>

View File

@ -30,9 +30,6 @@ Group: System/Base
URL: https://github.com/shadow-maint/shadow
Source: https://github.com/shadow-maint/shadow/releases/download/%{version}/shadow-%{version}.tar.xz
Source1: pamd.tar.bz2
Source3: useradd.local
Source4: userdel-pre.local
Source5: userdel-post.local
Source6: shadow.service
Source7: shadow.timer
Source42: https://github.com/shadow-maint/shadow/releases/download/%{version}/shadow-%{version}.tar.xz.asc
@ -41,10 +38,6 @@ Source43: %{name}.keyring
Source44: shadow-login_defs-check.sh
# PATCH-FIX-SUSE shadow-login_defs-unused-by-pam.patch kukuk@suse.com -- Remove variables that have no use with PAM.
Patch0: shadow-login_defs-unused-by-pam.patch
# PATCH-FEATURE-SUSE userdel-script.patch kukuk@suse.com -- Add support for USERDEL_PRECMD and USERDEL_POSTCMD.
Patch1: userdel-script.patch
# PATCH-FEATURE-SUSE useradd-script.patch kukuk@suse.com -- Add support for USERADD_CMD.
Patch2: useradd-script.patch
# PATCH-FEATURE-SUSE useradd-default.patch kukuk@suse.com -- Change useradd defaults group to 1000.
Patch3: useradd-default.patch
# PATCH-FEATURE-SUSE shadow-util-linux.patch sbrabec@suse.com -- Add support for util-linux specific variables, delete shadow login, su runuser specific.
@ -120,8 +113,6 @@ Development files for libsubid4.
%prep
%setup -q -a 1
%patch0
%patch1
%patch2
%patch3
%patch4
%patch5
@ -162,10 +153,6 @@ autoreconf -fvi
# Separate call to install man pages. See https://github.com/shadow-maint/shadow/issues/389
%make_install -C man install-man
# install useradd.local, userdel.local, ...
install -m 0755 %{SOURCE3} %{buildroot}/%{_sbindir}/
install -m 0755 %{SOURCE4} %{buildroot}/%{_sbindir}/
install -m 0755 %{SOURCE5} %{buildroot}/%{_sbindir}/
install -Dm644 %{SOURCE6} %{buildroot}%{_unitdir}/shadow.service
install -Dm644 %{SOURCE7} %{buildroot}%{_unitdir}/shadow.timer
@ -356,9 +343,6 @@ test -f %{_sysconfdir}/login.defs.rpmsave && mv -v %{_sysconfdir}/login.defs.rpm
%attr(0755,root,root) %{_sbindir}/newusers
%{_sbindir}/vipw
%{_sbindir}/vigr
%verify(not md5 size mtime) %config(noreplace) %{_sbindir}/useradd.local
%verify(not md5 size mtime) %config(noreplace) %{_sbindir}/userdel-pre.local
%verify(not md5 size mtime) %config(noreplace) %{_sbindir}/userdel-post.local
%{_mandir}/man1/chage.1%{?ext_man}
%{_mandir}/man1/chfn.1%{?ext_man}
%{_mandir}/man1/chsh.1%{?ext_man}

View File

@ -1,94 +0,0 @@
---
etc/login.defs | 7 +++++++
lib/getdef.c | 1 +
src/useradd.c | 41 ++++++++++++++++++++++++++++++++++++++++-
3 files changed, 48 insertions(+), 1 deletion(-)
Index: etc/login.defs
===================================================================
--- etc/login.defs.orig
+++ etc/login.defs
@@ -238,6 +238,13 @@ DEFAULT_HOME yes
NONEXISTENT /nonexistent
#
+# If defined, this command is run when adding a user.
+# It should rebuild any NIS database etc. to add the
+# new created account.
+#
+USERADD_CMD /usr/sbin/useradd.local
+
+#
# If defined, this command is run when removing a user.
# It should remove any at/cron/print jobs etc. owned by
# the user to be removed (passed as the first argument).
Index: lib/getdef.c
===================================================================
--- lib/getdef.c.orig
+++ lib/getdef.c
@@ -127,6 +127,7 @@ static struct itemdef def_table[] = {
{"UID_MAX", NULL},
{"UID_MIN", NULL},
{"UMASK", NULL},
+ {"USERADD_CMD", NULL},
{"USERDEL_CMD", NULL},
{"USERDEL_PRECMD", NULL},
{"USERDEL_POSTCMD", NULL},
Index: src/useradd.c
===================================================================
--- src/useradd.c.orig
+++ src/useradd.c
@@ -2426,6 +2426,44 @@ static void check_uid_range(int rflg, ui
}
/*
+ * call_script - call a script to do some work
+ *
+ * call_script calls a script for additional changes to the
+ * account.
+ */
+
+static void call_script (const char *user, const uid_t uid, const gid_t gid, const char *home)
+{
+ const char *cmd;
+ const char *argv[6];
+ char *strgid, *struid;
+ int status;
+
+ cmd = getdef_str ("USERADD_CMD");
+ if (NULL == cmd) {
+ return;
+ }
+ if (asprintf(&struid, "%lu", (long unsigned)uid) < 0) {
+ (void) fprintf (stderr, _("%s: out of memory\n"), Prog);
+ exit(1);
+ }
+ if (asprintf(&strgid, "%lu", (long unsigned)gid) < 0) {
+ (void) fprintf (stderr, _("%s: out of memory\n"), Prog);
+ exit(1);
+ }
+ argv[0] = cmd;
+ argv[1] = user;
+ argv[2] = struid;
+ argv[3] = strgid;
+ argv[4] = home;
+ argv[5] = (char *)0;
+ (void) run_command (cmd, argv, NULL, &status);
+ free(strgid);
+ free(struid);
+}
+
+
+/*
* main - useradd command
*/
int main (int argc, char **argv)
@@ -2720,6 +2758,7 @@ int main (int argc, char **argv)
exit(1);
}
+ call_script (user_name, user_id, user_gid, user_home);
+
return E_SUCCESS;
}
-

View File

@ -1,49 +0,0 @@
#!/bin/sh
#
# Here you can add your own stuff, that should be done for every user who
# was new created.
#
# When you create a user with useradd, this script will be called
# with the login name as parameter. Optional, UID, GID and the HOME
# directory are added.
#
case "$1" in
--help|--version)
echo Usage: $0 username [uid gid home]
exit 0
;;
esac
# Check for the required argument.
if [ $# -lt 1 -o $# -gt 4 ]; then
echo Usage: $0 username [uid gid home]
exit 1
fi
USER=$1
if [ $# -eq 4 ]; then
GID=$3
HOMEDIR=$4
else
GID=$(id -g $USER)
HOMEDIR=$(grep -E "^${USER}:" /etc/passwd| cut -d: -f6,6)
fi
# Update NIS database
# make -C /var/yp
# Main useradd tool creates this if specified on command line
[ -d $HOMEDIR ] || exit 0
# If SELinux is enabled, we have to run restorecon to assign
# appropriate fcontexts to the respective $HOME and files under it
if [ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled ; then
test -x /sbin/restorecon || exit 2
/sbin/restorecon -R $HOMEDIR
fi
# All done.
exit 0

View File

@ -1,29 +0,0 @@
#!/bin/sh
#
# Here you can add your own stuff, that should be done for every user
# which we deleted.
#
# If you delete a user with userdel, this script will be called
# with the login name as parameter after the account and optional
# home directory was removed from the system.
#
case "$1" in
--help|--version)
echo Usage: $0 username uid gid home
exit 0
;;
esac
# Check for the required argument.
if [ $# != 1 ]; then
echo Usage: $0 username
exit 1
fi
# Rebuild NIS database to remove the account from it.
# make -C /var/yp
# All done.
exit 0

View File

@ -1,32 +0,0 @@
#!/bin/sh
#
# Here you can add your own stuff, that should be done for every user
# who will be deleted.
#
# When you delete a user with userdel, this script will be called
# with the login name as parameter before any other action is done.
#
case "$1" in
--help|--version)
echo Usage: $0 username uid gid home
exit 0
;;
esac
# Check for the required argument.
if [ $# != 1 ]; then
echo Usage: $0 username
exit 1
fi
# Remove cron jobs
test -x /usr/bin/crontab && /usr/bin/crontab -r -u $1
# Stop systemd user jobs, even this requires --force
id=$(id -u $1)
systemctl stop user@${id}.service > /dev/null 2>&1 &
# All done.
exit 0