diff --git a/NEWS b/NEWS index 786d11a4b..73f0ccb2e 100644 --- a/NEWS +++ b/NEWS @@ -15,9 +15,9 @@ GNU coreutils NEWS -*- outline -*- when only a partial context is specified. [bug introduced with the chcon program in coreutils-6.9.90] - 'chroot --userspec=USER' now uses the primary group of USER as looked up - inside the chroot. Previously the group looked up outside the chroot - was used, even when the look-up inside the chroot succeeded. + 'chroot --userspec=USER' now uses the primary group of USER from inside the + chroot. Also this no longer sets supplemental groups of an unrelated user, + or reads freed memory, when the USER ID is only known outside the chroot. [bug introduced in coreutils-8.23] 'cksum' now detects GNU and BSD reversed formats for each checksum file. diff --git a/src/chroot.c b/src/chroot.c index cad94264e..92c93b794 100644 --- a/src/chroot.c +++ b/src/chroot.c @@ -315,7 +315,9 @@ main (int argc, char **argv) gid = pwd->pw_gid; gid_inferred = true; } - username = pwd->pw_name; + /* Copy, as the look-up inside the chroot reuses PWD's + storage, even when it fails. */ + username = xstrdup (pwd->pw_name); } }