3317029e04
- 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
156 lines
4.7 KiB
Diff
156 lines
4.7 KiB
Diff
Copy also skeleton files from /usr/etc/skel (boo#1173321)
|
|
|
|
---
|
|
etc/useradd | 1 +
|
|
src/useradd.c | 37 +++++++++++++++++++++++++++++++++++++
|
|
2 files changed, 38 insertions(+)
|
|
|
|
Index: src/useradd.c
|
|
===================================================================
|
|
--- src/useradd.c.orig
|
|
+++ src/useradd.c
|
|
@@ -82,6 +82,9 @@
|
|
#ifndef SKEL_DIR
|
|
#define SKEL_DIR "/etc/skel"
|
|
#endif
|
|
+#ifndef USRSKELDIR
|
|
+#define USRSKELDIR "/usr/etc/skel"
|
|
+#endif
|
|
#ifndef USER_DEFAULTS_FILE
|
|
#define USER_DEFAULTS_FILE "/etc/default/useradd"
|
|
#define NEW_USER_FILE "/etc/default/nuaddXXXXXX"
|
|
@@ -106,6 +109,7 @@ static const char *def_gname = "other";
|
|
static const char *def_home = "/home";
|
|
static const char *def_shell = "/bin/bash";
|
|
static const char *def_template = SKEL_DIR;
|
|
+static const char *def_usrtemplate = USRSKELDIR;
|
|
static const char *def_create_mail_spool = "yes";
|
|
|
|
static long def_inactive = -1;
|
|
@@ -208,6 +212,7 @@ static bool home_added = false;
|
|
#define DINACT "INACTIVE="
|
|
#define DEXPIRE "EXPIRE="
|
|
#define DSKEL "SKEL="
|
|
+#define DUSRSKEL "USRSKEL="
|
|
#define DCREATE_MAIL_SPOOL "CREATE_MAIL_SPOOL="
|
|
|
|
/* local function prototypes */
|
|
@@ -481,6 +486,29 @@ static void get_defaults (void)
|
|
}
|
|
|
|
/*
|
|
+ * Default Usr Skeleton information
|
|
+ */
|
|
+ else if (MATCH (buf, DUSRSKEL)) {
|
|
+ if ('\0' == *cp) {
|
|
+ cp = USRSKELDIR; /* XXX warning: const */
|
|
+ }
|
|
+
|
|
+ if(prefix[0]) {
|
|
+ size_t len;
|
|
+ int wlen;
|
|
+ char* _def_usrtemplate; /* avoid const warning */
|
|
+
|
|
+ len = strlen(prefix) + strlen(cp) + 2;
|
|
+ _def_usrtemplate = xmalloc(len);
|
|
+ wlen = snprintf(_def_usrtemplate, len, "%s/%s", prefix, cp);
|
|
+ assert (wlen == (int) len -1);
|
|
+ def_usrtemplate = _def_usrtemplate;
|
|
+ }
|
|
+ else {
|
|
+ def_usrtemplate = xstrdup (cp);
|
|
+ }
|
|
+ }
|
|
+ /*
|
|
* Create by default user mail spool or not ?
|
|
*/
|
|
else if (MATCH (buf, DCREATE_MAIL_SPOOL)) {
|
|
@@ -512,6 +540,7 @@ static void show_defaults (void)
|
|
printf ("EXPIRE=%s\n", def_expire);
|
|
printf ("SHELL=%s\n", def_shell);
|
|
printf ("SKEL=%s\n", def_template);
|
|
+ printf ("USRSKEL=%s\n", def_usrtemplate);
|
|
printf ("CREATE_MAIL_SPOOL=%s\n", def_create_mail_spool);
|
|
}
|
|
|
|
@@ -538,6 +567,7 @@ static int set_defaults (void)
|
|
bool out_expire = false;
|
|
bool out_shell = false;
|
|
bool out_skel = false;
|
|
+ bool out_usrskel = false;
|
|
bool out_create_mail_spool = false;
|
|
size_t len;
|
|
int ret = -1;
|
|
@@ -632,6 +662,9 @@ static int set_defaults (void)
|
|
} else if (!out_skel && MATCH (buf, DSKEL)) {
|
|
fprintf (ofp, DSKEL "%s\n", def_template);
|
|
out_skel = true;
|
|
+ } else if (!out_usrskel && MATCH (buf, DUSRSKEL)) {
|
|
+ fprintf (ofp, DUSRSKEL "%s\n", def_usrtemplate);
|
|
+ out_usrskel = true;
|
|
} else if (!out_create_mail_spool
|
|
&& MATCH (buf, DCREATE_MAIL_SPOOL)) {
|
|
fprintf (ofp,
|
|
@@ -661,6 +694,8 @@ static int set_defaults (void)
|
|
fprintf (ofp, DSHELL "%s\n", def_shell);
|
|
if (!out_skel)
|
|
fprintf (ofp, DSKEL "%s\n", def_template);
|
|
+ if (!out_usrskel)
|
|
+ fprintf (ofp, DUSRSKEL "%s\n", def_usrtemplate);
|
|
|
|
if (!out_create_mail_spool)
|
|
fprintf (ofp, DCREATE_MAIL_SPOOL "%s\n", def_create_mail_spool);
|
|
@@ -2679,6 +2714,8 @@ int main (int argc, char **argv)
|
|
if (home_added) {
|
|
copy_tree (def_template, prefix_user_home, false, false,
|
|
(uid_t)-1, user_id, (gid_t)-1, user_gid);
|
|
+ copy_tree (def_usrtemplate, prefix_user_home, false, false,
|
|
+ (uid_t)-1, user_id, (gid_t)-1, user_gid);
|
|
} else {
|
|
fprintf (stderr,
|
|
_("%s: warning: the home directory %s already exists.\n"
|
|
Index: libmisc/copydir.c
|
|
===================================================================
|
|
--- libmisc/copydir.c.orig
|
|
+++ libmisc/copydir.c
|
|
@@ -416,6 +416,14 @@ static int copy_entry (const char *src,
|
|
old_uid, new_uid, old_gid, new_gid);
|
|
}
|
|
|
|
+ /*
|
|
+ * If the destination already exists do nothing.
|
|
+ * This is after the copy_dir above to still iterate into subdirectories.
|
|
+ */
|
|
+ if (LSTAT (dst, &sb) != -1) {
|
|
+ return 0;
|
|
+ }
|
|
+
|
|
#ifdef S_IFLNK
|
|
/*
|
|
* Copy any symbolic links
|
|
@@ -477,6 +485,7 @@ static int copy_dir (const char *src, co
|
|
gid_t old_gid, gid_t new_gid)
|
|
{
|
|
int err = 0;
|
|
+ struct stat dst_sb;
|
|
|
|
/*
|
|
* Create a new target directory, make it owned by
|
|
@@ -488,6 +497,16 @@ static int copy_dir (const char *src, co
|
|
return -1;
|
|
}
|
|
#endif /* WITH_SELINUX */
|
|
+
|
|
+ /*
|
|
+ * If the destination is already a directory, don't change it
|
|
+ * but copy into it (recursively).
|
|
+ */
|
|
+ if (LSTAT (dst, &dst_sb) == 0 && S_ISDIR(dst_sb.st_mode)) {
|
|
+ return (copy_tree (src, dst, false, reset_selinux,
|
|
+ old_uid, new_uid, old_gid, new_gid) != 0);
|
|
+ }
|
|
+
|
|
if ( (mkdir (dst, statp->st_mode) != 0)
|
|
|| (chown_if_needed (dst, statp,
|
|
old_uid, new_uid, old_gid, new_gid) != 0)
|