shadow/useradd-script.patch
Michael Vetter 3317029e04 Accepting request 912915 from home:jubalh:branches:Base:System
- Update to 4.9:
  * Updated translations
  * Major salt updates
  * Various coverity and cleanup fixes
  * Consistently use 0 to disable PASS_MIN_DAYS in man
  * Implement NSS support for subids and a libsubid
  * setfcap: retain setfcap when mapping uid 0
  * login.defs: include HMAC_CRYPTO_ALGO key
  * selinux fixes
  * Fix path prefix path handling
  * Manpage updates
  * Treat an empty passwd field as invalid(Haelwenn Monnier)
  * newxidmap: allow running under alternative gid
  * usermod: check that shell is executable
  * Add yescript support
  * useradd memleak fixes
  * useradd: use built-in settings by default
  * getdefs: add foreign
  * buffer overflow fixes
  * Adding run-parts style for pre and post useradd/del
- Refresh:
  * shadow-login_defs-unused-by-pam.patch
  * userdel-script.patch
  * useradd-script.patch
  * chkname-regex.patch
  * useradd-default.patch: bbf4b79 stopped shipping default file.
    change group in code now.
  * shadow-login_defs-suse.patch
  * useradd-userkeleton.patch
- Remove because upstreamed:

OBS-URL: https://build.opensuse.org/request/show/912915
OBS-URL: https://build.opensuse.org/package/show/Base:System/shadow?expand=0&rev=106
2021-08-18 14:25:29 +00:00

95 lines
2.6 KiB
Diff

---
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
@@ -266,6 +266,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
@@ -149,6 +149,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
@@ -2398,6 +2398,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)
@@ -2691,6 +2729,7 @@ int main (int argc, char **argv)
nscd_flush_cache ("group");
sssd_flush_cache (SSSD_DB_PASSWD | SSSD_DB_GROUP);
+ call_script (user_name, user_id, user_gid, user_home);
+
return E_SUCCESS;
}
-