From a7898626c3745551c96a3c92ab132971bfabbadd Mon Sep 17 00:00:00 2001 From: Stefan Fiedler Date: Sat, 3 Nov 2007 09:26:27 +0000 Subject: [PATCH] Stefan Fiedler: sysfiles: add two functions that packages can use to get the ids of users and groups from the target system [2007100820472917584] (https://www.rocklinux.net/submaster) git-svn-id: http://www.rocklinux.org/svn/rock-linux/trunk@8794 c5f82cb5-29bc-0310-9cd0-bff59a50e3bc --- package/base/sysfiles/parse-config | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/package/base/sysfiles/parse-config b/package/base/sysfiles/parse-config index 01c3cdeee..c2cadb32b 100644 --- a/package/base/sysfiles/parse-config +++ b/package/base/sysfiles/parse-config @@ -66,3 +66,20 @@ safe_groupadd() { fi } +# Usage: uid_by_name name +# +# Outputs the uid of name on the target system or nothing +# if not found. +# +uid_by_name() { + echo "$( grep "^$1:" $root/etc/passwd | cut -f3 -d: )" +} + +# Usage: gid_by_name name +# +# Outputs the gid of name on the target system or nothing +# if not found. +# +gid_by_name() { + echo "$( grep "^$1:" $root/etc/group | cut -f3 -d: )" +}