summaryrefslogtreecommitdiff
path: root/package/base-files/files/lib
diff options
context:
space:
mode:
authorYousong Zhou <yszhou4tech@gmail.com>2017-11-09 17:29:56 +0800
committerYousong Zhou <yszhou4tech@gmail.com>2017-11-09 17:42:36 +0800
commitb2aa820b48add74b97e0eab993ede648c43e85db (patch)
treecc81c5e726d0f63d8ee1b8ae5fb292e0e1773908 /package/base-files/files/lib
parenta6e9d146f2bf1434f6645e72a7dc99166b5021fb (diff)
downloadmtk-20170518-b2aa820b48add74b97e0eab993ede648c43e85db.zip
mtk-20170518-b2aa820b48add74b97e0eab993ede648c43e85db.tar.gz
mtk-20170518-b2aa820b48add74b97e0eab993ede648c43e85db.tar.bz2
base-files: fix getting gid from group_add_next
Shell function return code only has range [0, 255]. Other values will be truncated, e.g. return 65536 will have the same effect as return 0 While at it, drop other "return $rc" where rc will almost always take value 0 and whose value current callers actually do not check Fixes FS#988 Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
Diffstat (limited to 'package/base-files/files/lib')
-rwxr-xr-xpackage/base-files/files/lib/functions.sh13
1 files changed, 6 insertions, 7 deletions
diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh
index 4879a37..dfadfdb 100755
--- a/package/base-files/files/lib/functions.sh
+++ b/package/base-files/files/lib/functions.sh
@@ -202,7 +202,7 @@ add_group_and_user() {
if [ -n "$gname" ] && [ -n "$gid" ]; then
group_exists "$gname" || group_add "$gname" "$gid"
elif [ -n "$gname" ]; then
- group_add_next "$gname"; gid=$?
+ gid="$(group_add_next "$gname")"
fi
if [ -n "$uname" ]; then
@@ -296,9 +296,7 @@ group_add() {
[ -f "${IPKG_INSTROOT}/etc/group" ] || return 1
[ -n "$IPKG_INSTROOT" ] || lock /var/lock/group
echo "${name}:x:${gid}:" >> ${IPKG_INSTROOT}/etc/group
- rc=$?
[ -n "$IPKG_INSTROOT" ] || lock -u /var/lock/group
- return $rc
}
group_exists() {
@@ -308,14 +306,17 @@ group_exists() {
group_add_next() {
local gid gids
gid=$(grep -s "^${1}:" ${IPKG_INSTROOT}/etc/group | cut -d: -f3)
- [ -n "$gid" ] && return $gid
+ if [ -n "$gid" ]; then
+ echo $gid
+ return
+ fi
gids=$(cat ${IPKG_INSTROOT}/etc/group | cut -d: -f3)
gid=65536
while [ -n "$(echo "$gids" | grep "^$gid$")" ] ; do
gid=$((gid + 1))
done
group_add $1 $gid
- return $gid
+ echo $gid
}
group_add_user() {
@@ -348,9 +349,7 @@ user_add() {
[ -n "$IPKG_INSTROOT" ] || lock /var/lock/passwd
echo "${name}:x:${uid}:${gid}:${desc}:${home}:${shell}" >> ${IPKG_INSTROOT}/etc/passwd
echo "${name}:x:0:0:99999:7:::" >> ${IPKG_INSTROOT}/etc/shadow
- rc=$?
[ -n "$IPKG_INSTROOT" ] || lock -u /var/lock/passwd
- return $rc
}
user_exists() {