support/mkusers: fix warnings when adding a new user
PATCH 1/1 support/mkusers: fix warnings when adding a new user
From: "Yann E. MORIN" <[email protected]>
When adding a new user (or a new group), we would get warnings, like:
[...]/support/scripts/mkusers: line 145: [: too many arguments
This is because we're checking if a UID (or a GID) is already defined, and/or is different from the requested one, both checks in the same test.
Of course, if a UID (or a GID) is not defined, it does not have a value, so we can not compare it to an integer.
Fix that by splitting the test in two, so the second is only executed if the first is sucessful.
--- support/scripts/mkusers | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
support/scripts/mkusers +9 -3
@@ -137,12 +137,16 @@ check_user_validity() { fi # check the group does not already exists with another gid - if [ -n "${_gid}" -a ${_gid} -ne ${gid} ]; then + # Need to split the check in two, otherwise '[' complains it + # is missing arguments when _gid is empty + if [ -n "${_gid}" ] && [ ${_gid} -ne ${gid} ]; then fail "group already exists with gid '${_gid}'\n" fi # check the user does not already exists with another gid - if [ -n "${_ugid}" -a ${_ugid} -ne ${gid} ]; then + # Need to split the check in two, otherwise '[' complains it + # is missing arguments when _ugid is empty + if [ -n "${_ugid}" ] && [ ${_ugid} -ne ${gid} ]; then fail "user already exists with gid '${_ugid}'\n" fi fi
@@ -156,7 +160,9 @@ check_user_validity() { fi # check the user does not already exists with another uid - if [ -n "${_uid}" -a ${_uid} -ne ${uid} ]; then + # Need to split the check in two, otherwise '[' complains it + # is missing arguments when _uid is empty + if [ -n "${_uid}" ] && [ ${_uid} -ne ${uid} ]; then fail "user already exists with uid '${_uid}'\n" fi fi
Signature · 1 line
1.8.3.2
Thomas Petazzoni
AppliedPATCH 1/1 support/mkusers: fix warnings when adding a new user
Dear Yann E. MORIN,
Quoted 12 lines · Yann E. MORIN
From: "Yann E. MORIN" <[email protected]>
When adding a new user (or a new group), we would get warnings, like:
[...]/support/scripts/mkusers: line 145: [: too many argumentsThis is because we're checking if a UID (or a GID) is already defined, and/or is different from the requested one, both checks in the same test.
Of course, if a UID (or a GID) is not defined, it does not have a value, so we can not compare it to an integer.
Quoted 8 lines
Fix that by splitting the test in two, so the second is only executed if the first is sucessful.
Reported-by Thomas Petazzoni <[email protected]>Signed-off-by "Yann E. MORIN" <[email protected]>--- support/scripts/mkusers | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
Applied, thanks.
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com