From patchwork Tue Feb 23 14:43:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Dobrovolsky X-Patchwork-Id: 1443508 X-Patchwork-Delegate: hauke@hauke-m.de 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; 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=VV8yBi/m; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=Q5HqyCas; 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 4DlMLL5hwzz9sRN for ; Wed, 24 Feb 2021 01:46:02 +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: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:In-Reply-To:References:List-Owner; bh=KZlkW4B4zo4UVTHxIBuq/qpySVON4a5fMpyHC3o/Oxc=; b=VV8yBi/mfXC1ErWsOqRG8sYrTI 4YvELikA82aeCJi1uArlyuCQHEIOL6VaS2T/J62EPGlkJhz+P6vec0YHs+2xcqL6aHfTOl8lxsXZu qfk9aXS3uJQ+gkULZG5FWECwj4csOZZFsdhHni9aJrDKwbI6fRiqne8LoZz2Srh5XvmpRjmJn3GhQ P631oXa5KXscjkk2bIV4xXe3uVhIkhGilXbn1nVSzOo2l+izA2L+UQ1Oxge8T7E3Xr/g4RHkgEksb /Ngggxfh+SIbD1BnyG321tel7zP8nCyQr6yoBeS33N2ROgw3RtmkozYPJ5zmUSoLkMIVYFZdi6P4q PocHo/MA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEYuf-00057z-SA; Tue, 23 Feb 2021 14:43:45 +0000 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEYud-00057I-Qu for openwrt-devel@lists.openwrt.org; Tue, 23 Feb 2021 14:43:44 +0000 Received: by mail-wm1-x32c.google.com with SMTP id o10so1738707wmc.1 for ; Tue, 23 Feb 2021 06:43:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=/TnyDd5ZTFnjSdBGNwmtHMJe2clkGyN6bbh+ygDxsBU=; b=Q5HqyCas8WF2RtTT3j/haCMZAwdgnPeltsr1WluNoLRkgrr9ASqzhwPXSr9ZOydqOC 2dZXA3j4iaCRrtDURPYmgXi7YVA7ubopG5N3G4HP1V+npcHbYwISCUX3LuLddoh/2DVK H9vZ7lG4yBbdUJkuoSkpq3btBm4EIJUECA88hOnkAVNrxQyB8f+cJEfoEb3CcZ1iKMO1 W4cRGsTYR4UoNuIXEMNs1TQooDJm/lq8zxLIWAbjcSMZDp3GigZB4GO97Eeg3ssSwoJU nh7m+v3O2I/xblI4Nb0H7bCsRz2hyYvwAQd0mD42Gli4SrSkOS0M1rBC0h53t53NtLd7 +a1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=/TnyDd5ZTFnjSdBGNwmtHMJe2clkGyN6bbh+ygDxsBU=; b=CyVqw3/mYMs1s1YomXdDqw9Rw0os+5ZkV/jJz1pqqoMwDmcGiIXr6kUEWlNFuofZLd oBJR6aCl96FoLMLAsmmIT41iPcj01/7DoUJOAD71qWnr3C1i7BuqDx7hmV6sT8GC6X4e GB9fKwl3tdooWmBxjxvBkQkakZkh1US7zBXyOtRvfNNW3mtDLQhAVmyFm6ZtvumtUqOv HsbXL2A2E3SOXcrE2t4Zyw7b5nsCrTpnTjve1y/GalzVX+pTrK0F125NDXPHyrYvMzAA gOFBvHEE7jPqRD1/8Qf8AY9+qo/Z0O9nLmv/7QvzaosePz4XYNLm4XHK9Jt1SCT7JMjg FT9w== X-Gm-Message-State: AOAM533Ve274V+MsI+gxwDhXfz00ictrIbFLmO5ZNyfEj0P/sdD7IcRU y4u1H7Cnrc4Z8WH3LMMR5X5zhbBFInUyvQ== X-Google-Smtp-Source: ABdhPJwj64nLab8qc3Vil7YE5fJrY1kKFvcN53iG+4Km8ZYEmZkICf0J1NrkwDF0zlY7QOJXw7Ij1w== X-Received: by 2002:a1c:8005:: with SMTP id b5mr25714553wmd.130.1614091420504; Tue, 23 Feb 2021 06:43:40 -0800 (PST) Received: from localhost.localdomain (ip-95-220-37-14.bb.netbynet.ru. [95.220.37.14]) by smtp.gmail.com with ESMTPSA id c12sm21392338wru.71.2021.02.23.06.43.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Feb 2021 06:43:40 -0800 (PST) From: Alexey Dobrovolsky To: openwrt-devel@lists.openwrt.org Subject: [PATCH] busybox: sysntpd: option to bind server to iface Date: Tue, 23 Feb 2021 17:43:02 +0300 Message-Id: <20210223144302.1670-1-dobrovolskiy.alexey@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210223_094343_905741_9654CB43 X-CRM114-Status: GOOD ( 11.27 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) 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:32c listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [dobrovolskiy.alexey[at]gmail.com] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 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_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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: Alexey Dobrovolsky Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org NTPD in busybox has option -I to bind server to IFACE. However, capabilities of the busybox are limited, the -I option cannot be repeated and only one interface can be effectively specified in it. This option is currently not configurable via UCI. The patch adds an interface option to the system config, ntp section. Also sort options for uci_load_validate alphabetically. Signed-off-by: Alexey Dobrovolsky --- package/utils/busybox/files/sysntpd | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/package/utils/busybox/files/sysntpd b/package/utils/busybox/files/sysntpd index e4a070762f..c4c311c242 100755 --- a/package/utils/busybox/files/sysntpd +++ b/package/utils/busybox/files/sysntpd @@ -30,7 +30,12 @@ get_dhcp_ntp_servers() { validate_ntp_section() { uci_load_validate system timeserver "$1" "$2" \ - 'server:list(host)' 'enabled:bool:1' 'enable_server:bool:0' 'use_dhcp:bool:1' 'dhcp_interface:list(string)' + 'dhcp_interface:list(string)' \ + 'enable_server:bool:0' \ + 'enabled:bool:1' \ + 'interface:string' \ + 'server:list(host)' \ + 'use_dhcp:bool:1' } start_ntpd_instance() { @@ -49,7 +54,10 @@ start_ntpd_instance() { procd_open_instance procd_set_param command "$PROG" -n -N - [ "$enable_server" = "1" ] && procd_append_param command -l + if [ "$enable_server" = "1" ]; then + procd_append_param command -l + [ -n "$interface" ] && procd_append_param command -I $interface + fi [ -x "$HOTPLUG_SCRIPT" ] && procd_append_param command -S "$HOTPLUG_SCRIPT" for peer in $server; do procd_append_param command -p $peer