[OpenWrt-Devel] [PATCH] [base-files] default_postinst() fix wrong call of group_add

Bastian Bittorf bittorf at bluebottle.com
Wed Oct 15 08:36:57 EDT 2014


[base-files] default_postinst() fix wrong call of group_add
after 12bae65d07d29854204715cebc1ef1eae237fd9b group_add is
always called. shell scripting can be tricky...

wrong call - stacked calls are wrong:
[ -n "$gid" ] && group_exists $name || group_add $name $gid

this leads to a call of 'group_add' when $gid is emtpy, proof:

root at box:~ [ -n "" ] && echo 'filled' || echo 'echo failed'
echo failed

Signed-off-by: Bastian Bittorf <bittorf at bluebottle.com>
---
 package/base-files/files/lib/functions.sh |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh
index 3a5a65d..d53be3e 100755
--- a/package/base-files/files/lib/functions.sh
+++ b/package/base-files/files/lib/functions.sh
@@ -1,5 +1,5 @@
 #!/bin/sh
-# Copyright (C) 2006-2013 OpenWrt.org
+# Copyright (C) 2006-2014 OpenWrt.org
 # Copyright (C) 2006 Fokus Fraunhofer <carsten.tittel at fokus.fraunhofer.de>
 # Copyright (C) 2010 Vertical Communications
 
@@ -193,7 +193,10 @@ default_postinst() {
 				}
 
 				gid=$id
-				[ -n "$gid" ] && group_exists $name || group_add $name $gid
+				[ -n "$gid" ] && {
+					group_exists $name || group_add $name $gid
+				}
+
 				[ -z "$gid" ] && {
 					group_add_next $name
 					gid=$?
-- 
1.7.10.4
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list