From patchwork Thu Oct 6 17:59:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Roevens X-Patchwork-Id: 6043 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4MjzwF212Wz3wgN for ; Thu, 6 Oct 2022 18:09:01 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4Mjzw80DXSz2Zk; Thu, 6 Oct 2022 18:08:55 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4Mjzw728Qhz300b; Thu, 6 Oct 2022 18:08:55 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4Mjzw62mNgz2yfc for ; Thu, 6 Oct 2022 18:08:54 +0000 (UTC) Received: from knopi.disroot.org (knopi.disroot.org [178.21.23.139]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPS id 4Mjzw61sTsz1GW for ; Thu, 6 Oct 2022 18:08:54 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id E02BF4C98C for ; Thu, 6 Oct 2022 20:08:53 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with UTF8SMTP id irrfPcoiReES for ; Thu, 6 Oct 2022 20:08:52 +0200 (CEST) Received: from chojin.sicho.home (amaterasu.sicho.home [192.168.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (no client certificate requested) (Authenticated sender) by hachiman (MailScanner Milter) with SMTP id 1029D73542; Thu, 6 Oct 2022 20:00:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1665079223; bh=yyr9r7oQWZjPJ0qf+VAreyrxpn9yuyVhSrPvpR1uBpw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=T00n/VlFPpl7AWY8vwNdEWtoyS5R0dia+6+VhZxvuz1GPVW7gZ6BUEIPiCx5Qyo+4 WGL3NjacxJA/Oe8Zpl2nDGgxw8KWmC+4QjBkgAExjGnekeYbCOFkZkDfcmnlfNmEkB xG++Q+5hAcMRVloGtZF577megZ1K3ssJ1S00uVPvnL5Qhi1GgMcJMuaeAYk7hYBpLZ gne9JdBR3Dj5DJi8p1PPsy9n9BoivBLPORY6bxs1bsM4ide8f/NjCtS28VuOb1ady9 SMnQD6JYe/R7AH73IK1MdB/+xtr9X+PshAPbk68ZZeWGe/gPzqvB+vZErlMZM8pR3p UunlyOTfroyTQ== From: Robin Roevens To: development@lists.ipfire.org Subject: [PATCH v2 4/5] services.cgi: add restart action and restrict action usage Date: Thu, 6 Oct 2022 19:59:57 +0200 Message-Id: <20221006175958.11036-5-robin.roevens@disroot.org> In-Reply-To: <20221006175958.11036-1-robin.roevens@disroot.org> References: <20221006175958.11036-1-robin.roevens@disroot.org> Mime-Version: 1.0 X-sicho-MailScanner-ID: 1029D73542.A8A80 X-sicho-MailScanner: Found to be clean X-sicho-MailScanner-From: robin.roevens@disroot.org X-sicho-MailScanner-Watermark: 1665684008.85393@DBdhnaL2cYYp0pxskZM8Hg ARC-Seal: i=1; s=202003rsa; d=lists.ipfire.org; t=1665079734; a=rsa-sha256; cv=none; b=IKNMtt+1IWjqHQHxH+KDfpOi56fCAw01aGnjD27ObJNZUsnp2h9FmoEeX0lpNpYwrF7aVw m2SAmAMfPAgPDvjGcs/lYYsC8aM6n4rpaSp7b8MjAOWKf5XFr0d+3XYgXtPQ6HXR2R1b7Z ejHXIdJE8bI8w8FfzGUFk9nT6buZE5e54k9QXe1/5dP2aH0a8NdGTmPMc1GPQU5PJTGYjO BVGVa5Ua/JBuIIxqLEf6serVf4lvxMx7CK41XYzxtchy3jwAtODJOEXIL0vrY7qXDXCfac HGC7Cts+1+qdVlyTDE8GDVkFUMxKo99PnUfxVyYUP2BGsXbHp1qtTIfYpQ6lFQ== ARC-Authentication-Results: i=1; mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b="T00n/VlF"; spf=pass (mail01.ipfire.org: domain of robin.roevens@disroot.org designates 178.21.23.139 as permitted sender) smtp.mailfrom=robin.roevens@disroot.org; dmarc=pass (policy=quarantine) header.from=disroot.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.ipfire.org; s=202003rsa; t=1665079734; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=WXYia0IMeOLf9Pntkzycp729WzHUkkazpFm452MZ0fw=; b=n7QxEP8WQZ2Thm6s2NhCmayT8/Ewwy/ohW6SoFZoVevJPbDmbz6pMnXWeI/e7gP07T9PjY qDeUahutgjtJ+DyRyrc1fItMPE3fggymS60gA1Wkn9gAZH4Hq6H0iq5fiTQT6ALJtx7rns x1Wn4uzbJuwIrYf8AqD4fL58D0k5xjlxfPkJzOtkO4Oj40GJYPCvpdyxbO9v9GeZTT8d4z AWWqxmVnpCVUNWO+igCMBbkUXxyaeUPxu7x0L2EI9hiS46AI2t9+BiqgUqB/Z49si2fVNs 8BDKxvcB82jmcdWWDYK4AmUVoZmk6GYHnxMR9Bn84w7GU7WHs+xMdPJHx9npqQ== Authentication-Results: mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b="T00n/VlF"; spf=pass (mail01.ipfire.org: domain of robin.roevens@disroot.org designates 178.21.23.139 as permitted sender) smtp.mailfrom=robin.roevens@disroot.org; dmarc=pass (policy=quarantine) header.from=disroot.org X-Rspamd-Server: mail01.haj.ipfire.org X-Spamd-Result: default: False [-4.82 / 11.00]; BAYES_HAM(-3.00)[99.99%]; IP_REPUTATION_HAM(-1.10)[asn: 50673(-0.31), country: NL(-0.01), ip: 178.21.23.139(-0.78)]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM(-1.00)[-0.999]; DKIM_REPUTATION(-0.79)[-0.79182035360089]; SPF_REPUTATION_HAM(-0.68)[-0.68195333597372]; MV_CASE(0.50)[]; DMARC_POLICY_ALLOW(-0.50)[disroot.org,quarantine]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(0.26)[disroot.org:s=mail]; MIME_HTML_ONLY(0.20)[]; R_SPF_ALLOW(-0.20)[+a:c]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[development@lists.ipfire.org]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; RCVD_COUNT_THREE(0.00)[4]; ARC_SIGNED(0.00)[lists.ipfire.org:s=202003rsa:i=1]; ASN(0.00)[asn:50673, ipnet:178.21.23.0/24, country:NL]; DKIM_TRACE(0.00)[disroot.org:+]; MIME_TRACE(0.00)[0:~]; RCPT_COUNT_TWO(0.00)[2]; TO_DN_SOME(0.00)[] X-Rspamd-Queue-Id: 4Mjzw61sTsz1GW X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" * Add restart action to services. * Only display available actions for a service: Start when service is stopped or Stop and Restart when a service is running. Signed-off-by: Robin Roevens --- html/cgi-bin/services.cgi | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/html/cgi-bin/services.cgi b/html/cgi-bin/services.cgi index e35b04cae..4b379251e 100644 --- a/html/cgi-bin/services.cgi +++ b/html/cgi-bin/services.cgi @@ -143,7 +143,7 @@ END my @param=split(/!/, $paramstr); # Make sure action parameter is actually one of the allowed service actions given ($param[1]) { - when ( ['start', 'stop', 'enable', 'disable'] ) { + when ( ['start', 'stop', 'restart', 'enable', 'disable'] ) { # Make sure pak-name and service name don't contain any illegal character if ( $param[0] !~ /[^a-zA-Z_0-9\-]/ && $param[2] !~ /[^a-zA-Z_0-9\-]/ ) { @@ -196,8 +196,6 @@ END my $status = isautorun($pak,$service,$col); print "$status "; - print "$Lang::tr{"; - print "$Lang::tr{ "; my $status = isrunningaddon($pak,$service,$col); $status =~ s/\\[[0-1]\;[0-9]+m//g; @@ -307,7 +305,9 @@ sub isrunningaddon (@) { my $testcmd = @testcmd[0]; if ( $testcmd =~ /is\ running/ && $testcmd !~ /is\ not\ running/){ - $status = "$Lang::tr{'running'}"; + $status = "$Lang::tr{ "; + $status .= "$Lang::tr{ "; + $status .= "$Lang::tr{'running'}"; $testcmd =~ s/.* //gi; $testcmd =~ s/[a-z_]//gi; $testcmd =~ s/\[[0-1]\;[0-9]+//gi; @@ -330,7 +330,8 @@ sub isrunningaddon (@) { } $status .="$memory KB"; }else{ - $status = "$Lang::tr{'stopped'}"; + $status = "$Lang::tr{"; + $status .= "$Lang::tr{'stopped'}"; } return $status; }