From patchwork Wed Apr 29 17:51:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Greenberg X-Patchwork-Id: 11518059 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 35B8C1805 for ; Wed, 29 Apr 2020 17:52:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0E5EB214AF for ; Wed, 29 Apr 2020 17:52:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mymailpomona.onmicrosoft.com header.i=@mymailpomona.onmicrosoft.com header.b="b775xmYs" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726493AbgD2RwG (ORCPT ); Wed, 29 Apr 2020 13:52:06 -0400 Received: from mail-eopbgr680062.outbound.protection.outlook.com ([40.107.68.62]:45108 "EHLO NAM04-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726423AbgD2RwG (ORCPT ); Wed, 29 Apr 2020 13:52:06 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fbONeKZmO+jPcGS7vbhcC/wPQs4S3nh+k5mA51QTLwkBJuVJLZgPVaqiwVFqchGozvh7q1H9tUqGlji600Sw414DtTVhWsCblrX4yG9WvrWKRw78bAnTVvbWAu7mSz5rBytiEv9qyBZ51C6nhNZO5dqUlgIjGz3HbeIx7CVaoVhuWvl2/R76R6yfc13k2GaOUTukh+geyMLd0FwbTqidoSG/GDTMs/UMmKo3OhBe8KEk8uuiwoMkxBd0cXvWiALJx/yTKIKKO82PT7cUF6q2m/h3yrQvmST/UPhzj+sd6fYtAl7KF6/fd28t10iZ2FMj/sWrIM7WjzzSojYJGec10A== 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=TpCpcGu3QOHD3I26+nBReI70N1H/unit38n+F2zOgeg=; b=dP0skM3yCOvggnnE7nPHerTnh6EldnqmhkWMmmLL9+u/eIIr0H/3NWPlv8Z8ZNScu596hMie6lUWnjRYyT11/D7Hhr08yCdJjQ3Rc2q7MN8OFhrKO7RSTNovUuAWef5YW2DJI5J89G8rFwho07wl4hVxECq8Yk5iyWcQTtudM85StJ55V2hVlLQXhe0KSxmBZHDly/2A7mT2qYP5kogwPF+1LvUTx2ePTPDdolwGjxYMff4ilTyr9lVSXUFN7XpH4HJblq1GL0pzeMc4r+nIFLhTxg+S1dIp4SMdYJTdwWJZgs13Ve5DAnmstld1lSlsAg6xtVI4HsSsjxuY7NlgUQ== 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=TpCpcGu3QOHD3I26+nBReI70N1H/unit38n+F2zOgeg=; b=b775xmYsA825MgqmJdZpJk6EILQ7RL38y/w2LDu0yO3ekOX5se/dnGT8YpjN19iB0ytmEY+ZAmQznAWBn1P0byuKhLYNZvd64XVO3yg3KP4VmrjFQkyinOa3Ju+SGkHaCf4rEojFz5MSx33aOGJJJ9CB1uoQKNCDFecADCnnhn0= 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 SN6PR03MB4511.namprd03.prod.outlook.com (2603:10b6:805:fd::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2937.22; Wed, 29 Apr 2020 17:52:03 +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; Wed, 29 Apr 2020 17:52:03 +0000 From: Michael Greenberg To: Herbert Xu Cc: "dash\@vger.kernel.org" Subject: [v2 PATCH] mktokens relative TMPDIR In-Reply-To: <20200429055923.GA17016@gondor.apana.org.au> References: <20200429055923.GA17016@gondor.apana.org.au> Date: Wed, 29 Apr 2020 10:51:41 -0700 Message-ID: X-ClientProxiedBy: BYAPR07CA0045.namprd07.prod.outlook.com (2603:10b6:a03:60::22) To SN6PR03MB4285.namprd03.prod.outlook.com (2603:10b6:805:c1::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost (172.251.28.224) by BYAPR07CA0045.namprd07.prod.outlook.com (2603:10b6:a03:60::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.19 via Frontend Transport; Wed, 29 Apr 2020 17:52:01 +0000 X-Originating-IP: [172.251.28.224] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c8e7f4bc-253a-48eb-1493-08d7ec6605a7 X-MS-TrafficTypeDiagnostic: SN6PR03MB4511: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-Forefront-PRVS: 03883BD916 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)(366004)(396003)(376002)(346002)(136003)(39850400004)(8676002)(8936002)(478600001)(786003)(66946007)(44832011)(5660300002)(66476007)(52116002)(66556008)(316002)(75432002)(16526019)(6666004)(2906002)(36756003)(186003)(26005)(6486002)(6496006)(4326008)(956004)(2616005)(86362001)(6916009);DIR:OUT;SFP:1101; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zCmoWo0vhJHt+ELt+cBgwc7lQctSw1yjfZxqqZ5a+5AsZdJS4k5fl0ck6WswjvZf7uDkPm3cc9TLs6gf3W2o+R0e+7FefLnbOXFgf5TGhD91WnTmpB0XnLQMA/7aXEEedY8TeZLO8XAGsJa0WT9bgV+pK4AbqOK7cka9I9Mb7Y0qljlS6ag0yv3Y2z91EeJbvgqMUhkZ/d+1oqgM26i1zVZpO2mixxfvBZbUDI2Qe1By7FJGOlfIVdxm2hKZkUminoH/7IVbEUbKf0St4AA9Xn82xcJIG4mbwoDUTBloCLrysF0EwIpgm41eiwIGXwmGTKGuVCwthQsqPWtx32lIe9SgZ6gpAQp1RL1e3+MQ2Qsns+omhNKZc5cd17pZg1OtIpD6BTupE7FPQzB/iZTw9FBycRpi5FDMfH77tu1423MaeIEfnDIrYGuvsOm6ceal X-MS-Exchange-AntiSpam-MessageData: PFaE8ciIKqTckHTy8lsjMTjI50XRIn6RYPzq+/Qf2mIC8DR0xSOKvst4SRArVIDGNPxNjXLIqGIN9vW0YDj5ptY9pTFx2TAfRFEeeCT/v1hCGIons9MaBuwTkdvShHU+LdvjicTibukVWWt/zTDVAtoyV6lumplcwpN40ACdnEDTDw7FDN+od68kpoPH4Qmeih4ijFsleNKC7BiMen0sxib7Ri2IrIv9wcFGJFC9EY90our5FLWN0p6Irjtl/TNVW7v23fcbQ+DnWztau0UVKQPWIJ/R1dIes2CtcxjvziOXcsHXx8ryKSnKWKD6qcd2bGdtY5mgvNn599LG7WER/pjZiDh8Od4oARf7UlemcWayjmHNT5PmN5SiC7izcg+5zlW/z2T/lrpOcRXtvN/w/G6xlHMDLHhPr9OvVP2cgsXPux8xXbSsAof2VQEPpHO22JPtdFUhb2ppc/mfUktAtymMWfd+l5rN+RCV34CrU6dYn1+l3dP+v4EH9NHb8VduHWknfbOJtbvOAllNPHJbo8K0S5S74HCZkUtAILuye3WaBUzEXrbbKKGpYpO3mw7Rl8ykk/u6KbFv97MuX7Y4hAOO9IBjimDAsbNReQ/ylBAe1JpFRXE1kpVNu7pU1HtVHVVg7TQoNU3yy08vPVvwgrHOy4E1DRLeLp2WjVTXkm2IXmsPVXbHCGd0FhGCUe7meIGyn6x08fruy8aPr59LvrK5nYJexlDuJWe46nXeeyxP6vjud8vYUihmDr9HXVVvyc85X5Nd/1Ma2y3MZDLmK8r1jVa1Cm/4oxGxox6F7bU= X-OriginatorOrg: pomona.edu X-MS-Exchange-CrossTenant-Network-Message-Id: c8e7f4bc-253a-48eb-1493-08d7ec6605a7 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2020 17:52:03.5162 (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: MzLAeVDGldEe3A0XriJZyoPwe7feD6DlCdZoNHYbbRkWjNZVLSxlTJMHqcsrH9lnlJ/XOdmuD782wrdcltma+Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR03MB4511 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. 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$$