FS/XFS testing framework
 help / color / mirror / Atom feed
* [PATCH] common: check user and group existence via id
@ 2023-09-25 15:22 Christian Brauner
  2023-09-26 10:35 ` Christian Brauner
  0 siblings, 1 reply; 2+ messages in thread
From: Christian Brauner @ 2023-09-25 15:22 UTC (permalink / raw)
  To: Zorro Lang, fstests; +Cc: Christian Brauner

Newer machines support the creation of users that don't appear in
/etc/passwd but are only available via nss or userdbd. Use the id binary
which is portable and reliable.

With this change I can run xfstests on systems where the users are
created via systemd-userdbd drop-ins. See the documentation in [1] and [2].

Link: [1]: https://man7.org/linux/man-pages/man8/nss-systemd.8.html
Link: [2]: https://man7.org/linux/man-pages/man5/nsswitch.conf.5.html
Signed-off-by: Christian Brauner <brauner@kernel.org>
---
 common/rc | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/common/rc b/common/rc
index 76a7e774..44c90f50 100644
--- a/common/rc
+++ b/common/rc
@@ -2450,7 +2450,8 @@ _yp_active()
 _cat_passwd()
 {
 	[ $(_yp_active) -eq 0 ] && ypcat passwd
-	cat /etc/passwd
+	id -u "$1"
+	[ "$?" == "0" ] && echo "$user:"
 }
 
 # cat the group file
@@ -2458,7 +2459,8 @@ _cat_passwd()
 _cat_group()
 {
 	[ $(_yp_active) -eq 0 ] && ypcat group
-	cat /etc/group
+	id -g "$1"
+	[ "$?" == "0" ] && echo "$group:"
 }
 
 # check if a user exists in the system

---
base-commit: 2fddeb5c79ff16bf37e1f1d809bd94b360c27801
change-id: 20230925-fstests-check-user-5487ee9be2ef


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] common: check user and group existence via id
  2023-09-25 15:22 [PATCH] common: check user and group existence via id Christian Brauner
@ 2023-09-26 10:35 ` Christian Brauner
  0 siblings, 0 replies; 2+ messages in thread
From: Christian Brauner @ 2023-09-26 10:35 UTC (permalink / raw)
  To: Zorro Lang, fstests

On Mon, Sep 25, 2023 at 05:22:21PM +0200, Christian Brauner wrote:
> Newer machines support the creation of users that don't appear in
> /etc/passwd but are only available via nss or userdbd. Use the id binary
> which is portable and reliable.
> 
> With this change I can run xfstests on systems where the users are
> created via systemd-userdbd drop-ins. See the documentation in [1] and [2].
> 
> Link: [1]: https://man7.org/linux/man-pages/man8/nss-systemd.8.html
> Link: [2]: https://man7.org/linux/man-pages/man5/nsswitch.conf.5.html
> Signed-off-by: Christian Brauner <brauner@kernel.org>
> ---

I need to resend a fixed version. I only send half the patch.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-09-26 10:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-25 15:22 [PATCH] common: check user and group existence via id Christian Brauner
2023-09-26 10:35 ` Christian Brauner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox