From patchwork Sat Mar 9 23:44:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yann E. MORIN" X-Patchwork-Id: 1910161 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=buildroot.org (client-ip=140.211.166.136; helo=smtp3.osuosl.org; envelope-from=buildroot-bounces@buildroot.org; receiver=patchwork.ozlabs.org) Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Tsflb3sXVz1yWy for ; Sun, 10 Mar 2024 10:44:43 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 7C9F060A67; Sat, 9 Mar 2024 23:44:38 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uXt_ybOiW9n4; Sat, 9 Mar 2024 23:44:37 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.34; helo=ash.osuosl.org; envelope-from=buildroot-bounces@buildroot.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 5A1D260AB3 Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp3.osuosl.org (Postfix) with ESMTP id 5A1D260AB3; Sat, 9 Mar 2024 23:44:37 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 09EFB1BF2A2 for ; Sat, 9 Mar 2024 23:44:36 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 68D3D81EB5 for ; Sat, 9 Mar 2024 23:44:33 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wDgc24jPZjC1 for ; Sat, 9 Mar 2024 23:44:32 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2a00:1450:4864:20::32e; helo=mail-wm1-x32e.google.com; envelope-from=yann.morin.1998@gmail.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp1.osuosl.org 5DC47817FD DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 5DC47817FD Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by smtp1.osuosl.org (Postfix) with ESMTPS id 5DC47817FD for ; Sat, 9 Mar 2024 23:44:32 +0000 (UTC) Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-413216e601eso4237395e9.1 for ; Sat, 09 Mar 2024 15:44:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710027870; x=1710632670; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Z3oMYyYwvReRf8/NiGRdnOx1bB5jrias09Zpz/MnN7E=; b=idGbZv+9m6Hff/oRNpO9TkVyA5Tj9JqWHZpOR7MEOvLyqZ8EFHrCTgNvobwomnWFeB K5oLSljic++8HTobqW7f6U08H/DjQEn2agAiEX3OXVX5BsxLLeyPGfmIRjPeTdr/3nL4 R3cWjdJ0lwp2BstKERbAlv0Lpt78oqQaHXBi3K+PzZOlMVntI97elol4wae18nEQX9Bp ahcIv1k2wXYGAQAQr5DGD66QyqIUV+SH/3hzImAD5olHFtHGeSFhb1kwmJyZxldT62Jw LHTqkxBgOf8g37EUIC9CWUqwJmIvacQPgRqyXk+zCmLN9BEjjUXnvAtEKBW/sCAJxu+W +ylA== X-Gm-Message-State: AOJu0YwmpHZqg0BTLogufUVgmvHmUkdtzGmB61it4zDuuDTB1jbcLGw+ OBKfZ3F++deBH3w/yN144zGdz1AhyzfW9yt1XUssey3NIEZan2ASpvr/CRT+ X-Google-Smtp-Source: AGHT+IFHYHeyDvUyifCl9fMLnU8aJCzlHQLzupt81TavpR/TSFpK+Qsbv8KIHRou19JYGEtX2bwjFQ== X-Received: by 2002:a05:600c:4e55:b0:412:6101:915c with SMTP id e21-20020a05600c4e5500b004126101915cmr1958106wmq.19.1710027870135; Sat, 09 Mar 2024 15:44:30 -0800 (PST) Received: from landeda.home ([2a01:cb19:8290:3800:e05a:3b8d:ff83:9629]) by smtp.gmail.com with ESMTPSA id fc19-20020a05600c525300b0041312855081sm4005123wmb.5.2024.03.09.15.44.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Mar 2024 15:44:29 -0800 (PST) From: "Yann E. MORIN" To: buildroot@buildroot.org Date: Sun, 10 Mar 2024 00:44:25 +0100 Message-ID: <30e2f6585aa887573547941c00bd61c02c9142db.1710027863.git.yann.morin.1998@free.fr> X-Mailer: git-send-email 2.44.0 In-Reply-To: References: MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710027870; x=1710632670; darn=buildroot.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=Z3oMYyYwvReRf8/NiGRdnOx1bB5jrias09Zpz/MnN7E=; b=gJDaUSXjKnKnzGc4peHIid9oy4gRnopidW2zt81gfNxgRS5bCTPWsHvfSFL3Aqoyxq DMsfcRWe1CBjk9rYVToAWEOR5Pj9xnymyP8XophQ/PwZyV1bbvJcGs+uzQJmJy5swdEd /2mNA0N7WN94vpxlnzy5BFaX1OySh59TuywPc61PGj85+XJAqLJr4dJQvuIJNb0t4gJH awy0s+woNRnyZVshh4vMNsFkHqeaxqjrbqoW79Ca3Umba53vYLGKzr7wtGC74kG9VMkf OQCMVlPGNmd+ZlJXyouBbUaPV89Yk6wAw4MCQc20o8yfM5GeJLQ9rZuyyYvsNSQcp304 Pgaw== X-Mailman-Original-Authentication-Results: smtp1.osuosl.org; dmarc=fail (p=none dis=none) header.from=free.fr X-Mailman-Original-Authentication-Results: smtp1.osuosl.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=gJDaUSXj Subject: [Buildroot] [PATCH 1/5] support/scripts/mkusers: fix UID/GID confusion X-BeenThere: buildroot@buildroot.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Norbert Lange , "Yann E. MORIN" Errors-To: buildroot-bounces@buildroot.org Sender: "buildroot" Commit 41ea61d59c3e (support/scripts/mkusers: allow option for system uid/gid) confused GID and UID variables: the GID limits were used to create UIDs. Fix that. Note that this fixes a shellcheck error; although there are many more shellcheck errors, these fixes are semantically a bug that need to be fixed separately from the coding style issues reported by shellcheck. Signed-off-by: Yann E. MORIN Cc: Norbert Lange Cc: Arnout Vandecappelle (Essensium/Mind) --- support/scripts/mkusers | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/support/scripts/mkusers b/support/scripts/mkusers index 4fc06f8fdf..d786943cf8 100755 --- a/support/scripts/mkusers +++ b/support/scripts/mkusers @@ -324,9 +324,9 @@ add_one_user() { # Generate a new UID if needed if [ ${uid} -eq ${AUTO_USER_ID} ]; then - uid="$( generate_uid "${username}" $FIRST_USER_GID $LAST_USER_GID )" + uid="$( generate_uid "${username}" $FIRST_USER_UID $LAST_USER_UID )" elif [ ${uid} -eq ${AUTO_SYSTEM_ID} ]; then - uid="$( generate_uid "${username}" $FIRST_SYSTEM_GID $LAST_SYSTEM_GID )" + uid="$( generate_uid "${username}" $FIRST_SYSTEM_UID $LAST_SYSTEM_UID )" fi # Remove any previous instance of this user From patchwork Sat Mar 9 23:44:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yann E. MORIN" X-Patchwork-Id: 1910163 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=buildroot.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=buildroot-bounces@buildroot.org; receiver=patchwork.ozlabs.org) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Tsflj4Znmz1yWy for ; Sun, 10 Mar 2024 10:44:49 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 9F2CB60A48; Sat, 9 Mar 2024 23:44:47 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YQGpI-884R-T; Sat, 9 Mar 2024 23:44:45 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.34; helo=ash.osuosl.org; envelope-from=buildroot-bounces@buildroot.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 8B3B460B03 Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp3.osuosl.org (Postfix) with ESMTP id 8B3B460B03; Sat, 9 Mar 2024 23:44:44 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 1BC281BF853 for ; Sat, 9 Mar 2024 23:44:37 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id E5688817FD for ; Sat, 9 Mar 2024 23:44:33 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3ld4GYbnAYVt for ; Sat, 9 Mar 2024 23:44:33 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2a00:1450:4864:20::32f; helo=mail-wm1-x32f.google.com; envelope-from=yann.morin.1998@gmail.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp1.osuosl.org CE0B981886 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org CE0B981886 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by smtp1.osuosl.org (Postfix) with ESMTPS id CE0B981886 for ; Sat, 9 Mar 2024 23:44:32 +0000 (UTC) Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-4131ad76f05so11690785e9.0 for ; Sat, 09 Mar 2024 15:44:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710027871; x=1710632671; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=ggXpucYE0Lqoq6DOmAOTavtMmlTDBkOBG43ipOY1MjA=; b=MppsRTNLJmJuXUALRgYoM8kK4trBWNpuIYoXCXJmE+8BXmnn8GkWOLzYCc6skjwqja l0kb9LRQ+SQp5eEnOtqU6cZwavV/KqnbPEAuyy/wZHH6LCQGScyjeTA/Oj5sMwFRG3KG s5TDw3dE3lOZqQZuRGJUes2Sok1mTyavDkRwQXRh9UuO/wh8P289lNQp+Z4cJNhv7Q74 tYdMEkuYPN0PVb386pzBydKtIkEx4wL7iOdMd0L3s2HqSrK0Z5r5viZ2uIm61gcCnho9 8tpRAjryFAe5qK6ngqQRKlX19eLUVhuRK8h8HUpfAMH7bQO0uwkxWPGSV9czRDANzrWt nG4A== X-Gm-Message-State: AOJu0YyZ50ruYm8r8dZ0CTlOzpe9cfqEAZ8UsVlaqkgTZDjSzhhNIu/u 1YzXyik8e3fN+4WOACxqKES/WUUwxvWT70Ug5J+JCI72emimACk7drkMUMm+ X-Google-Smtp-Source: AGHT+IFzmS3E8T/pc6XheBqmasazYcwazEIDgtNnpf/t+FObV28CdOGR5WWy2xvLZR2zCfgrJe28/A== X-Received: by 2002:a05:600c:4e89:b0:413:1f59:63f4 with SMTP id f9-20020a05600c4e8900b004131f5963f4mr1898440wmq.17.1710027870726; Sat, 09 Mar 2024 15:44:30 -0800 (PST) Received: from landeda.home ([2a01:cb19:8290:3800:e05a:3b8d:ff83:9629]) by smtp.gmail.com with ESMTPSA id fc19-20020a05600c525300b0041312855081sm4005123wmb.5.2024.03.09.15.44.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Mar 2024 15:44:30 -0800 (PST) From: "Yann E. MORIN" To: buildroot@buildroot.org Date: Sun, 10 Mar 2024 00:44:26 +0100 Message-ID: <60125f836d8da8ed5480d85cac91918378428214.1710027863.git.yann.morin.1998@free.fr> X-Mailer: git-send-email 2.44.0 In-Reply-To: References: MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710027871; x=1710632671; darn=buildroot.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=ggXpucYE0Lqoq6DOmAOTavtMmlTDBkOBG43ipOY1MjA=; b=kZab1OBLnHjVGLZWy+vm9X6/XDoUmKdDuiILy9NSromrfapbe8WsOwB+OPldKgDEZC MLFYzvsWRaG82VJvVD1tjVVdZ/JK8K0NLG/7wpoyb1wYtdbrxpfl81xDPkmuewcQp4Ya xIdCxR3C4Ix/Wc2samooAIalxn0114UqP89aFLNrEyNO8oL1ukXGRxmvh0yaYHmbmIBA 907MZLbcDEc2MiI0LP/TJ4jJgunZfCr2IMN/qDt6eCFLhLLDsD6Zh390QcMCYazn/LBh GP4QELQpitoKlaY9WzfXqC961qpd7kKsDYBXUvKlg+ZrYwYDGWIoYKFry7EcusVZ5GTi xMog== X-Mailman-Original-Authentication-Results: smtp1.osuosl.org; dmarc=fail (p=none dis=none) header.from=free.fr X-Mailman-Original-Authentication-Results: smtp1.osuosl.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=kZab1OBL Subject: [Buildroot] [PATCH 2/5] support/scripts/mkusers: fix shellcheck errors X-BeenThere: buildroot@buildroot.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Yann E. MORIN" Errors-To: buildroot-bounces@buildroot.org Sender: "buildroot" the user tables do not use trailing backslash \ to continue lines, so we don't want them to be interpreted thusly, so we use 'read -r' (SC2162). Integer variables need not be quoted (SC2086). In any case, should there be an actual issue and they be set empty, that would cause a runtime issue, wether they be quoted or not. The binary -o and -a ar perfectly defined in bash's test (SC2166). Signed-off-by: Yann E. MORIN --- .checkpackageignore | 1 - support/scripts/mkusers | 27 +++++++++++++++++++++------ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/.checkpackageignore b/.checkpackageignore index f4bfa12e1e..db09574463 100644 --- a/.checkpackageignore +++ b/.checkpackageignore @@ -1471,7 +1471,6 @@ support/scripts/expunge-gconv-modules Shellcheck support/scripts/fix-configure-powerpc64.sh EmptyLastLine support/scripts/generate-gitlab-ci-yml Shellcheck support/scripts/mkmakefile ConsecutiveEmptyLines Shellcheck -support/scripts/mkusers Shellcheck support/scripts/setlocalversion Shellcheck support/testing/tests/core/post-build.sh Shellcheck support/testing/tests/package/test_opkg/post-build.sh Shellcheck diff --git a/support/scripts/mkusers b/support/scripts/mkusers index d786943cf8..ee09bbd1f2 100755 --- a/support/scripts/mkusers +++ b/support/scripts/mkusers @@ -26,6 +26,7 @@ error() { shift printf "%s: " "${myname}" >&2 + # shellcheck disable=SC2059 # fmt is the format passed to error() printf "${fmt}" "${@}" >&2 } fail() { @@ -145,6 +146,8 @@ check_user_validity() { fail "invalid username '%s\n'" "${username}" fi + # shellcheck disable=SC2086 # gid is a non-empty int + # shellcheck disable=SC2166 # [ .. -o .. ] works well in this case if [ ${gid} -lt -2 -o ${gid} -eq 0 ]; then fail "invalid gid '%d' for '%s'\n" ${gid} "${username}" elif [ ${gid} -ge 0 ]; then @@ -171,6 +174,8 @@ check_user_validity() { fi fi + # shellcheck disable=SC2086 # uid is a non-empty int + # shellcheck disable=SC2166 # [ .. -o .. ] works well in this case if [ ${uid} -lt -2 -o ${uid} -eq 0 ]; then fail "invalid uid '%d' for '%s'\n" ${uid} "${username}" elif [ ${uid} -ge 0 ]; then @@ -190,6 +195,7 @@ check_user_validity() { fi # check the user does not already exist in another group + # shellcheck disable=SC2166 # [ .. -a .. ] works well in this case if [ -n "${_ugroup}" -a "${_ugroup}" != "${group}" ]; then fail "user '%s' already exists with group '%s' (wants '%s')\n" \ "${username}" "${_ugroup}" "${group}" @@ -218,6 +224,7 @@ generate_gid() { break fi done + # shellcheck disable=SC2086 # gid and maxgid are non-empty ints if [ ${gid} -gt ${maxgid} ]; then fail "can not allocate a GID for group '%s'\n" "${group}" fi @@ -233,6 +240,7 @@ add_one_group() { local members # Generate a new GID if needed + # shellcheck disable=SC2086 # gid is a non-empty int if [ ${gid} -eq ${AUTO_USER_ID} ]; then gid="$( generate_gid "${group}" $FIRST_USER_GID $LAST_USER_GID )" elif [ ${gid} -eq ${AUTO_SYSTEM_ID} ]; then @@ -272,6 +280,7 @@ generate_uid() { break fi done + # shellcheck disable=SC2086 # uid is a non-empty int if [ ${uid} -gt ${maxuid} ]; then fail "can not allocate a UID for user '%s'\n" "${username}" fi @@ -323,6 +332,7 @@ add_one_user() { check_user_validity "${username}" "${uid}" "${group}" "${gid}" # Generate a new UID if needed + # shellcheck disable=SC2086 # uid is a non-empty int if [ ${uid} -eq ${AUTO_USER_ID} ]; then uid="$( generate_uid "${username}" $FIRST_USER_UID $LAST_USER_UID )" elif [ ${uid} -eq ${AUTO_SYSTEM_ID} ]; then @@ -399,7 +409,7 @@ main() { fi # Read in all the file in memory, exclude empty lines and comments - while read line; do + while read -r line; do ENTRIES+=( "${line}" ) done < <( sed -r -e 's/#.*//; /^[[:space:]]*$/d;' "${USERS_TABLE}" ) @@ -410,14 +420,16 @@ main() { # First, create all the main groups which gid is *not* automatic for line in "${ENTRIES[@]}"; do - read username uid group gid passwd home shell groups comment <<<"${line}" + read -r username uid group gid passwd home shell groups comment <<<"${line}" + # shellcheck disable=SC2086 # gid is a non-empty int [ ${gid} -ge 0 ] || continue # Automatic gid add_one_group "${group}" "${gid}" done # Then, create all the main groups which gid *is* automatic for line in "${ENTRIES[@]}"; do - read username uid group gid passwd home shell groups comment <<<"${line}" + read -r username uid group gid passwd home shell groups comment <<<"${line}" + # shellcheck disable=SC2086 # gid is a non-empty int [ ${gid} -lt 0 ] || continue # Non-automatic gid add_one_group "${group}" "${gid}" done @@ -428,8 +440,9 @@ main() { # system gid if the uid is a system user (<= LAST_SYSTEM_UID), # otherwise a user gid. for line in "${ENTRIES[@]}"; do - read username uid group gid passwd home shell groups comment <<<"${line}" + read -r username uid group gid passwd home shell groups comment <<<"${line}" if [ "${groups}" != "-" ]; then + # shellcheck disable=SC2086 # uid is a non-empty int if [ ${uid} -le 0 ]; then auto_id=${uid} elif [ ${uid} -le ${LAST_SYSTEM_UID} ]; then @@ -450,8 +463,9 @@ main() { # Now, add users whose uid is *not* automatic for line in "${ENTRIES[@]}"; do - read username uid group gid passwd home shell groups comment <<<"${line}" + read -r username uid group gid passwd home shell groups comment <<<"${line}" [ "${username}" != "-" ] || continue # Magic string to skip user creation + # shellcheck disable=SC2086 # uid is a non-empty int [ ${uid} -ge 0 ] || continue # Automatic uid add_one_user "${username}" "${uid}" "${group}" "${gid}" "${passwd}" \ "${home}" "${shell}" "${groups}" "${comment}" @@ -459,8 +473,9 @@ main() { # Finally, add users whose uid *is* automatic for line in "${ENTRIES[@]}"; do - read username uid group gid passwd home shell groups comment <<<"${line}" + read -r username uid group gid passwd home shell groups comment <<<"${line}" [ "${username}" != "-" ] || continue # Magic string to skip user creation + # shellcheck disable=SC2086 # uid is a non-empty int [ ${uid} -lt 0 ] || continue # Non-automatic uid add_one_user "${username}" "${uid}" "${group}" "${gid}" "${passwd}" \ "${home}" "${shell}" "${groups}" "${comment}" From patchwork Sat Mar 9 23:44:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yann E. MORIN" X-Patchwork-Id: 1910162 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=buildroot.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=buildroot-bounces@buildroot.org; receiver=patchwork.ozlabs.org) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Tsfld5Ws1z1yWy for ; Sun, 10 Mar 2024 10:44:45 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 0CC9960A3D; Sat, 9 Mar 2024 23:44:43 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UlTob1DU4w8T; Sat, 9 Mar 2024 23:44:42 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.34; helo=ash.osuosl.org; envelope-from=buildroot-bounces@buildroot.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 1C37060AF8 Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp3.osuosl.org (Postfix) with ESMTP id 1C37060AF8; Sat, 9 Mar 2024 23:44:42 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id E60461BF2A2 for ; Sat, 9 Mar 2024 23:44:36 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 5B4B740493 for ; Sat, 9 Mar 2024 23:44:35 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id AKVKwIEgzefm for ; Sat, 9 Mar 2024 23:44:34 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2a00:1450:4864:20::333; helo=mail-wm1-x333.google.com; envelope-from=yann.morin.1998@gmail.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp4.osuosl.org 087DA4012F DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 087DA4012F Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by smtp4.osuosl.org (Postfix) with ESMTPS id 087DA4012F for ; Sat, 9 Mar 2024 23:44:33 +0000 (UTC) Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-41317cc388dso13413925e9.2 for ; Sat, 09 Mar 2024 15:44:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710027871; x=1710632671; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Z8A9YnD/AmLHx9mOTvlfbE9Hh+BjrC4vt9XKXZz/9Ag=; b=AwUwL2dWspoyZhi1yabrp48my6p32FsC7VUuN3cMBieeKR3pNGF6etbLng34F5ZfHW QY2+SIG+8aDFJEmsjGRJKzEVW8rhggw0ZsONHFxJfPQytNQGED9umfYaFcsXkTMKA7g+ VM5ZCWi0A1uILQvBZMfsN8QSpG6kof6tjBsLZiv6NI0noyYXelnRNHzEicdY+5xhfBT3 3P5GkFE6XtxSbvluEwDVxnufzpaLsT4z/Hl4YECyfBRLoCdG+rtZcaKiILlHvRUeH7zj lk2MyQRBtB0U5ySiPT+QvwdpnMAyuzKe42HlwiKJ2apkCc//HkR0J+NssAF33BglTSof dEYA== X-Gm-Message-State: AOJu0Yy6k79NapIThTbEx1JXYouURfrDpxhpQOb7Udo9y2Bfh/+lDNe3 FiY4YtRy28+fwSmIh7DCLrcsPKgJHb6/FOMFj+dO5XDEXIwI0suARBqk2+E3 X-Google-Smtp-Source: AGHT+IGeZ22LvM1SYufbSEFQ/2NnPg9Ba77eLQ4ncUBO71Xcqgi/YhhtfcRAfp1Mkaz73ySC+3BziQ== X-Received: by 2002:a05:600c:5487:b0:413:1985:db97 with SMTP id iv7-20020a05600c548700b004131985db97mr2451487wmb.9.1710027871287; Sat, 09 Mar 2024 15:44:31 -0800 (PST) Received: from landeda.home ([2a01:cb19:8290:3800:e05a:3b8d:ff83:9629]) by smtp.gmail.com with ESMTPSA id fc19-20020a05600c525300b0041312855081sm4005123wmb.5.2024.03.09.15.44.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Mar 2024 15:44:30 -0800 (PST) From: "Yann E. MORIN" To: buildroot@buildroot.org Date: Sun, 10 Mar 2024 00:44:27 +0100 Message-ID: X-Mailer: git-send-email 2.44.0 In-Reply-To: References: MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710027871; x=1710632671; darn=buildroot.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=Z8A9YnD/AmLHx9mOTvlfbE9Hh+BjrC4vt9XKXZz/9Ag=; b=C/+gFyG7szVxk4JZ1wQm1uIjoSGu4axHSeOwjlHRf9INRusoOLkzhjVPke4WNWpAWK DgX/zxJVpWu6hbLJ+RQK2doFxuucZwLliaZHv/ReC8pR4CxSxev3W1BOD7jS5kVucJa8 L6W5QdlDoa/occ2L4d1rANsXmc9jcPV173VJ/v2f8tDBrbJOscHPxfEQ6GPdzE9IBY5j K9gUo8LJXkOKUixT/iWQh8IJY2U5wFm99ysS4HB4XNPybetwL8+g9Iy2bwvMsH8o76LN Ok5wvF0SrLBB7QZhHO0HFzXIZTtam5cxOLeeka+c1zWrpOLgd3NG4DWPFr1IWoG91E1Y Q6tw== X-Mailman-Original-Authentication-Results: smtp4.osuosl.org; dmarc=fail (p=none dis=none) header.from=free.fr X-Mailman-Original-Authentication-Results: smtp4.osuosl.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=C/+gFyG7 Subject: [Buildroot] [PATCH 3/5] support/scripts/mkusers: accept user tables without terminating \n X-BeenThere: buildroot@buildroot.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Yann E. MORIN" Errors-To: buildroot-bounces@buildroot.org Sender: "buildroot" Signed-off-by: Yann E. MORIN --- support/scripts/mkusers | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/support/scripts/mkusers b/support/scripts/mkusers index ee09bbd1f2..08f3344518 100755 --- a/support/scripts/mkusers +++ b/support/scripts/mkusers @@ -409,9 +409,8 @@ main() { fi # Read in all the file in memory, exclude empty lines and comments - while read -r line; do - ENTRIES+=( "${line}" ) - done < <( sed -r -e 's/#.*//; /^[[:space:]]*$/d;' "${USERS_TABLE}" ) + # mapfile reads all lines, even the last one if it is missing a \n + mapfile -t ENTRIES < <( sed -r -e 's/#.*//; /^[[:space:]]*$/d;' "${USERS_TABLE}" ) # We first create groups whose gid is positive, and then we create groups # whose gid is automatic, so that, if a group is defined both with From patchwork Sat Mar 9 23:44:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yann E. MORIN" X-Patchwork-Id: 1910164 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=buildroot.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=buildroot-bounces@buildroot.org; receiver=patchwork.ozlabs.org) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Tsflm5k43z1yWy for ; Sun, 10 Mar 2024 10:44:52 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 92D0B60A59; Sat, 9 Mar 2024 23:44:50 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id AkqW4OPjtCYj; Sat, 9 Mar 2024 23:44:49 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.34; helo=ash.osuosl.org; envelope-from=buildroot-bounces@buildroot.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 6EAA960B15 Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp3.osuosl.org (Postfix) with ESMTP id 6EAA960B15; Sat, 9 Mar 2024 23:44:48 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id E9DD21BF2A2 for ; Sat, 9 Mar 2024 23:44:37 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 781A24012F for ; Sat, 9 Mar 2024 23:44:35 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id L_ATKZnAcNpn for ; Sat, 9 Mar 2024 23:44:34 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2a00:1450:4864:20::334; helo=mail-wm1-x334.google.com; envelope-from=yann.morin.1998@gmail.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp4.osuosl.org 4271C40135 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 4271C40135 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by smtp4.osuosl.org (Postfix) with ESMTPS id 4271C40135 for ; Sat, 9 Mar 2024 23:44:33 +0000 (UTC) Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-413183f5e11so9813255e9.1 for ; Sat, 09 Mar 2024 15:44:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710027872; x=1710632672; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=14F32g3xEA6hC8F2moRd3cagFQs3PFyMv3/Ab3vPFuY=; b=h8CmNr2CFd0XAUJ6ZXGnhjJOoDDbzcU1FJWxg2sx44AYjRvHucdq1gyoBFJ1N6ZDCc 9RXKM6kaXHEqlOtSvPidnaSst6eEG+Kk16HuvbfHfazCsp0NzCYNl1QPA2If7wyvASP3 sHb7ZwXDKueEcYZe0zScAL617OCUc0BjHdDrMS/SnrJyA6O1YENpoq9VGteSqNFLtOBR DiBqE+zozFcPpuSP+vUktUypzp7J02gOBvAqNZevhq0vKZgybpp2+VmCid2DxWCqtWSQ iyYVaQ5yf5FktsEzx9XCgIDSCEM1W8G1psV98dmIiHJg9laopgQFyp1+DE1iOztwJI4W Z+5Q== X-Gm-Message-State: AOJu0YyxAUANEHM9VUHd4uXG2IzQtBUcddW2leuKeDwjt76803aOlQcx Y7C/moVLTz8+0UOVor1P916LH2/l78I3jS10zuWLBGlw6q2ExwYEXTa4VVNI X-Google-Smtp-Source: AGHT+IFg8bV5jOzoTvE+SmzMi3iOv4JFqushF9w+JRqcRAI77uls3KMHXjfLc9imv0ks87ujQwrhww== X-Received: by 2002:a05:600c:3542:b0:412:c811:b6a3 with SMTP id i2-20020a05600c354200b00412c811b6a3mr3631142wmq.12.1710027871699; Sat, 09 Mar 2024 15:44:31 -0800 (PST) Received: from landeda.home ([2a01:cb19:8290:3800:e05a:3b8d:ff83:9629]) by smtp.gmail.com with ESMTPSA id fc19-20020a05600c525300b0041312855081sm4005123wmb.5.2024.03.09.15.44.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Mar 2024 15:44:31 -0800 (PST) From: "Yann E. MORIN" To: buildroot@buildroot.org Date: Sun, 10 Mar 2024 00:44:28 +0100 Message-ID: <0442347acee9bba11664bd51714905fc1c93e3a0.1710027863.git.yann.morin.1998@free.fr> X-Mailer: git-send-email 2.44.0 In-Reply-To: References: MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710027872; x=1710632672; darn=buildroot.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=14F32g3xEA6hC8F2moRd3cagFQs3PFyMv3/Ab3vPFuY=; b=TpENc89xcE3Ms7mW2QaH0uJrfCy+k4qic4J3ydFAkJ33n4Ms1L6sMQVKplQJ8lhFN3 fhO9l1ZSsEz9nxnDA/LpRD2jYq5PGcVZm68k75kUR2AZX/znqhcKBn2TZY+GEAAD2fNQ AFOqSbjQ8MZXfo39LzlYQ2Iq6aaq8bPWb8EFRd9VFmKWWf5BE/1Ewg0RjxpcBbFS3WGL XCHKbwUHIYybMiBaN36RR4QbFKIOUwcoYt1xTeBthZ5i6o+vXi4yOD2LI48twzFi+tHN QGXSkj/S2oGkc7BHt15/QrxkSm+TMr3u4GnqCbzxTOcsRDzftOG7QQUmX0xrjIs1OIC9 5qPg== X-Mailman-Original-Authentication-Results: smtp4.osuosl.org; dmarc=fail (p=none dis=none) header.from=free.fr X-Mailman-Original-Authentication-Results: smtp4.osuosl.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=TpENc89x Subject: [Buildroot] [PATCH 4/5] support/download/check-hash: fix shellcheck errors X-BeenThere: buildroot@buildroot.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Yann E. MORIN" Errors-To: buildroot-bounces@buildroot.org Sender: "buildroot" The hash files do not use trailing backslash \ to continue lines, so we don't want them to be interpreted thusly, so we use 'read -r' (SC2162). The h_file is used twice in the same loop, once for reading from it, and once just to print it, so there is no conflict (SC2094). Integrer variables need not be quoted (SC2086). In any case, should there be an actual issue and they be set empty, that would cause a runtime issue, wether they be quoted or not. Signed-off-by: Yann E. MORIN --- .checkpackageignore | 1 - support/download/check-hash | 8 ++++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.checkpackageignore b/.checkpackageignore index db09574463..e9dcc56d32 100644 --- a/.checkpackageignore +++ b/.checkpackageignore @@ -1448,7 +1448,6 @@ support/dependencies/check-host-xzcat.sh Shellcheck support/dependencies/dependencies.sh Shellcheck support/download/bzr ConsecutiveEmptyLines Shellcheck support/download/cargo-post-process Shellcheck -support/download/check-hash Shellcheck support/download/cvs Shellcheck support/download/dl-wrapper Shellcheck support/download/file Shellcheck diff --git a/support/download/check-hash b/support/download/check-hash index 03a6557187..9db647885a 100755 --- a/support/download/check-hash +++ b/support/download/check-hash @@ -57,7 +57,7 @@ check_one_hash() { esac # Do the hashes match? - _hash=$( ${_h}sum "${_file}" |cut -d ' ' -f 1 ) + _hash="$( "${_h}sum" "${_file}" |cut -d ' ' -f 1 )" if [ "${_hash}" = "${_known}" ]; then printf "%s: OK (%s: %s)\n" "${base}" "${_h}" "${_hash}" return 0 @@ -78,7 +78,8 @@ nb_checks=0 for h_file in "${h_files[@]}"; do [ -f "${h_file}" ] || continue : $((nb_h_files++)) - while read t h f; do + # shellcheck disable=SC2094 # we're really reading it only once + while read -r t h f; do case "${t}" in ''|'#'*) # Skip comments and empty lines @@ -86,6 +87,7 @@ for h_file in "${h_files[@]}"; do ;; *) if [ "${f}" = "${base}" ]; then + # shellcheck disable=SC2094 # we're only printing the h_file filename check_one_hash "${t}" "${h}" "${file}" "${h_file}" : $((nb_checks++)) fi @@ -94,11 +96,13 @@ for h_file in "${h_files[@]}"; do done <"${h_file}" done +# shellcheck disable=SC2086 # nb_h_files is a non-empty int if [ ${nb_h_files} -eq 0 ]; then printf "WARNING: no hash file for %s\n" "${base}" >&2 exit 0 fi +# shellcheck disable=SC2086 # nb_checks is a non-empty int if [ ${nb_checks} -eq 0 ]; then case " ${BR_NO_CHECK_HASH_FOR} " in *" ${base} "*) From patchwork Sat Mar 9 23:44:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yann E. MORIN" X-Patchwork-Id: 1910165 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=buildroot.org (client-ip=140.211.166.136; helo=smtp3.osuosl.org; envelope-from=buildroot-bounces@buildroot.org; receiver=patchwork.ozlabs.org) Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Tsflq5TdHz1yWy for ; Sun, 10 Mar 2024 10:44:55 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id E74C360AF8; Sat, 9 Mar 2024 23:44:52 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id g4w_stiPuQsu; Sat, 9 Mar 2024 23:44:52 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.34; helo=ash.osuosl.org; envelope-from=buildroot-bounces@buildroot.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org A1B8760B15 Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp3.osuosl.org (Postfix) with ESMTP id A1B8760B15; Sat, 9 Mar 2024 23:44:51 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 19A8F1BF2A2 for ; Sat, 9 Mar 2024 23:44:40 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id E0D05404C6 for ; Sat, 9 Mar 2024 23:44:36 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WYqt3HKCIK8m for ; Sat, 9 Mar 2024 23:44:35 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2a00:1450:4864:20::336; helo=mail-wm1-x336.google.com; envelope-from=yann.morin.1998@gmail.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp4.osuosl.org 8049E40135 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 8049E40135 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by smtp4.osuosl.org (Postfix) with ESMTPS id 8049E40135 for ; Sat, 9 Mar 2024 23:44:34 +0000 (UTC) Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-412f1961101so26183935e9.0 for ; Sat, 09 Mar 2024 15:44:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710027872; x=1710632672; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Oid9jc3+40qbeYjYjoUCNTnbyXFDEL1yQJdj8kMX3Is=; b=DN3p4X5wOJna3WspA/OfVQmQW/m6NKNl76+Sa/yi+8r1cVmPIYWq9pJCUiJYLHz9GE fmBJnUQem8F7GlmMAEGCAVIgNNAaru0TCWqeui4N6nHxnbOjvmpN7BCzdNl6UdeOzcJ9 71eHIzG0a32UQi/M/csEdOm5BLG1XS2MGmKVh8F/DEPyKqyASH3VYLRzN253DV4cMLyx iQuFT1Ou9pMbr+bOBwX7K39gkw8/M2yapPMdibYzSz9OOtIqkjcpm+AlV//Vb8SjJwOF pi1MGLnh0e7FJxlENNHtyOZMVVwOeTeUH2kZj1zisXKgX5d4K0/RoTK4nOCxpzaxoRg8 Uq/w== X-Gm-Message-State: AOJu0YwFqymm9xM1yxjOmVru01GEq2vkJDiiqZkmgBpz3zam+lODVZDE KAw5xTcckxExmHVmj2oRaVSxmbCnbns2yTeFarJPBMkpS7ZsaGmezcq8fm57 X-Google-Smtp-Source: AGHT+IHzvMTe7QEi5KBCls54r2CVU9N65/qiZ80RDmBOchMjST6fWb3OmkrJav8OE9XXUQZVbyJK+Q== X-Received: by 2002:a05:600c:4591:b0:413:1e07:9dad with SMTP id r17-20020a05600c459100b004131e079dadmr2503830wmo.1.1710027872487; Sat, 09 Mar 2024 15:44:32 -0800 (PST) Received: from landeda.home ([2a01:cb19:8290:3800:e05a:3b8d:ff83:9629]) by smtp.gmail.com with ESMTPSA id fc19-20020a05600c525300b0041312855081sm4005123wmb.5.2024.03.09.15.44.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Mar 2024 15:44:32 -0800 (PST) From: "Yann E. MORIN" To: buildroot@buildroot.org Date: Sun, 10 Mar 2024 00:44:29 +0100 Message-ID: <7c4ef882367896d7d522301f04c742bc26df47aa.1710027863.git.yann.morin.1998@free.fr> X-Mailer: git-send-email 2.44.0 In-Reply-To: References: MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710027872; x=1710632672; darn=buildroot.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=Oid9jc3+40qbeYjYjoUCNTnbyXFDEL1yQJdj8kMX3Is=; b=TmQCtQVQoYQqYAkI69amGsal3WAWOCtAglaXk99ZWZzMV5Wh9BXpQNPBQL1c31lfqr 61YSzL/y9y86jAnkucOfIM55YW4/mAcj1moDOHKtK+uPs9N34/MJpb1vIZjop0t2THe+ pLNDUnx2UH4xOHQypXbySti8+7EYHgWWweMtpTxr2lIsQbdAAC9aYYTFfSSocZrZNbP2 LhOzCWsXLkPzISPJL1AX80PlWPyWhgY8iDN7Z4xyBSkpPeHkAvFR/FNflBnhgWfq8q+C USPFPoEIJFTR5iyL3g8kTEkSEuKbGq4/TH1k67Cx6MoD6BtAYublBxJFZzGUmnEdasew O+1Q== X-Mailman-Original-Authentication-Results: smtp4.osuosl.org; dmarc=fail (p=none dis=none) header.from=free.fr X-Mailman-Original-Authentication-Results: smtp4.osuosl.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=TmQCtQVQ Subject: [Buildroot] [PATCH 5/5] support/download/check-hash: accept hash files without terminating \n X-BeenThere: buildroot@buildroot.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Yann E. MORIN" , masonwardle@gmail.com Errors-To: buildroot-bounces@buildroot.org Sender: "buildroot" Lots of people are using broken text editors that 1. do not naturally terminate text files with a final \n as is customary in UNIX text files, and 2. do not respect our .editorconfig settings, which explicitly require adding that final newline. See this nice summary of what a text file is (with references to applicable standards): https://stackoverflow.com/questions/12916352/shell-script-read-missing-last-line/12916758#12916758 So, it is not surprising that read does not read the last "line" of a file, when said "line" does not end with a newline, because it is thus not really a line. Even though we do mandate actual text files, let's be a little bit lax in this respect, because people may write packages, and their hash files, in a br2-external tree, and they may not have our .editorconfig in the directory heierarchy (e.g. if buildroot is a submodule of their br2-external tree, or whatever). mapfile does not suffer from this limitation, though, and correctly reads all lines from a file, even the final line-that-is-not-a-line. mapfile was introduced in bash 4.0, released on 2009-01-20, more than 15 years ago. Debian squeeze, released in 2011 already had bash 4.1. Those are really ancient. So, it means we can indeed expect bash version 4.0 or later; which means mapfile is available. "It should be fine!" Fixes: #15976 Reported-by: masonwardle@gmail.com Signed-off-by: Yann E. MORIN --- support/download/check-hash | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/support/download/check-hash b/support/download/check-hash index 9db647885a..d18ec8b134 100755 --- a/support/download/check-hash +++ b/support/download/check-hash @@ -78,8 +78,10 @@ nb_checks=0 for h_file in "${h_files[@]}"; do [ -f "${h_file}" ] || continue : $((nb_h_files++)) - # shellcheck disable=SC2094 # we're really reading it only once - while read -r t h f; do + # mapfile reads all lines, even the last one if it is missing a \n + mapfile -t hash_lines <"${h_file}" + for hash_line in "${hash_lines[@]}"; do + read -r t h f <<<"${hash_line}" case "${t}" in ''|'#'*) # Skip comments and empty lines @@ -87,13 +89,12 @@ for h_file in "${h_files[@]}"; do ;; *) if [ "${f}" = "${base}" ]; then - # shellcheck disable=SC2094 # we're only printing the h_file filename check_one_hash "${t}" "${h}" "${file}" "${h_file}" : $((nb_checks++)) fi ;; esac - done <"${h_file}" + done done # shellcheck disable=SC2086 # nb_h_files is a non-empty int