From patchwork Fri Nov 19 08:51:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Eckert X-Patchwork-Id: 1556995 X-Patchwork-Delegate: rsalvaterra@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=zL4nrHpT; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HwVrl6kNJz9sRK for ; Fri, 19 Nov 2021 19:56:23 +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: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:In-Reply-To:References: List-Owner; bh=RcIEEaL55jucCYTIipt11V+F3GbfYWMvZGAfRCwOtbI=; b=zL4nrHpTMurS0O StTLxWEQVCy93XDM0eJUQ3mMFTaIJr8nxy8Zf2pwYv81p1+9XeEysEUPs0blOlGc9ZVcxgo3kKkV2 yQtl//E22FLqwBshXMFiAXALsotZsavru7XlQC6bjU23HxXU+PoI15c59YEP8e03Z/4kUyvDMMMki eraEkNLGISw0UpkkZlUVOa/ILYBjg9vq6cbx8uxz4ATBT8695GEIyjH9y7uH9bRSNBrglkoisUiqI 53oOp57G2dze7g1hAxkPtvUsch64tW8vW3hb9cZTp0TNcLeWPU3JADC1vhqqj4vFI+zqSp6ZJuz16 o2ZJZHmsnP7lGSvaXdng==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mnzcB-009qOm-G2; Fri, 19 Nov 2021 08:51:23 +0000 Received: from mxout70.expurgate.net ([194.37.255.70]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mnzc7-009qNK-Ry for openwrt-devel@lists.openwrt.org; Fri, 19 Nov 2021 08:51:21 +0000 Received: from [127.0.0.1] (helo=localhost) by relay.expurgate.net with smtp (Exim 4.92) (envelope-from ) id 1mnzc0-000264-Bv; Fri, 19 Nov 2021 09:51:12 +0100 Received: from [195.243.126.94] (helo=securemail.tdt.de) by relay.expurgate.net with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mnzbz-0002Vg-H5; Fri, 19 Nov 2021 09:51:11 +0100 Received: from securemail.tdt.de (localhost [127.0.0.1]) by securemail.tdt.de (Postfix) with ESMTP id 37580240041; Fri, 19 Nov 2021 09:51:11 +0100 (CET) Received: from mail.dev.tdt.de (unknown [10.2.4.42]) by securemail.tdt.de (Postfix) with ESMTP id CF090240040; Fri, 19 Nov 2021 09:51:10 +0100 (CET) Received: from localhost.localdomain (unknown [10.2.3.40]) by mail.dev.tdt.de (Postfix) with ESMTPSA id CFCCC20FEA; Fri, 19 Nov 2021 09:51:08 +0100 (CET) From: Florian Eckert To: jo@mein.io, dedeckeh@gmail.com, Eckert.Florian@googlemail.com Cc: openwrt-devel@lists.openwrt.org Subject: [PATCH] firewall3: fix locking issue Date: Fri, 19 Nov 2021 09:51:02 +0100 Message-ID: <20211119085102.8338-1-fe@dev.tdt.de> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,URIBL_BLOCKED, URIBL_DBL_BLOCKED_OPENDNS,URIBL_ZEN_BLOCKED_OPENDNS autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.dev.tdt.de X-purgate-ID: 151534::1637311872-00000A80-3665FA53/0/0 X-purgate-type: clean X-purgate: clean X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211119_005120_102449_5832B830 X-CRM114-Status: GOOD ( 14.59 ) X-Spam-Score: -0.7 (/) 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: By calling the command 'fw3 reload' several times at the same time, I noticed that the locking was not working properly. It happened from time to time that some firewall rules were present twice in th [...] Content analysis details: (-0.7 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [194.37.255.70 listed in list.dnswl.org] 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 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 By calling the command 'fw3 reload' several times at the same time, I noticed that the locking was not working properly. It happened from time to time that some firewall rules were present twice in the system! By removing the 'unlink' systemcall, this error no longer occurred on my systems. Since fw3 does not run as a service, it makes no sense to delete this lock file every time a filehandler is no longer open on this lock file, because fw3 binary is not running. If fw3 does run as a service then we can remove this lock file on service stop. But this is not the case for fw3. Signed-off-by: Florian Eckert --- utils.c | 1 - 1 file changed, 1 deletion(-) diff --git a/utils.c b/utils.c index 17d5bf9..92e966c 100644 --- a/utils.c +++ b/utils.c @@ -397,7 +397,6 @@ fw3_unlock_path(int *fd, const char *lockpath) warn("Cannot release exclusive lock: %s", strerror(errno)); close(*fd); - unlink(FW3_LOCKFILE); *fd = -1; }