[LEDE-DEV] [PATCH 1/3] base-files: support multiple user:group tuples in Require-User
Yousong Zhou
yszhou4tech at gmail.com
Thu Jun 15 03:14:45 PDT 2017
On 15 June 2017 at 17:19, Jonas Gorski <jonas.gorski at gmail.com> wrote:
> Hi,
>
> On 14 June 2017 at 14:28, Yousong Zhou <yszhou4tech at gmail.com> wrote:
>> 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
>
> I don't understand this patch, the old code already supported multiple
> tuples, so what does this patch do apart from slightly rewriting the
> code? Does it fix anything? It doesn't help that the
> commit message is empty.
>
>
> Regards
> Jonas
You are right. The old code already supported multiple tuples. I got
struck by the impression that multiple items need to be separated by
commas... I will later send a v2 dropping this patch. Thanks for the
review.
Regards,
yousong
More information about the Lede-dev
mailing list