aboutsummaryrefslogtreecommitdiffstats
path: root/package/base-files/files/lib/functions.sh
diff options
context:
space:
mode:
authorJohn Crispin <blogic@openwrt.org>2014-10-08 08:01:28 +0000
committerJohn Crispin <blogic@openwrt.org>2014-10-08 08:01:28 +0000
commitf9cddd1fd95f6fd9660cde44ce9941302c22a133 (patch)
tree0f51b12df8b62f50498b414c15182507d3a6cf11 /package/base-files/files/lib/functions.sh
parent98e716884d9421af03c89637613498b87c69617a (diff)
downloadupstream-f9cddd1fd95f6fd9660cde44ce9941302c22a133.tar.gz
upstream-f9cddd1fd95f6fd9660cde44ce9941302c22a133.tar.bz2
upstream-f9cddd1fd95f6fd9660cde44ce9941302c22a133.zip
base-files: extend USERID:=syntax
it is now possible to inlie the uid and gid in the syntax USERID:=username=uid:group=gid:group2=gid2:... Signed-off-by: John Crispin <blogic@openwrt.org> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@42838 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/base-files/files/lib/functions.sh')
-rwxr-xr-xpackage/base-files/files/lib/functions.sh28
1 files changed, 20 insertions, 8 deletions
diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh
index 7f148223f5..6f22dd013a 100755
--- a/package/base-files/files/lib/functions.sh
+++ b/package/base-files/files/lib/functions.sh
@@ -176,24 +176,36 @@ default_postinst() {
[ -f ${IPKG_INSTROOT}/usr/lib/opkg/info/${name}.postinst-pkg ] && ( . ${IPKG_INSTROOT}/usr/lib/opkg/info/${name}.postinst-pkg )
rusers=$(grep "Require-User:" ${IPKG_INSTROOT}/usr/lib/opkg/info/${name}.control)
[ -n "$rusers" ] && {
- local user group
+ local user group uid gid
for a in $(echo $rusers | sed "s/Require-User://g"); do
user=""
group=""
for b in $(echo $a | sed "s/:/ /g"); do
+ local name id
+
+ name=$(echo $b | cut -d= -f1)
+ id=$(echo $b | cut -d= -f2)
+
[ -z "$user" ] && {
- user=$b
+ user=$name
+ uid=$id
continue
}
- [ -z "$group" ] && {
- group=$b
- group_add_next $b
+
+ gid=$id
+ [ -n "$gid" ] && group_add $name $gid
+ [ -z "$gid" ] && {
+ group_add_next $name
gid=$?
- user_exists $user || user_add $user "" $gid
+ }
+
+ [ -z "$group" ] && {
+ user_exists $user || user_add $user "$uid" $gid
+ group=$name
continue
}
- group_add_next $b
- group_add_user $b $user
+
+ group_add_user $name $user
done
done
}