Add support for /usr/etc/skel to useradd binary its self
OBS-URL: https://build.opensuse.org/package/show/Base:System/shadow?expand=0&rev=97
This commit is contained in:
parent
5d3b7a8e02
commit
cf082dac01
@ -1,3 +1,10 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Wed Nov 11 11:28:09 UTC 2020 - Dr. Werner Fink <werner@suse.de>
|
||||||
|
|
||||||
|
- Add patch useradd-userkeleton.patch to extend original C code
|
||||||
|
of useradd to handle /usr/etc/skel (boo#1173321)
|
||||||
|
- Remove /usr/etc/skel support in useradd.local script
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Mon Nov 2 15:54:02 UTC 2020 - Dr. Werner Fink <werner@suse.de>
|
Mon Nov 2 15:54:02 UTC 2020 - Dr. Werner Fink <werner@suse.de>
|
||||||
|
|
||||||
|
@ -61,6 +61,8 @@ Patch7: shadow-4.1.5.1-logmsg.patch
|
|||||||
Patch13: shadow-login_defs-comments.patch
|
Patch13: shadow-login_defs-comments.patch
|
||||||
# PATCH-FEATURE-SUSE shadow-login_defs-suse.patch kukuk@suse.com -- Customize login.defs.
|
# PATCH-FEATURE-SUSE shadow-login_defs-suse.patch kukuk@suse.com -- Customize login.defs.
|
||||||
Patch14: shadow-login_defs-suse.patch
|
Patch14: shadow-login_defs-suse.patch
|
||||||
|
# PATCH-FEATURE-SUSE Copy also skeleton files from /usr/etc/skel (boo#1173321)
|
||||||
|
Patch15: useradd-userkeleton.patch
|
||||||
# PATCH-FIX-SUSE disable_new_audit_function.patch adam.majer@suse.de -- Disable newer libaudit functionality for older distributions.
|
# PATCH-FIX-SUSE disable_new_audit_function.patch adam.majer@suse.de -- Disable newer libaudit functionality for older distributions.
|
||||||
Patch20: disable_new_audit_function.patch
|
Patch20: disable_new_audit_function.patch
|
||||||
BuildRequires: audit-devel > 2.3
|
BuildRequires: audit-devel > 2.3
|
||||||
@ -106,6 +108,7 @@ group accounts.
|
|||||||
%patch7
|
%patch7
|
||||||
%patch13
|
%patch13
|
||||||
%patch14
|
%patch14
|
||||||
|
%patch15
|
||||||
%if 0%{?suse_version} < 1330
|
%if 0%{?suse_version} < 1330
|
||||||
%patch20 -p1
|
%patch20 -p1
|
||||||
%endif
|
%endif
|
||||||
|
117
useradd-userkeleton.patch
Normal file
117
useradd-userkeleton.patch
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
Copy also skeleton files from /usr/etc/skel (boo#1173321)
|
||||||
|
|
||||||
|
---
|
||||||
|
etc/useradd | 1 +
|
||||||
|
src/useradd.c | 37 +++++++++++++++++++++++++++++++++++++
|
||||||
|
2 files changed, 38 insertions(+)
|
||||||
|
|
||||||
|
--- etc/useradd
|
||||||
|
+++ etc/useradd 2020-11-11 11:33:32.809513584 +0000
|
||||||
|
@@ -5,4 +5,5 @@ INACTIVE=-1
|
||||||
|
EXPIRE=
|
||||||
|
SHELL=/bin/bash
|
||||||
|
SKEL=/etc/skel
|
||||||
|
+USRSKEL=/usr/etc/skel
|
||||||
|
CREATE_MAIL_SPOOL=yes
|
||||||
|
--- src/useradd.c
|
||||||
|
+++ src/useradd.c 2020-11-11 11:15:42.922067931 +0000
|
||||||
|
@@ -78,6 +78,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"
|
||||||
|
@@ -101,6 +104,7 @@ static const char *def_gname = "other";
|
||||||
|
static const char *def_home = "/home";
|
||||||
|
static const char *def_shell = "";
|
||||||
|
static const char *def_template = SKEL_DIR;
|
||||||
|
+static const char *def_usrtemplate = USRSKELDIR;
|
||||||
|
static const char *def_create_mail_spool = "no";
|
||||||
|
|
||||||
|
static long def_inactive = -1;
|
||||||
|
@@ -202,6 +206,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 */
|
||||||
|
@@ -469,6 +474,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)) {
|
||||||
|
@@ -500,6 +528,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);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -526,6 +555,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;
|
||||||
|
@@ -620,6 +650,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,
|
||||||
|
@@ -649,6 +682,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);
|
||||||
|
@@ -2505,6 +2540,8 @@ int main (int argc, char **argv)
|
||||||
|
if (mflg) {
|
||||||
|
create_home ();
|
||||||
|
if (home_added) {
|
||||||
|
+ copy_tree (def_usrtemplate, prefix_user_home, false, false,
|
||||||
|
+ (uid_t)-1, user_id, (gid_t)-1, user_gid);
|
||||||
|
copy_tree (def_template, prefix_user_home, false, false,
|
||||||
|
(uid_t)-1, user_id, (gid_t)-1, user_gid);
|
||||||
|
} else {
|
@ -37,20 +37,6 @@ fi
|
|||||||
# Main useradd tool creates this if specified on command line
|
# Main useradd tool creates this if specified on command line
|
||||||
[ -d $HOMEDIR ] || exit 0
|
[ -d $HOMEDIR ] || exit 0
|
||||||
|
|
||||||
#
|
|
||||||
# Copy also skeleton files from /usr/etc/skel (boo#1173321)
|
|
||||||
#
|
|
||||||
USRSKELDIR=/usr/etc/skel
|
|
||||||
if [ -d $USRSKELDIR ] ; then
|
|
||||||
for file in $(ls -A $USRSKELDIR); do
|
|
||||||
# Only copy if not exist yet, i.e. does *not* exist in /etc/skel, which is still
|
|
||||||
# being preferred ...
|
|
||||||
test -e $HOMEDIR/$file && continue
|
|
||||||
cp -a $USRSKELDIR/$file $HOMEDIR
|
|
||||||
chown -R $USER.$GID $HOMEDIR/$file
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
# If SELinux is enabled, we have to run restorecon to assign
|
# If SELinux is enabled, we have to run restorecon to assign
|
||||||
# appropriate fcontexts to the respective $HOME and files under it
|
# appropriate fcontexts to the respective $HOME and files under it
|
||||||
if [ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled ; then
|
if [ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled ; then
|
||||||
|
Loading…
Reference in New Issue
Block a user