]> code.ossystems Code Review - openembedded-core.git/commitdiff
shadow: Make useradd work correctly with --root again
authorPeter Kjellerstedt <peter.kjellerstedt@axis.com>
Fri, 12 Sep 2014 15:05:00 +0000 (17:05 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 16 Sep 2014 21:12:29 +0000 (22:12 +0100)
Even if useradd --root <root> is used it would still read login.defs
before doing the chroot() and thus use the one provided by the host
rather than the sysroot.

(From OE-Core rev: b85917a4ebe636316fa7305017cd32a47b392039)

Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-extended/shadow/files/0001-Do-not-read-login.defs-before-doing-chroot.patch [new file with mode: 0644]
meta/recipes-extended/shadow/shadow.inc

diff --git a/meta/recipes-extended/shadow/files/0001-Do-not-read-login.defs-before-doing-chroot.patch b/meta/recipes-extended/shadow/files/0001-Do-not-read-login.defs-before-doing-chroot.patch
new file mode 100644 (file)
index 0000000..828b95a
--- /dev/null
@@ -0,0 +1,46 @@
+From 170c25c8e0b5c3dc2615d1db94c8d24a13ff99bf Mon Sep 17 00:00:00 2001
+From: Peter Kjellerstedt <pkj@axis.com>
+Date: Thu, 11 Sep 2014 15:11:23 +0200
+Subject: [PATCH] Do not read login.defs before doing chroot()
+
+If "useradd --root <root> ..." was used, the login.defs file would still
+be read from /etc/login.defs instead of <root>/etc/login.defs. This was
+due to getdef_ulong() being called before process_root_flag().
+
+Upstream-Status: Submitted [http://lists.alioth.debian.org/pipermail/pkg-shadow-devel/2014-September/010446.html]
+
+Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
+---
+ src/useradd.c | 8 ++++++--
+ 1 file changed, 6 insertions(+), 2 deletions(-)
+
+diff --git a/src/useradd.c b/src/useradd.c
+index a8a1f76..e1ebf50 100644
+--- a/src/useradd.c
++++ b/src/useradd.c
+@@ -1993,9 +1993,11 @@ int main (int argc, char **argv)
+ #endif                                /* USE_PAM */
+ #endif                                /* ACCT_TOOLS_SETUID */
++#ifdef ENABLE_SUBIDS
+       /* Needed for userns check */
+-      uid_t uid_min = (uid_t) getdef_ulong ("UID_MIN", 1000UL);
+-      uid_t uid_max = (uid_t) getdef_ulong ("UID_MAX", 60000UL);
++      uid_t uid_min;
++      uid_t uid_max;
++#endif
+       /*
+        * Get my name so that I can use it to report errors.
+@@ -2026,6 +2028,8 @@ int main (int argc, char **argv)
+       is_shadow_grp = sgr_file_present ();
+ #endif
+ #ifdef ENABLE_SUBIDS
++      uid_min = (uid_t) getdef_ulong ("UID_MIN", 1000UL);
++      uid_max = (uid_t) getdef_ulong ("UID_MAX", 60000UL);
+       is_sub_uid = sub_uid_file_present () && !rflg &&
+           (!user_id || (user_id <= uid_max && user_id >= uid_min));
+       is_sub_gid = sub_gid_file_present () && !rflg &&
+-- 
+1.9.0
+
index 84d1f864b7ee9d89ab20e90d7f547ae9cc13cffb..6a769dfc5cbc4467e35a1e0c0e9f7ae6fbc08df6 100644 (file)
@@ -15,6 +15,7 @@ SRC_URI = "http://pkg-shadow.alioth.debian.org/releases/${BPN}-${PV}.tar.xz \
            file://usermod-fix-compilation-failure-with-subids-disabled.patch \
            file://fix-installation-failure-with-subids-disabled.patch \
            file://0001-su.c-fix-to-exec-command-correctly.patch \
+           file://0001-Do-not-read-login.defs-before-doing-chroot.patch \
            ${@bb.utils.contains('PACKAGECONFIG', 'pam', '${PAM_SRC_URI}', '', d)} \
            "