From patchwork Mon Aug 28 14:12:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Gothe X-Patchwork-Id: 1826759 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=SJut+o4T; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=genexis.eu header.i=@genexis.eu header.a=rsa-sha256 header.s=selector1 header.b=iN7DO557; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (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 4RZCMz0MVCz1yfv for ; Tue, 29 Aug 2023 00:18:38 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-ID:Message-ID:Date :Subject:CC:To:From:Reply-To:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=m5osW9PTazsE9d/DQhQnNt2T+rb79Z9Pzv3+Xwj1J0I=; b=SJut+o4T+KZobb uhNGErDg+8X5t5bZJPLNNOUpW6OmObUnKB1GDXhLHQ18EHIE3isu2IPzmOzSZ2sGsTqdVLLu2V0UG OMF32BGn8GiG2ksntKFjIR3gpBHcrmcaOqHDDqZiz3qHgEyJ/N9IcJ7WYUA04V/pb145O0ORCq7pZ yEfDGAvEnds2AuqVsCp4fd9lsQthWN9AkwK+bZAViPCAWCMcEsaYnGzUJ529ozJ9TTcbA42HjSA9b wl3JPBY08UdDT0ttXdgU/47vZgIU/gBmQ1p4iEQ69xzczPsEWYv9CoNaj1zHYUu2B5QRPJQFkK3OQ 9jL8b4WxoCH4zPr7Pfbw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qacyX-009h4j-1e; Mon, 28 Aug 2023 14:12:17 +0000 Received: from mail-db8eur05on20603.outbound.protection.outlook.com ([2a01:111:f400:7e1a::603] helo=EUR05-DB8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qacyT-009h44-1r for openwrt-devel@lists.openwrt.org; Mon, 28 Aug 2023 14:12:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E6GlbN49eR35wx+qh4hkFMZIemrSbz5mNhHyLmAOH97ad/W8QdjgRF+rlHiT5uZbufcCxdNBrmvTEExSU+k0laSpT3OCfC5HXuRANxgHW75M8oxkIkvpLXRrVC8buJX1q0UEkDC7vEgbSZUrxpEUJNLInhz7fk6w49CUBMebCoyqe6EoERQpdjS2A62AUeJ6ZVyIAD2Ju8QDv5n4E2k43V5WP+SG7MCA+eVeCR2GfJGE6m79MkfG/DCB320GSXzDI69ue+rmdTpTiAiZxK2RtP1SKeM/V+ytlE7dLLr27GkCoGt2ivEOa4UqZCa52VGzkESZFThDS1dVF3ASXNX1Lw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=t8eJyUyiPOH23TueJFGB0M2xbWt+Grug4275xVjAqYM=; b=G6FKPZZo8Z4bnXqil67kjgqpZbV5p5YQMo0eH+LHS/gLAb2cQehCDtuM65VbOV4cpXTUYlOPSrdo2LdO1MECjPFnEOnxNPTtaeW0vRXlz2TtKWeRuSS91YOakjM3NcscuZnATw2fjNc4zq5laFG0NMAETh77gYQ1Pdn3e8XN+G52WBd8mzlCuxV1XoKAWDQzUITwc0SGke2mHR+3iwHMbfjAhJ6+Buf6MoewygAsmul7LA8DIZHObVrgNJu0xbZD5T825w210ru7HB1CrAehY0u/uPltkyMF2NgT9HjwcLJiRcDkk3O2NSx+2oSCaxvC0ahjK/Dz72C1qb70I6XO9w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=genexis.eu; dmarc=pass action=none header.from=genexis.eu; dkim=pass header.d=genexis.eu; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=genexis.eu; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=t8eJyUyiPOH23TueJFGB0M2xbWt+Grug4275xVjAqYM=; b=iN7DO557H1CiKILouH+rCR4bm3tkwlm9fgQoHonoygRayAD6hzU7xyXzKLW/bLEpfgZDnQYKPAjUyS2n9Jqrn2PvrXEi4NRybi2CcPfWIipqp7UOJKuEleXEhEgJfaYlA9XLHLGZy5RLYewqtiFRflyMkL5fZ+eI9b7cY/kYYoM= Received: from AM4PR08MB2770.eurprd08.prod.outlook.com (2603:10a6:205:d::11) by AS8PR08MB8568.eurprd08.prod.outlook.com (2603:10a6:20b:565::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.34; Mon, 28 Aug 2023 14:12:01 +0000 Received: from AM4PR08MB2770.eurprd08.prod.outlook.com ([fe80::8d61:65dd:8cbd:eba3]) by AM4PR08MB2770.eurprd08.prod.outlook.com ([fe80::8d61:65dd:8cbd:eba3%5]) with mapi id 15.20.6699.034; Mon, 28 Aug 2023 14:12:01 +0000 From: Markus Gothe To: "openwrt-devel@lists.openwrt.org" CC: Markus Gothe Subject: [PATCH procd] Fix retriggering of init.d-scripts. Thread-Topic: [PATCH procd] Fix retriggering of init.d-scripts. Thread-Index: AQHZ2bmdGpCACKwOoEKqog7dazMqpg== Date: Mon, 28 Aug 2023 14:12:01 +0000 Message-ID: <18ea7470-f507-6424-b21a-00ac0f5673ba@genexis.eu> Accept-Language: en-SE, en-US Content-Language: aa X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=genexis.eu; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AM4PR08MB2770:EE_|AS8PR08MB8568:EE_ x-ms-office365-filtering-correlation-id: 70613d0d-a0c3-4a51-ac2e-08dba7d0bf81 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: dGWfmlI4yh+H1dhVmGoH5rBLUf9Ja/shAGBbjcJLRr+t28owPX6ZNDLZXWNckTtRji6Y4UONV3k8cZOFmF++2ORNZcAWox8DyvnIV6BDtr3WfCkMSFsGblf4tW8IuwWs0kF3mJOK8TB3xGXhiQVCS+CPBHuyLfsAHbxABN5/mrypVWBCMhMOX1y7fYFWtGFo75aq64JAcQWBfctbfBNb4XHZf3qQNEZtlqTHyDrpotWIITsIZ6l/e/2cN9sJ8Ab8+gAET1ubS0GxshpYmfEKJbiluxkjrOIn6IOjpEDD0CkuJfEU7ALhLzvsYuc1rrDwyJBCnJBibIMY/yN7LzJhE2TEJnSdpbt2+XYL5hG0DfCO3zj0zZ1hzPUvtiaXj+gwwbuPvXsPY4KuavXZJ8NlwMPXNfKH9YM5eAwDn4Fc16P/1DSS8DVeGpR5c1nw4fUvMXPOkKPZ0hpx88nuOnD3hNSXgupK6qUgmqq9+rVvXm+ShleyL3SRqpTpcCLbUDZx0vPf/YspCU/rTBRbHbUqMyMWoh8acmTjWIfQOOtzw2dSJdde6EqNz0SONUHmmVUcT/Bx9110zeesnOwMEU5mxfxkQ6zfxYsHi4fD9cMUAurail8Ntr12jYSAwfRNGOOc8QaXlEVDEe5voUKKj3utUvK/qfJTnRyyaE2cP6JbHWLWkf6CvoCHkw/i/8JFeZOZ x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM4PR08MB2770.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(376002)(396003)(136003)(366004)(39850400004)(451199024)(1800799009)(186009)(71200400001)(6506007)(6486002)(2616005)(83380400001)(26005)(478600001)(6916009)(6512007)(66556008)(64756008)(316002)(66446008)(8676002)(44832011)(5660300002)(66946007)(76116006)(107886003)(2906002)(66476007)(8936002)(4326008)(31696002)(86362001)(36756003)(41300700001)(38100700002)(38070700005)(122000001)(31686004)(45980500001)(43740500002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?04y1Mwj1ogw+bidLIOQ69+E4TV7E?= =?utf-8?q?AY7id00+7cJQ6SrghXzRdJkt+GDULoeDtvdTnznFRgjzm9JinGqTzu+NGdTXcKL6O?= =?utf-8?q?7fFmIcMvoalb5Xdc7q+gNedRn9idFmPn2mmSIdRudj7DNA5bQ8qOYaLf5hOiEbcPA?= =?utf-8?q?LS2Fzts3btsAlvBr8HpSgmW8m6z4Bd/B3bYDguLKTZ8Aolb7t6PFKucZLwNUz2hYd?= =?utf-8?q?pnw8hb0FlF9OWNe+cIFD9wTXdA914P4SmMOeC25w9Mgl6Q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jAs7Y?= =?utf-8?q?A9w7kQbmL9VTQqBxBvMr6i5T1OTjTf8+gk0BGnik83W9eYAEz2z3KuaC8mHJ2tE9E?= =?utf-8?q?Ks+AdPBlCwc+XluVLaT57WDKhLC2Y3BgCrAlF2uw9W6goUfrkR9hRY43N0L5BHDo1?= =?utf-8?q?l9yIqKvscb5PeTevT60ARkK6FpMfq8U9CTNqtn9iqCKyxMPsQCl+/L9Uww8CniJsm?= =?utf-8?q?B0zbu5KSpJR9iklvHmNc0UOV9kfm2s7NbDlejWgm5MXlp4h1pa+XNTdzwu3ACZSTZ?= =?utf-8?q?IRQJxnr/IEjeXBiqWLS6XtEePeGCIFPXSxW4PHnVk9MXLWfIA0MdenIcS+Ft97/xB?= =?utf-8?q?f0Q9SPxzkv6LcsqHFtS01ArXmOvXZJYt1UlDBDwX5PLyx7/7Tzq9Up2P/8CXGbcav?= =?utf-8?q?nX2+GqnjgBMc?= Content-ID: MIME-Version: 1.0 X-OriginatorOrg: genexis.eu X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: AM4PR08MB2770.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 70613d0d-a0c3-4a51-ac2e-08dba7d0bf81 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Aug 2023 14:12:01.0911 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 8d891be1-7bce-4216-9a99-bee9de02ba58 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: JsXTox0CzOiJCBihHP18AN+/exIr9q7IZgpRLs4BAie3HNxr6UKfsyhXE/QKrNmIaaTe/a7FXVgCICRps022CA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB8568 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230828_071213_965801_585FF94A X-CRM114-Status: GOOD ( 11.93 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Fix retriggering of init.d-scripts which calls commands dependent on functional STDIN/STDOUT/STDERR. If we just close these file descriptors those commands will not work as expected leading to unwanted consequences. If we instead redirect the file descriptors to /dev/null, we will end up the same end [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Fix retriggering of init.d-scripts which calls commands dependent on functional STDIN/STDOUT/STDERR. If we just close these file descriptors those commands will not work as expected leading to unwanted consequences. If we instead redirect the file descriptors to /dev/null, we will end up the same end-result and these commands will work as expected. Signed-off-by: Markus Gothe ---  service/trigger.c | 13 ++++++++++---  1 file changed, 10 insertions(+), 3 deletions(-)      blobmsg_for_each_attr(cur, cmd->data, rem) diff --git a/service/trigger.c b/service/trigger.c index 4af1474..324d78e 100644 --- a/service/trigger.c +++ b/service/trigger.c @@ -118,9 +118,16 @@ static void trigger_command_run(struct runqueue *q, struct runqueue_task *t)      }      if (debug < 3) { -        close(STDIN_FILENO); -        close(STDOUT_FILENO); -        close(STDERR_FILENO); +        int devnull = open("/dev/null", O_RDWR); + +        if (devnull >= 0) { +            dup2(devnull, STDIN_FILENO); +            dup2(devnull, STDOUT_FILENO); +            dup2(devnull, STDERR_FILENO); + +            if (devnull > STDERR_FILENO) +                close(devnull); +        }      }