Patchwork [1/1] extrausers.bbclass: avoid infinite loop

login
register
mail settings
Submitter Qi.Chen@windriver.com
Date Nov. 6, 2013, 2:50 a.m.
Message ID <167b611b04f6bb4f26ae7265d1e22263f66ba617.1383706191.git.Qi.Chen@windriver.com>
Download mbox | patch
Permalink /patch/61185/
State Accepted
Commit 5810d54756159f181e0e95122bfbcca451fe7665
Headers show

Comments

Qi.Chen@windriver.com - Nov. 6, 2013, 2:50 a.m.
From: Chen Qi <Qi.Chen@windriver.com>

Avoid infinite loop if the last record in EXTRA_USRES_PARAMS doesn't
end with a semicolon.

It's possible the the users will write configurations like below.

INHERIT += "extrausers"
EXTRA_USERS_PARAMS = "useradd tester; useradd developer"

In such situation, the do_rootfs task will enter an infinite loop.
An infinite loop is never acceptable.

This patch fixes the above problem.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 meta/classes/extrausers.bbclass |    4 ++++
 1 file changed, 4 insertions(+)

Patch

diff --git a/meta/classes/extrausers.bbclass b/meta/classes/extrausers.bbclass
index 8670a2a..faf57b1 100644
--- a/meta/classes/extrausers.bbclass
+++ b/meta/classes/extrausers.bbclass
@@ -54,6 +54,10 @@  set_user_group () {
 				bbfatal "Invalid command in EXTRA_USERS_PARAMS: $cmd"
 				;;
 		esac
+		# Avoid infinite loop if the last parameter doesn't end with ';'
+		if [ "$setting" = "$remaining" ]; then
+			break
+		fi
 		# iterate to the next setting
 		setting=`echo $remaining | cut -d ';' -f1`
 		remaining=`echo $remaining | cut -d ';' -f2-`