[LEDE-DEV] [PATCH 1/3] base-files: support multiple user:group tuples in Require-User
Yousong Zhou
yszhou4tech at gmail.com
Wed Jun 14 05:28:58 PDT 2017
Signed-off-by: Yousong Zhou <yszhou4tech at gmail.com>
---
package/base-files/Makefile | 2 +-
package/base-files/files/lib/functions.sh | 54 +++++++++++++++----------------
2 files changed, 28 insertions(+), 28 deletions(-)
diff --git a/package/base-files/Makefile b/package/base-files/Makefile
index c669ff0ac6..54c157611f 100644
--- a/package/base-files/Makefile
+++ b/package/base-files/Makefile
@@ -11,7 +11,7 @@ include $(INCLUDE_DIR)/kernel.mk
include $(INCLUDE_DIR)/version.mk
PKG_NAME:=base-files
-PKG_RELEASE:=173
+PKG_RELEASE:=174
PKG_FLAGS:=nonshared
PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/
diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh
index 2b6415a200..ae7f4dc9ee 100755
--- a/package/base-files/files/lib/functions.sh
+++ b/package/base-files/files/lib/functions.sh
@@ -186,36 +186,36 @@ default_prerm() {
add_group_and_user() {
local pkgname="$1"
local rusers="$(sed -ne 's/^Require-User: *//p' $root/usr/lib/opkg/info/${pkgname}.control 2>/dev/null)"
+ local oIFS="$IFS"
+ local tuple
+
+ IFS=", "; set -- $rusers; IFS="$oIFS"
+ for tuple in "$@"; do
+ local uid gid uname gname
+
+ IFS=":"
+ set -- $tuple; uname="$1"; gname="$2"
+ IFS="="
+ set -- $uname; uname="$1"; uid="$2"
+ set -- $gname; gname="$1"; gid="$2"
+ IFS="$oIFS"
+
+ if [ -n "$gname" ] && [ -n "$gid" ]; then
+ group_exists "$gname" || group_add "$gname" "$gid"
+ elif [ -n "$gname" ]; then
+ group_add_next "$gname"; gid=$?
+ fi
- if [ -n "$rusers" ]; then
- local tuple oIFS="$IFS"
- for tuple in $rusers; do
- local uid gid uname gname
-
- IFS=":"
- set -- $tuple; uname="$1"; gname="$2"
- IFS="="
- set -- $uname; uname="$1"; uid="$2"
- set -- $gname; gname="$1"; gid="$2"
- IFS="$oIFS"
-
- if [ -n "$gname" ] && [ -n "$gid" ]; then
- group_exists "$gname" || group_add "$gname" "$gid"
- elif [ -n "$gname" ]; then
- group_add_next "$gname"; gid=$?
- fi
-
- if [ -n "$uname" ]; then
- user_exists "$uname" || user_add "$uname" "$uid" "$gid"
- fi
+ if [ -n "$uname" ]; then
+ user_exists "$uname" || user_add "$uname" "$uid" "$gid"
+ fi
- if [ -n "$uname" ] && [ -n "$gname" ]; then
- group_add_user "$gname" "$uname"
- fi
+ if [ -n "$uname" ] && [ -n "$gname" ]; then
+ group_add_user "$gname" "$uname"
+ fi
- unset uid gid uname gname
- done
- fi
+ unset uid gid uname gname
+ done
}
default_postinst() {
--
2.12.2
More information about the Lede-dev
mailing list