From patchwork Tue Oct 27 06:27:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Harding X-Patchwork-Id: 1388288 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=living180.net Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=mw4axI+Z; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=living180.net header.i=@living180.net header.a=rsa-sha256 header.s=fm1 header.b=PWAFdT3W; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm1 header.b=kaP0RrQz; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (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 ozlabs.org (Postfix) with ESMTPS id 4CL1yL2gWFz9sSf for ; Tue, 27 Oct 2020 17:29:30 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=3InagL+0I9JKNgXsMWYYJ9kBr2Lc+wHZ1I3vEzN76xg=; b=mw4axI+Z1yCy909iwJ1YG6O6H ccy3GkNfnqCHyju1b7QKNTC716YCkNXZrXRfajgLCxzvnpRqHjKALH2rj0W+cgTUh0i2cWW9Fg4a0 YdWKBtoo6eMANtBLvBZHu264znfDiGWDTN/b30jUB1aVDWM3xRzuD8OCGBJGyYaEDmhC4NmzvZKEn f48rbyApvshy5WDgiCCCWKqc/KjD22jVgbCf2yr67yli8hmZFK2Qff7Kc2NKVDXYQiAGozTbjpb6l jBe/oQEISZn2hLKJDvvQfAnOYMOfW5HovLGtEY0rDLy3orkHCFlm71enc2Qy/Zzi+SHuM8Q0N0XEr bPrprRQMw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kXISk-0004lm-8v; Tue, 27 Oct 2020 06:28:06 +0000 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kXISg-0004ky-Ma for openwrt-devel@lists.openwrt.org; Tue, 27 Oct 2020 06:28:04 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id 5A668A13; Tue, 27 Oct 2020 02:27:57 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Tue, 27 Oct 2020 02:27:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=living180.net; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=z25CIjJUKEDqc WqJM47rrdKMKohGRxqphdYjUXRbPvg=; b=PWAFdT3WDbza7AoRVwafu0DolFR/T ivHuX/IEMZsai1jRWQdEfir3neYIR12+ZIxRkXjXXJOaJnm5GPbI0LQMe2j6Bo1z 6VXc/QzFsDnQB8Sl+VsdfrLgH/N7nruXUrWf/BM02upEPhx3I5gWXThGnqKSzNl4 u3krN9O6Ym0+E71Cu3DfIB8NsTg9IaSim0ZSJgYxxz4hJ/PjF50etSHiJXWBbMBo AJWlkR330/zbNkBIpLq35XXDVOjsxXXPWzduntaQKdvAoIdhY6EnlEC7s4h+WGNC Cq7cyH4hamFLK1IH4000xSWR5PqQ6fnu6Rkvy9X4DYGgB6iY4sS6St9bQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=z25CIjJUKEDqcWqJM47rrdKMKohGRxqphdYjUXRbPvg=; b=kaP0RrQz Ni0SrMBvOoizUnFZe5G890Yp4LWoLPUxPiHB+iwdcvNlvqLW5Ws6jhrHoPP92i8m mGvtf8EhagxuV9W7jYV2QJ1jNWn5eKtAwgJ/+/0xjNofF30v8r7V7WJ++iU3CP/Z CJ5dlelu6YfrTR5HtXg9Ii5rVmfZMnffhkP1uCHznRxRZLyxEG0Qszj3DMWsN78X vwDROr4wG4r0VPeJpIXgrpiboybGW/iDcQmUfnvYqhzHYBHykCEaeA/ErrDMiDHs cGnPloxVWyb1U6Yj/R+rk/ExoIJ+cgmwXhclMdR7soVnPQNmNuZ9WJmtZA3UHawm ict6IfYcGUb5zg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrkeekgdelgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepffgrnhhivghl ucfjrghrughinhhguceoughhrghrughinhhgsehlihhvihhnghdukedtrdhnvghtqeenuc ggtffrrghtthgvrhhnpeejjeeuieffteffhfeviefhueetffduvdfgfedvveetteeiveei feelhfefueelieenucfkphepudejiedrvdekrddukeejrddukeenucevlhhushhtvghruf hiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpeguhhgrrhguihhngheslhhivhhi nhhgudektddrnhgvth X-ME-Proxy: Received: from localhost (unknown [176.28.187.18]) by mail.messagingengine.com (Postfix) with ESMTPA id CE8433064674; Tue, 27 Oct 2020 02:27:55 -0400 (EDT) From: Daniel Harding To: openwrt-devel@lists.openwrt.org Subject: [PATCH firewall3 v3] ipsets: allow blank/commented lines with loadfile Date: Tue, 27 Oct 2020 09:27:01 +0300 Message-Id: <20201027062701.2627547-1-dharding@living180.net> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201026062835.1968632-1-dharding@living180.net> References: <20201026062835.1968632-1-dharding@living180.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201027_022803_008745_B3F22228 X-CRM114-Status: UNSURE ( 8.74 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.9 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [64.147.123.19 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [64.147.123.19 listed in wl.mailspike.net] -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Henrique de Moraes Holschuh , Daniel Harding , Jo-Philipp Wich Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org When loading ipset files using the loadfile option, skip blank lines and lines that start with '#' (disregarding any leading whitespace). Signed-off-by: Daniel Harding --- ipsets.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ipsets.c b/ipsets.c index 280845b..ba31e64 100644 --- a/ipsets.c +++ b/ipsets.c @@ -16,6 +16,8 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include + #include "ipsets.h" @@ -337,6 +339,7 @@ load_file(struct fw3_ipset *ipset) { FILE *f; char line[128]; + char *p; if (!ipset->loadfile) return; @@ -350,8 +353,13 @@ load_file(struct fw3_ipset *ipset) return; } - while (fgets(line, sizeof(line), f)) - fw3_pr("add %s %s", ipset->name, line); + while (fgets(line, sizeof(line), f)) { + p = line; + while (isspace(*p)) + p++; + if (*p && *p != '#') + fw3_pr("add %s %s", ipset->name, line); + } fclose(f); }