From patchwork Thu Apr 30 03:04:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Greenberg X-Patchwork-Id: 11519093 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EFD2413B2 for ; Thu, 30 Apr 2020 03:04:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C0DD22073E for ; Thu, 30 Apr 2020 03:04:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mymailpomona.onmicrosoft.com header.i=@mymailpomona.onmicrosoft.com header.b="1Mk6FRPb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726291AbgD3DEc (ORCPT ); Wed, 29 Apr 2020 23:04:32 -0400 Received: from mail-dm6nam11on2071.outbound.protection.outlook.com ([40.107.223.71]:6078 "EHLO NAM11-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726180AbgD3DEc (ORCPT ); Wed, 29 Apr 2020 23:04:32 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ciwam2e67QX7RTkV0MCVe+P6EqMfvDPwfVAFwltLim/hTPg85u46lTf4I8VcXq7cwwZwqg85N4wy+QlKygzgV5iPjlBmTKOKFOC9vTWM5Cbfa8okN+Fve6iOHHpqOgP8rFGmdWniaqdB+UMakBljoaB7Tj9ZpFiBH4pYH16TgZ7s3hkhEwHCYKc7oUX7I4X6zAL8HnBKAD6Ih5Wj3A785DC6UDllFP5dIKoc8PnqNHq5HlOgUt+Bhw2c05pcrInrWczQjwCAqvQ8w6NgJb3mUn1vE1pyS1HKOFfuS7s6/brLQ7nRXzugWz4iGtP5+ZTgAuJ9+/5KZRbv1woiioXLrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sdAEnzOJ+7V/2k23qQ+8zqX92hiySig3F86nMPWBSA4=; b=W8AZvRJC0KScAWPABSWWlmKeTaFGsqoz95Dh4FppZKSIGjvG15CWFWazXIkFvZSXQOCBzHnZ5lamK9TFejb/vHqoBRiX3FpU1fDeQeSyaIsus/+Wyl/DmZ4EqlIyufUTCC3TIBukC0kNY9M4kBukWjqaKYZyFohFh7iFFzi5PJfo7pM0dudT+sDn/WzzlmGr3+8AGppYiqwSYASXmQW5ft15N2klPhW0QL3GeBnbKh1dIWgvqiCQZzRPvX4ewSMlaPB5qjS4P+Ebgm2Z9jX935QSmSPcF1Ae2tshd47AWAGx/hYhM54Dx3jocVVKQ1kIOoIYgCtsGGNUvHnRS/HwAQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=pomona.edu; dmarc=pass action=none header.from=pomona.edu; dkim=pass header.d=pomona.edu; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mymailpomona.onmicrosoft.com; s=selector2-mymailpomona-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sdAEnzOJ+7V/2k23qQ+8zqX92hiySig3F86nMPWBSA4=; b=1Mk6FRPbzvkzIOiAqQ+ZYnxa0mQQpIO11pWKcEdDSVj0lG4OuxX2eX7loeFf712CJJUCYcSoPlO4ioF9z58cq5OqxbanTzGHHqfUcOsnWCz7e+8teaNhqoVfOVZI2NM2TiG3xQ8P58qLzbzcVpvJGjTZXcoANQ/18FY3hoxImNs= Authentication-Results: gondor.apana.org.au; dkim=none (message not signed) header.d=none;gondor.apana.org.au; dmarc=none action=none header.from=pomona.edu; Received: from SN6PR03MB4285.namprd03.prod.outlook.com (2603:10b6:805:c1::17) by SN6PR03MB4496.namprd03.prod.outlook.com (2603:10b6:805:103::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.20; Thu, 30 Apr 2020 03:04:29 +0000 Received: from SN6PR03MB4285.namprd03.prod.outlook.com ([fe80::200e:5103:7b95:ba36]) by SN6PR03MB4285.namprd03.prod.outlook.com ([fe80::200e:5103:7b95:ba36%3]) with mapi id 15.20.2937.028; Thu, 30 Apr 2020 03:04:29 +0000 From: Michael Greenberg To: Herbert Xu , "dash\@vger.kernel.org" Subject: [v3 PATCH] mktokens relative TMPDIR In-Reply-To: <20200430025705.GA12900@gondor.apana.org.au> References: <20200429055923.GA17016@gondor.apana.org.au> <20200430025705.GA12900@gondor.apana.org.au> Date: Wed, 29 Apr 2020 20:04:21 -0700 Message-ID: X-ClientProxiedBy: BYAPR07CA0001.namprd07.prod.outlook.com (2603:10b6:a02:bc::14) To SN6PR03MB4285.namprd03.prod.outlook.com (2603:10b6:805:c1::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost (134.173.92.7) by BYAPR07CA0001.namprd07.prod.outlook.com (2603:10b6:a02:bc::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.19 via Frontend Transport; Thu, 30 Apr 2020 03:04:26 +0000 X-Originating-IP: [134.173.92.7] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 81c4ee9d-be3b-40e5-92b6-08d7ecb331bd X-MS-TrafficTypeDiagnostic: SN6PR03MB4496: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-Forefront-PRVS: 0389EDA07F X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tnou7LuKANII7DpZhTOlzTEWqURBHoWGTgmOxOYUz7u+jqFr/zLF/W08juT0Za75lplw27IB7l2o9XkRDCEdTsz4T5KH0UJHJodjNITnHeaaGtGYwdPPsjkm297osezCYol7GXe5EfZGnjcUlEbUUKMOo6YUEdCfdj3EamBUnfnrgtG9lW6VaqvPBgjMv6jBhPrL5yXlwnRGDDt6Gc9gGUXSb95OoTLlJNq4cou6U5GGcXxoYAb0IwlSrUnQ7FFNixfIrAK9SZJgsHRhYgvki6XURwEV9XUIgD9t1s8LHKpri6BGBiPUGR7lFTROCKIgbiI7nme4oemXRhLKLixbyE0jHaujT9+G/ir/4ySe6aEqSclg5sWw16SmuQ9ptIGLlzWgWo8IMhiqwglGyc5IvzSQCKecP4AqtbOp15HOEP4gVJbTAFZo0NRwWUZfrqRJrcFfJBY9zkdJQ2o/0KaUvDaGi0YJoPUlqpYTrfGPOaQ= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR03MB4285.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(376002)(136003)(39860400002)(346002)(396003)(366004)(786003)(316002)(186003)(2616005)(86362001)(2906002)(36756003)(956004)(478600001)(6666004)(66476007)(110136005)(75432002)(66946007)(8676002)(66556008)(26005)(5660300002)(52116002)(8936002)(6496006)(16526019)(6486002)(44832011)(491001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: b0VPFBNu0gEyI3KvHJzthG/2QcXw677B2adiTjWj03FCRfl5112X9ePZ3ZIFLW8DiRerUyfDdM7wE4oaAG3/pf4NKlMfI+ES/TGfmHEDe7o9ba02TGa3r0ItVRdVNxSY0CzMEeJpi0KO8Khd5edW1OTffwg5NzM59e3wgChzKgIg+jql8lJAZ3llQFSTPhrk4LimyNqbO2BAofJgsOyuEfQZdnv8zCyx+mM0+Udv2rD2XD8pt9ipRJ9BPgJVyM2gO1xHIShm11dIv5xBdWeAeotEQSgHZ4Ay5g3Yj5c9EJgQ3S6yCioQknmW6RctHaTdWt5J6eKtSwAaV47MBRA2mGnTilnDTVcOxhub5wRLhpdtvrc0+4SWkt1BpNrTmMgr9pIcD9LdPS4/CVYRbwop5hIuWXn7H1Wi2BZyF42H346l7PKi6X0CPgduGV3CHcTCe8DCbCfU773bv7azuLKMQcNSj+jtwvU/St3pbsbJZ/MFbQay7bIVfPSAQIkP7MzP52LTzN0FsdCvKb1kw6TNHgAL7eU5cPzg8JTzHDA6XrIs6c4XrBGZKlB/nQCCM+M+0c0mugnKmePKhx4CaLxRR+kxP2Mvh1RbV4TbVF3TZlHVAwD5KTGz7vNds27kVW0fBzm9jI0N3HKntbbhwFzalNep18KBLsjQGjUfoIO3UJDizwiyrxt7sFAcMfWx2uxOOIyAfvaVSIYDOPW0gjEHafMBmbdDfg4d01CJbBtEus7xsbTwzDYMvxyqz8rCs8IWzI/tZkN2/RGdspI5uEeiWKT/eCSOHJPvDj3Qh6J6kfM= X-OriginatorOrg: pomona.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 81c4ee9d-be3b-40e5-92b6-08d7ecb331bd X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Apr 2020 03:04:29.3062 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 817f5904-3904-4ee8-b3a5-a65d4746ff70 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: awQKInDEI2djAtWcnXPxpgyWeTVrFaTbgGVj5poeph7KBxjoQz5SVCWG97jaKORhhDPWAJ4uLhg8EGFhm23Phw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR03MB4496 Sender: dash-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dash@vger.kernel.org The mktokens script fails when /tmp isn't writable (e.g., when building in a sandbox with a different TMPDIR). Replace absolute references to /tmp to relative references to TMPDIR. If TMPDIR is unset or null, default to /tmp. The mkbuiltins script was already hardened to work relative to TMPDIR, also defaulting to /tmp. v2 ensures that TMPDIR is quoted. v3 adds an extra quotation that prevents extra pathname expansions. Signed-off-by: Michael Greenberg diff --git a/src/mktokens b/src/mktokens index cd52241..3ab7bc5 100644 --- a/src/mktokens +++ b/src/mktokens @@ -37,7 +37,9 @@ # token marks the end of a list. The third column is the name to print in # error messages. -cat > /tmp/ka$$ <<\! +: "${TMPDIR:=/tmp}" + +cat > "${TMPDIR}"/ka$$ <<\! TEOF 1 end of file TNL 0 newline TSEMI 0 ";" @@ -68,28 +70,28 @@ TWHILE 0 "while" TBEGIN 0 "{" TEND 1 "}" ! -nl=`wc -l /tmp/ka$$` +nl=`wc -l "${TMPDIR}"/ka$$` exec > token.h -awk '{print "#define " $1 " " NR-1}' /tmp/ka$$ +awk '{print "#define " $1 " " NR-1}' "${TMPDIR}"/ka$$ exec > token_vars.h echo ' /* Array indicating which tokens mark the end of a list */ static const char tokendlist[] = {' -awk '{print "\t" $2 ","}' /tmp/ka$$ +awk '{print "\t" $2 ","}' "${TMPDIR}"/ka$$ echo '}; static const char *const tokname[] = {' sed -e 's/"/\\"/g' \ -e 's/[^ ]*[ ][ ]*[^ ]*[ ][ ]*\(.*\)/ "\1",/' \ - /tmp/ka$$ + "${TMPDIR}"/ka$$ echo '}; ' -sed 's/"//g' /tmp/ka$$ | awk ' +sed 's/"//g' "${TMPDIR}"/ka$$ | awk ' /TNOT/{print "#define KWDOFFSET " NR-1; print ""; print "static const char *const parsekwd[] = {"} /TNOT/,/neverfound/{if (last) print " \"" last "\","; last = $3} END{print " \"" last "\"\n};"}' -rm /tmp/ka$$ +rm "${TMPDIR}"/ka$$