From patchwork Sat Apr 5 16:24:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yann E. MORIN" X-Patchwork-Id: 337211 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from silver.osuosl.org (silver.osuosl.org [140.211.166.136]) by ozlabs.org (Postfix) with ESMTP id B8CDC1400D4 for ; Sun, 6 Apr 2014 02:24:55 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 7FC34302AA; Sat, 5 Apr 2014 16:24:54 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 04E8fI-AVknk; Sat, 5 Apr 2014 16:24:53 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 346DE3020D; Sat, 5 Apr 2014 16:24:53 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (whitealder.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id E748D1BF97E for ; Sat, 5 Apr 2014 16:24:51 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id E036C8BC4B for ; Sat, 5 Apr 2014 16:24:51 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wpH3eLEemt5J for ; Sat, 5 Apr 2014 16:24:51 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wg0-f46.google.com (mail-wg0-f46.google.com [74.125.82.46]) by whitealder.osuosl.org (Postfix) with ESMTPS id 09E928ACBF for ; Sat, 5 Apr 2014 16:24:50 +0000 (UTC) Received: by mail-wg0-f46.google.com with SMTP id b13so4796478wgh.17 for ; Sat, 05 Apr 2014 09:24:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id; bh=IouQ9UF1W/hc5swR3HtLwKPNO0jobrq+FKexKwC91lE=; b=SSLQXIh7huebiVQ8gVwLMVvhH1G4TRJVOZmoDcRysRot1bHENm6GedOI/7vYwf3oXt Ljm+cWyhUSeShX6QNgTeCQUjsFXBEZTe161TmKLvG47YfJMmQ/BtJiAGskY6m1Bs+v9/ VzDgERY5pxX03K0GjhKqc+6P5iTpD9YhwYKc9Atvner3fRhbM8A7Y92hdaZNWJ4AP7tz PzsxLhgfum7sivNIgKWpS3cYEB6g9TOl+DRY09c8oeLCySvgcPQbIurYihj3vnkDh5Ck Nsn4KmhAQcDJajAUmsV/QkqdWPS1WrzpBJ+uTdImNSVzAB3WMiSESBvDzBctmCh51woT ggcw== X-Received: by 10.180.19.130 with SMTP id f2mr13134562wie.6.1396715089657; Sat, 05 Apr 2014 09:24:49 -0700 (PDT) Received: from gourin.bzh.lan (ks3095497.kimsufi.com. [94.23.60.27]) by mx.google.com with ESMTPSA id gz1sm11698820wib.14.2014.04.05.09.24.47 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 05 Apr 2014 09:24:48 -0700 (PDT) From: "Yann E. MORIN" To: buildroot@buildroot.org Date: Sat, 5 Apr 2014 18:24:43 +0200 Message-Id: <1396715083-20764-1-git-send-email-yann.morin.1998@free.fr> X-Mailer: git-send-email 1.8.3.2 Cc: "Yann E. MORIN" Subject: [Buildroot] [PATCH] support/mkusers: fix warnings when adding a new user X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: buildroot-bounces@busybox.net From: "Yann E. MORIN" 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. Reported-by: Thomas Petazzoni Signed-off-by: "Yann E. MORIN" --- support/scripts/mkusers | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/support/scripts/mkusers b/support/scripts/mkusers index 90d1df7..3fa0fa8 100755 --- a/support/scripts/mkusers +++ b/support/scripts/mkusers @@ -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