diff mbox series

[master] useradd: use --root for groupmems which lacks --prefix support

Message ID 20260507114043.481583-1-j-sahu@ti.com
State Changes Requested
Headers show
Series [master] useradd: use --root for groupmems which lacks --prefix support | expand

Commit Message

Telukula Jeevan Kumar Sahu May 7, 2026, 11:40 a.m. UTC
groupmems in shadow does not support --prefix (unlike useradd, groupadd,
usermod). Only -R/--root is recognized. Recent commit [0] switched the
global OPT to --prefix, breaking any recipe using GROUPMEMS_PARAM with
"unrecognized option '--prefix'" at do_prepare_recipe_sysroot.

Introduce GROUPMEMS_OPT="--root $D" used exclusively in the groupmems
loop, keeping OPT="--prefix $D" unchanged for all other shadow ops.

[0]: https://git.openembedded.org/openembedded-core/commit/?id=a7b846ba7d6d63a5e59939d75d9c5fe3e4cbb0e9

Signed-off-by: Telukula Jeevan Kumar Sahu <j-sahu@ti.com>
---
 meta/classes/useradd.bbclass | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Peter Kjellerstedt May 7, 2026, 11:52 a.m. UTC | #1
> -----Original Message-----
> From: openembedded-core@lists.openembedded.org <openembedded-core@lists.openembedded.org> On Behalf Of Jeevan via lists.openembedded.org
> Sent: den 7 maj 2026 13:41
> To: openembedded-core@lists.openembedded.org
> Subject: [OE-core] [PATCH][master] useradd: use --root for groupmems which lacks --prefix support
> 
> groupmems in shadow does not support --prefix (unlike useradd, groupadd,
> usermod). Only -R/--root is recognized. Recent commit [0] switched the
> global OPT to --prefix, breaking any recipe using GROUPMEMS_PARAM with
> "unrecognized option '--prefix'" at do_prepare_recipe_sysroot.
> 
> Introduce GROUPMEMS_OPT="--root $D" used exclusively in the groupmems
> loop, keeping OPT="--prefix $D" unchanged for all other shadow ops.
> 
> [0]: https://git.openembedded.org/openembedded-core/commit/?id=a7b846ba7d6d63a5e59939d75d9c5fe3e4cbb0e9
> 
> Signed-off-by: Telukula Jeevan Kumar Sahu <j-sahu@ti.com>
> ---
>  meta/classes/useradd.bbclass | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/meta/classes/useradd.bbclass b/meta/classes/useradd.bbclass
> index d7ed6cb931..6738ad12f4 100644
> --- a/meta/classes/useradd.bbclass
> +++ b/meta/classes/useradd.bbclass
> @@ -22,11 +22,15 @@ PACKAGE_WRITE_DEPS += "shadow-native"
>  useradd_preinst () {
>  OPT=""
>  SYSROOT=""
> +GROUPMEMS_OPT=""
> 
>  if test "x$D" != "x"; then
>  	# Installing into a sysroot
>  	SYSROOT="$D"
>  	OPT="--prefix $D"
> +	# groupmems does not support --prefix (unlike useradd/groupadd/usermod),
> +	# only -R/--root is recognized. Use --root specifically for groupmems.
> +	GROUPMEMS_OPT="--root $D"
> 
>  	# Make sure login.defs is there, this is to make debian package backend work
>  	# correctly while doing rootfs.
> @@ -92,7 +96,7 @@ if test "x`echo $GROUPMEMS_PARAM | tr -d '[:space:]'`" != "x"; then
>  	opts=`echo "$GROUPMEMS_PARAM" | cut -d ';' -f 1 | sed -e 's#[ \t]*$##'`
>  	remaining=`echo "$GROUPMEMS_PARAM" | cut -d ';' -f 2- | sed -e 's#[ \t]*$##'`
>  	while test "x$opts" != "x"; do
> -		perform_groupmems "$SYSROOT" "$OPT $opts"
> +		perform_groupmems "$SYSROOT" "$GROUPMEMS_OPT $opts"
>  		if test "x$opts" = "x$remaining"; then
>  			break
>  		fi
> --
> 2.34.1

There is a Bugzilla issue for this: https://bugzilla.yoctoproject.org/show_bug.cgi?id=16277

Since the groupmems command has actually been removed in newer versions 
of shadow, the proper solution is actually to switch to using the usermod 
command instead. I am working on it...

//Peter
diff mbox series

Patch

diff --git a/meta/classes/useradd.bbclass b/meta/classes/useradd.bbclass
index d7ed6cb931..6738ad12f4 100644
--- a/meta/classes/useradd.bbclass
+++ b/meta/classes/useradd.bbclass
@@ -22,11 +22,15 @@  PACKAGE_WRITE_DEPS += "shadow-native"
 useradd_preinst () {
 OPT=""
 SYSROOT=""
+GROUPMEMS_OPT=""
 
 if test "x$D" != "x"; then
 	# Installing into a sysroot
 	SYSROOT="$D"
 	OPT="--prefix $D"
+	# groupmems does not support --prefix (unlike useradd/groupadd/usermod),
+	# only -R/--root is recognized. Use --root specifically for groupmems.
+	GROUPMEMS_OPT="--root $D"
 
 	# Make sure login.defs is there, this is to make debian package backend work
 	# correctly while doing rootfs.
@@ -92,7 +96,7 @@  if test "x`echo $GROUPMEMS_PARAM | tr -d '[:space:]'`" != "x"; then
 	opts=`echo "$GROUPMEMS_PARAM" | cut -d ';' -f 1 | sed -e 's#[ \t]*$##'`
 	remaining=`echo "$GROUPMEMS_PARAM" | cut -d ';' -f 2- | sed -e 's#[ \t]*$##'`
 	while test "x$opts" != "x"; do
-		perform_groupmems "$SYSROOT" "$OPT $opts"
+		perform_groupmems "$SYSROOT" "$GROUPMEMS_OPT $opts"
 		if test "x$opts" = "x$remaining"; then
 			break
 		fi