From patchwork Tue Feb 18 03:50:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Greenberg X-Patchwork-Id: 11387817 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 8446D109A for ; Tue, 18 Feb 2020 03:50:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 54A1220801 for ; Tue, 18 Feb 2020 03:50:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mymailpomona.onmicrosoft.com header.i=@mymailpomona.onmicrosoft.com header.b="xViaNHfe" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726276AbgBRDu4 (ORCPT ); Mon, 17 Feb 2020 22:50:56 -0500 Received: from mail-dm6nam12on2068.outbound.protection.outlook.com ([40.107.243.68]:23807 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726261AbgBRDuz (ORCPT ); Mon, 17 Feb 2020 22:50:55 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hsbT6wx8RNivgz16Rr2m+oVnmPY/tyOvM1rqwNN8C1tdSJpK6C85jvhuFJ8Ip+16qjbEAaC//TEXANLHNlLvMwKylgq9mB9h46ULEeO+7DjkIpR9p9/fNiJDaVIT7MfAW4Ot0vx5uerTBzMJo64a3zwUrhBVtFwImnQn5FohXTL17jGZ5QCkk1MsRE7IVWAi/Swt4CSVJdUtOfQ3yZH9o+AVmSOfjWJAWGLcLijjdQXOJ7rYH/kMC8Nu/kR3DTkCPfA9AEAUwofyWayf9B9LC7AHR79GRgt5pibxPZfrynjCu6n8FLxyBjyR8TqNoZ94BTjCNQgJJ+aAj3h5Pc+yhA== 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=f8VwSR48sKr70Dw+Bw11FT5rmOAS7EckL4hLXjCdvIU=; b=mkiPkAFRqfJk4jU3e9vYTpZmOGUt/HNtIropvcYLEBEAvtL1oLRB4r7KYQc7w9bFcJDVXvDjmk4i3el3iCR/3kWAMnrJiR3vj0PrbicD1Ocu2nyZUWVabhwQ2za0mHkxR9u1T8X3Bg912GGp7Pmoz9m8Xn5KOCqEdClHRYC3xVt0pM0lo7Vd94fk6jDp0CVppWacIACRwtkSArNG0g7Whh5SJJXJrWJLccR6wL+vgQpKrVKWzgMPBCSktgwGRn/tOI9rrSEyph4bYa9izY0nMHAoqUD8PMsczmQTleb4WyE7rUqsfyaZ+2CrNRMNeHY5Ao8AiIuoDOMfG5MvfntEpw== 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=f8VwSR48sKr70Dw+Bw11FT5rmOAS7EckL4hLXjCdvIU=; b=xViaNHfeFQrULbyTK3Htb0GWkxkcVBXnGk6aX08kcxZoYrcOE6NA3KdhaPvEtFuxkWv+d8EfxK3AWN3RyHcbQRif09xBCV7Lma9N+huZLJFXCjWRNYzMpcHoO94shDesw7WYZV1UvhTf9Ykn0/amqqXY8SqOiJOoJoyO/FRRd4M= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Michael.Greenberg@pomona.edu; Received: from CY4PR03MB3080.namprd03.prod.outlook.com (10.171.248.33) by CY4PR03MB2581.namprd03.prod.outlook.com (10.173.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2729.22; Tue, 18 Feb 2020 03:50:52 +0000 Received: from CY4PR03MB3080.namprd03.prod.outlook.com ([fe80::fcb7:4bbe:740f:2c60]) by CY4PR03MB3080.namprd03.prod.outlook.com ([fe80::fcb7:4bbe:740f:2c60%5]) with mapi id 15.20.2729.032; Tue, 18 Feb 2020 03:50:52 +0000 From: Michael Greenberg To: "dash\@vger.kernel.org" Subject: [PATCH] mktokens relative TMPDIR Date: Mon, 17 Feb 2020 19:50:50 -0800 Message-ID: X-ClientProxiedBy: BYAPR03CA0025.namprd03.prod.outlook.com (2603:10b6:a02:a8::38) To CY4PR03MB3080.namprd03.prod.outlook.com (2603:10b6:910:58::33) MIME-Version: 1.0 Received: from localhost (172.251.28.224) by BYAPR03CA0025.namprd03.prod.outlook.com (2603:10b6:a02:a8::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2729.23 via Frontend Transport; Tue, 18 Feb 2020 03:50:51 +0000 X-Originating-IP: [172.251.28.224] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 06fcbe38-8958-4025-9cfb-08d7b425bfa8 X-MS-TrafficTypeDiagnostic: CY4PR03MB2581: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-Forefront-PRVS: 031763BCAF X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4636009)(396003)(366004)(136003)(346002)(39850400004)(376002)(199004)(189003)(66556008)(66476007)(66946007)(2616005)(2906002)(75432002)(956004)(186003)(44832011)(16526019)(36756003)(86362001)(26005)(786003)(8676002)(6916009)(478600001)(8936002)(5660300002)(81156014)(81166006)(52116002)(6496006)(6486002)(316002)(491001);DIR:OUT;SFP:1101;SCL:1;SRVR:CY4PR03MB2581;H:CY4PR03MB3080.namprd03.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; Received-SPF: None (protection.outlook.com: pomona.edu does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fdvYn1J0bKD9rMnxtDqYy6qtPL9axiYhVC4LicfrXBCHTvFg9r3MBdBtE1AP+jbqQCvEmT+h5dxt5Cu0tZfx1+mIMf7kYeV5NiBaaoI7DrG7jlvWWPvAAwi+J+KBTr8wYvDBXzpoXz75aG8YwUTfxr2CwDaSN9CyFus9e6y+DN7V3BfCznbRsb987XBsAP65fh4PssFVtnYBTzCwlYg3m4abUlOw/5DL32/2quMOCCSB16PCBOs1ZHHlmBVCLdD6B0wN4OxkydIcgozBBNLzD7DOx9OOmfFLuzJIquIk7I5e1u1vPShxWAfQP3Zy0X7XZh9shHIvZt0DeSIzrwgrQ9p77IGkespTaKg+ZsoMlx24nNNT/dNpgfBbycUe4ZOn1uujTj4B68MHzR36wqPV6YoNcvuB5KUb6ORfq+HXRgwXCfoXYjBZxtWaEC4MIm+PPLZnDD1d1sVOMh9THQtPC2MQ7G2/haOKeWfnczF2ppo= X-MS-Exchange-AntiSpam-MessageData: uuKvqqblBk16hqYIS0awAftls+tVN+hs+cM/KgbAdctGkTGjRAb0yDaz+zjrY9EcNI7p3waQuJKyzn99sHWnLHDiC9etGDlv9Kj+lJ1klE90T7YoWD/xb8cVGquELTy8m2GPX2kAm/zKl/VQBAq68Q== X-OriginatorOrg: pomona.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 06fcbe38-8958-4025-9cfb-08d7b425bfa8 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2020 03:50:52.1830 (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: N0AFmnmsn4403exnC+eiIQWz2NJ9SsK0tsDFXm7+E19HEMqI7b8298pgdSyowkj2NKWRg9wqhkyakbbWa0Y2ng== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR03MB2581 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. 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$$