From patchwork Tue Jan 31 15:14:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 1734926 X-Patchwork-Delegate: ansuelsmth@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=rEIBDZXW; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=g6yiDC+4; dkim-atps=neutral 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 (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4P5pZl4LzWz23gV for ; Wed, 1 Feb 2023 02:17:51 +1100 (AEDT) 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:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=DCAGFHMpWlocvy4Kzw12wkzY+814EbKAnWXcFledRgE=; b=rEIBDZXW2pteKC n2kDpwXs7oeZXKWrlSI1Yer9qnPgBn0UVFz+PIjLIl3QCJ5Pt6w0ZkRvmaRbm0+957AsQXAw6kQpF LPnOEJrnBbdyyzTntE6spQdwETSAkhJLJEa5hCkkTAhl2DsQHIrBnK8fd8KTL1TvrWkMTiTyPqK3I wYyli/rWb3SHHZv35/IbXV4Nk6rFYCFKxcaI6ANsXKtUgs889swH8C8UY/yv4f14XFiPqV8NZolFV SzZ6afExY8R0ZVhu7FZ+2D9igCTS/fp9rdVlnRU8LbaN65u0hjGubSrbHSVKMw05L1pLpOVhLkGwU FwCyQETrrQ+BmIcus/5Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pMsLo-008SRV-8T; Tue, 31 Jan 2023 15:15:12 +0000 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pMsLQ-008SMW-AC for openwrt-devel@lists.openwrt.org; Tue, 31 Jan 2023 15:14:49 +0000 Received: by mail-wr1-x436.google.com with SMTP id bk16so14509999wrb.11 for ; Tue, 31 Jan 2023 07:14:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bAb/7LvteuKDWR2a+GGZcqr+IK2io0JZOzhsBMSLzAc=; b=g6yiDC+4FrvK+YqZLoIkb5AckNYwS++9X4w9AUjtPfgoFipB8N+ThTJe7fsm+PTRaV qh75726hA0nmVOdkCgxFG/fmZFDUNyx7mRB2ALWXCVRGPeWusowDAUuTou9CEX5cUoHe w/upb1DDIsDPugRoNg1d6CVLxaiF0OENXIhBjoHcO12dHanZF2yZy641H4WQYaimZNve +z57aYc+aWiM4cSFXjMoWTwIKjrLzWgKqNQdvA4C1W+Pc7VzKT8WHDXVzWkCiRJ1RdcS QbNmLhKFvsKZ+y6bg9VLqt78Mcq0c2tQhz26yLLC2VG6b71tzd9/N1X5eRi692kuwgcv cuCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bAb/7LvteuKDWR2a+GGZcqr+IK2io0JZOzhsBMSLzAc=; b=lLsFI8tM4Y0/IPEADbXsUhSk+viGKwpcMU3JRLWjeemeNPMjesnt3i7qgR6MTJ5rrC 4WgBZz/TklkD2fnRJdq/jx1IsIeNQVPbi1ay/8qBfL+HCPaOeK9rUQ1Ys+bhOl/7hmOU Cfgh4KFezpySBvb0JWBlI6L3lX9c3fo8wf7tVHmJFfsCxp5sSEaC0tFJfekCio1bVDSF DaVKlNHarWdEOABfc92i/N+DFivzyz7nMqfeee3UtEnFlQxeSDkoNnYNztzlbW04Cjr7 tCiOzEWE6QolDoTk6V0R2Poys1PG1//qOVxDO2fEkhvKWQ4qnY6W9BXapjYH7cfhNvII unOw== X-Gm-Message-State: AO0yUKUT9CWdc3qk/Xu7JjwITT5UHFXnrj3aGMahKLuLOZ8J9Nb8/Gwx RpPBJtRSsCF05VMjCMccFNA= X-Google-Smtp-Source: AK7set+0LEi5AiU2F1EYatNi0oIO2wjvXcfWSr/Mbzyt60Ga7eBiBZh+yWBv2QrzvNtH+KmxNKSVNg== X-Received: by 2002:adf:a1dc:0:b0:2bf:b4ca:6bac with SMTP id v28-20020adfa1dc000000b002bfb4ca6bacmr21791079wrv.59.1675178084907; Tue, 31 Jan 2023 07:14:44 -0800 (PST) Received: from localhost.localdomain (93-34-88-241.ip49.fastwebnet.it. [93.34.88.241]) by smtp.googlemail.com with ESMTPSA id z2-20020a5d6542000000b00267bcb1bbe5sm14942811wrv.56.2023.01.31.07.14.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 07:14:44 -0800 (PST) From: Christian Marangi To: Jo-Philipp Wich , OpenWrt Development List Cc: Christian Marangi Subject: [rpcd PATCH 2/4] rc: add support for scanning USE_PROCD and skip running if not supported Date: Tue, 31 Jan 2023 16:14:29 +0100 Message-Id: <20230131151431.15949-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230131151431.15949-1-ansuelsmth@gmail.com> References: <20230131151431.15949-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230131_071448_374972_0D397059 X-CRM114-Status: GOOD ( 14.76 ) 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: Running check is supported only in procd scripts. This cause prolonged execution time since the function needs to timeout. To fix this check if the script USE_PROCD and run running check only if supported. Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:436 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [ansuelsmth[at]gmail.com] -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 Running check is supported only in procd scripts. This cause prolonged execution time since the function needs to timeout. To fix this check if the script USE_PROCD and run running check only if supported. Also provide running info only if the running check is supported. Signed-off-by: Christian Marangi --- rc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/rc.c b/rc.c index 431d3a5..35b47e9 100644 --- a/rc.c +++ b/rc.c @@ -47,6 +47,7 @@ struct rc_list_context { int stop; bool enabled; bool running; + bool use_procd; } entry; }; @@ -81,7 +82,8 @@ static void rc_list_add_table(struct rc_list_context *c) if (c->entry.stop >= 0) blobmsg_add_u16(c->buf, "stop", c->entry.stop); blobmsg_add_u8(c->buf, "enabled", c->entry.enabled); - blobmsg_add_u8(c->buf, "running", c->entry.running); + if (c->entry.use_procd) + blobmsg_add_u8(c->buf, "running", c->entry.running); blobmsg_close_table(c->buf, e); } @@ -112,6 +114,9 @@ static int rc_list_exec(struct rc_list_context *c, const char *action, uloop_pro case -1: return -errno; case 0: + if (!c->entry.use_procd) + exit(-EOPNOTSUPP); + /* Set stdin, stdout & stderr to /dev/null */ fd = open("/dev/null", O_RDWR); if (fd >= 0) { @@ -192,13 +197,15 @@ static void rc_list_readdir(struct rc_list_context *c) int count = 0; beginning = true; - while ((c->entry.start < 0 || c->entry.stop < 0) && + while ((c->entry.start < 0 || c->entry.stop < 0 || !c->entry.use_procd) && count <= 10 && fgets(line, sizeof(line), fp)) { if (beginning) { if (!strncmp(line, "START=", 6)) { c->entry.start = strtoul(line + 6, NULL, 0); } else if (!strncmp(line, "STOP=", 5)) { c->entry.stop = strtoul(line + 5, NULL, 0); + } else if (!c->skip_running_check && !strncmp(line, "USE_PROCD=", 10)) { + c->entry.use_procd = !!strtoul(line + 10, NULL, 0); } count++; }