From patchwork Thu Jun 18 13:25:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 1312094 X-Patchwork-Delegate: jow@openwrt.org 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=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20170209 header.b=BhKI1ymx; 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=DZGeleX+; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 49njPT6k90z9sRW for ; Thu, 18 Jun 2020 23:26:05 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:Message-Id:Date: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=m7wnsosGYzBvba/E26xYV8BwtCauKcjs/vahxv4q3YM=; b=BhKI1ymxSc8jpa qVTXo1ivCAMIH0zTucrEDELqB63Az1xB8GEVUIRqaPIwPx46eZphnbjDQR4iq6DlIJL3uDTQpW/58 CObCSCMjGJUzv9GwQKtxvWlCjZ1dQufQTEjUClkd2NJ5XwRsPWlfYQUvFnVHHWFfR7bnvZHpsRt8x BCjKGsZUM8KMYlsj+a6gnPL6P9S4KU6W+blEteVDWR9TcNEKM3DGvp2NiJ2ITsF5OGT6biVWmPTlo KlC2WPHOPzKbE8a+xVaTWEOd3GZIUowMCVLxnPseCiga7KuHKog2j7Pl6hL8kI3UOcwqkjA5v1/fd E28h3GqpUgJU17z4SZLw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jluYO-00009X-Dk; Thu, 18 Jun 2020 13:26:04 +0000 Received: from mail-lj1-x231.google.com ([2a00:1450:4864:20::231]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jluYL-00008Z-I2 for openwrt-devel@lists.openwrt.org; Thu, 18 Jun 2020 13:26:02 +0000 Received: by mail-lj1-x231.google.com with SMTP id i3so7234853ljg.3 for ; Thu, 18 Jun 2020 06:26:00 -0700 (PDT) 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=TIRabxQCZ+z2Ra7czlOwXCkaWs5a/LptVAYiFFlQ4/E=; b=DZGeleX+41bU5vDmXDMh76aNHivJtvilrQum43ZuU06WnTweCwWpmyWWSJbjECORPF mJOxGno9uVntObvjJZOrWPpiVF62E5nTjrj2Ytdh+AbzwEUObogUrTjRtIi5lPnwv36s u1GsRvOLMgwxysyja+0k6okI37AMi1R9NzN3pyT6U4r+4cFxIwY10fbZOKnvyX51J5qy uaL+KMuxsyWgL5SZR/voLR3d20o8e0mQwOSjjTcX52d46hGQYuX3VvUNHk8/fH+rSlS1 Vbo9Uf8iE4LabxcXM2Y1sQ0Xn/TXClZEbpfCj6T0p4VQPKM2iu/pmbbwBI38oz8ODBIN LKJQ== 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=TIRabxQCZ+z2Ra7czlOwXCkaWs5a/LptVAYiFFlQ4/E=; b=KPJi8S0KMrv9BKMXeu/wtdEkllI2QghQ0QQxzTr2JZryo9w4KLmqMr0EurZAm4aVVX 8LrnXyEq+tpGZoVgCDeApqcQCHTWL9eRXXu7AHmWXua952HCvvfJC6OoQ0p5u+BpGapu OwvkSbcbZ8j++oclQ0/J1TXvTy72WXJ0JO4P6LZrVO8tOPEKx3e2nfhQTNC8eZlqVTxZ kHu3OY+pH4IoSHY+N82H4T52xOw7NrCqvbb5tc+kKZkqbCtnl/SAkFkNN6R0pi8dbU33 nJX+1ptBHEh0dGeY+VyOx5rQMBS1ZeI5WHMMk2qFm4fWM/9CFJT2j8BJxKoDn421IH8P 05tA== X-Gm-Message-State: AOAM5313i7N8sSeA7gvxn1e4WiKfQOldgzE1BoQuleDWuBRMrBcYSMfJ d4+f5f71srX0clvj5sgGSKA7WlIc X-Google-Smtp-Source: ABdhPJzyJldzrxnDVLhCpUQEfrUk4HN6/8g4VdMYTQaptxyhdbTEbL3fdXtda6FYA3pCV9zZe2TCJA== X-Received: by 2002:a05:651c:299:: with SMTP id b25mr2571545ljo.13.1592486758582; Thu, 18 Jun 2020 06:25:58 -0700 (PDT) Received: from elitebook.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id a17sm747846lfo.73.2020.06.18.06.25.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jun 2020 06:25:58 -0700 (PDT) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: openwrt-devel@lists.openwrt.org Date: Thu, 18 Jun 2020 15:25:18 +0200 Message-Id: <20200618132518.26000-1-zajec5@gmail.com> X-Mailer: git-send-email 2.26.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200618_062601_601038_5E950511 X-CRM114-Status: UNSURE ( 8.99 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.1 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (0.1 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:231 listed in] [list.dnswl.org] 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [zajec5[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.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [zajec5[at]gmail.com] -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_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 Subject: [OpenWrt-Devel] [PATCH luci] luci-mod-system: use ubus method for reboot X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= , Jo-Philipp Wich Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org From: Rafał Miłecki It's more generic & convenient than hardcoding /sbin/reboot executable path. procd provides "reboot" method since 2016. Signed-off-by: Rafał Miłecki --- .../luci-static/resources/view/system/reboot.js | 13 ++++++++++--- .../root/usr/share/rpcd/acl.d/luci-mod-system.json | 3 ++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/reboot.js b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/reboot.js index 3b9f450fc..249247bab 100644 --- a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/reboot.js +++ b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/reboot.js @@ -1,9 +1,16 @@ 'use strict'; 'require view'; 'require fs'; +'require rpc'; 'require ui'; 'require uci'; +var callReboot = rpc.declare({ + object: 'system', + method: 'reboot', + expect: { result: 0 } +}); + return view.extend({ load: function() { return uci.changes(); @@ -31,9 +38,9 @@ return view.extend({ }, handleReboot: function(ev) { - return fs.exec('/sbin/reboot').then(function(res) { - if (res.code != 0) { - L.ui.addNotification(null, E('p', _('The reboot command failed with code %d').format(res.code))); + return callReboot().then(function(res) { + if (res != 0) { + L.ui.addNotification(null, E('p', _('The reboot command failed with code %d').format(res))); L.raise('Error', 'Reboot failed'); } diff --git a/modules/luci-mod-system/root/usr/share/rpcd/acl.d/luci-mod-system.json b/modules/luci-mod-system/root/usr/share/rpcd/acl.d/luci-mod-system.json index b29ddb8f4..38ff98dee 100644 --- a/modules/luci-mod-system/root/usr/share/rpcd/acl.d/luci-mod-system.json +++ b/modules/luci-mod-system/root/usr/share/rpcd/acl.d/luci-mod-system.json @@ -160,7 +160,8 @@ "/sbin/reboot": [ "exec" ] }, "ubus": { - "file": [ "exec" ] + "file": [ "exec" ], + "system": [ "reboot" ] } } }