From patchwork Tue Oct 11 22:01:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Roevens X-Patchwork-Id: 6057 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 4Mn8tY56kTz3whg for ; Tue, 11 Oct 2022 22:03:33 +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 4Mn8tR2NSLz2b9; Tue, 11 Oct 2022 22:03:27 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4Mn8tR15yGz2yXK; Tue, 11 Oct 2022 22:03:27 +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 4Mn8tN1njXz2xfn for ; Tue, 11 Oct 2022 22:03:24 +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 4Mn8tN0jcKzyn for ; Tue, 11 Oct 2022 22:03:24 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id D0ADB4DAF4 for ; Wed, 12 Oct 2022 00:03:23 +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 v8SLBqb9_J3b for ; Wed, 12 Oct 2022 00:03:22 +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 0F654751FA; Wed, 12 Oct 2022 00:02:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1665525747; bh=yyr9r7oQWZjPJ0qf+VAreyrxpn9yuyVhSrPvpR1uBpw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=SjDjVtKnCUZf5aOqGRAdVSUxYskPRu7tqtaud+XWB0oaC14JacFd+i2InjgnBgNuw FBKE4o95QqMOD8i6uqqvyf268jxYP463vGSaQQAOa+TlWozTnuiACDJxaQ3f+oBe34 H8iD9+hdAK7TkKVN+g42fzy57kO8tWzqYI5ApKbHDhqm/ahXtzjhIKK8b1l0mt7UIm Kj6FQKzty4xaxhVDBPUXo/C6cbiNjzabFIF/7KX2zerSOkO1xSajt8dLYBwbVqWhgX BZ4FrmSbpyM52bDvC5wi96IQokj3w+0JecpgUj2UW52h5HeLJLdlYQg/Nbt6SobACH kQRRFI5GjOUmQ== From: Robin Roevens To: development@lists.ipfire.org Subject: [PATCH v3 4/5] services.cgi: add restart action and restrict action usage Date: Wed, 12 Oct 2022 00:01:56 +0200 Message-Id: <20221011220157.17385-5-robin.roevens@disroot.org> In-Reply-To: <20221011220157.17385-1-robin.roevens@disroot.org> References: <20221011220157.17385-1-robin.roevens@disroot.org> Mime-Version: 1.0 X-sicho-MailScanner-ID: 0F654751FA.A8A80 X-sicho-MailScanner: Found to be clean X-sicho-MailScanner-From: robin.roevens@disroot.org X-sicho-MailScanner-Watermark: 1666130530.93361@K3jXsvk5+T8AqQH71/2duQ ARC-Seal: i=1; s=202003rsa; d=lists.ipfire.org; t=1665525804; a=rsa-sha256; cv=none; b=Z6tCeqPB4Rg7k1ZI5Lwon4L+tiZ0jklAirGNbxf9BbOFJcOj3xf3pkizvVKjDahQ2B9B6K Fo8orqpDDGy0vnY+VAZvaWnX/3sLMlh3A8kDwtHerCIu1BVnJOgIAZVPF60Uu7yfDGziwj x9vypr+qnRdr0HQtLI5cI/HsNU5lsEcts7GKeJWo+R6vaQv8wCOuHD1Kw5ZkbdhB5Vo9Xn CmCFKlF3xsGQfczTQUZlZGiTuBc/Bl/I2m9wa8yHaIWGRlTWDtyb7L5c123rupqVO23WnB XVqT+PmFMuxtIK3rk6RTVbbiOPnVzRdDrwJxfb0kGvwwrXThbpD+lVZ+L9puGg== ARC-Authentication-Results: i=1; mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=SjDjVtKn; 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=1665525804; 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=wREJIsWqZiuzUr+H4QwEgiluFi1iITpWmRl9RrEsl12uZ+kyuKVEeYyGlBKdrqEZRpw7Mj coKVrRxFiVfsllF8LQ0KF9DBdDiyM1dimx+SPCsQp4dJXHlj20RYWywY+F7UQ1Y0mMiIDD YswRjROKa54vrSMlP7QG602Lzhkw+JL5w+a4QCDuqZVGldu5F1NpSBcn1fdFxWYp64gHD/ ZCc/P+xxP21CmcvsCDG2naUVGM92hh6qmX7mGHfZQf73+ps4suYEPI2pCmmDoVe/quNnZy isyHDYWng9zIqWOQ5NruQ5fk1OstIUQ0Hz2Xr+Xd3styqIjmDKKYfA+J/dH5aQ== Authentication-Results: mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=SjDjVtKn; 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.81 / 11.00]; BAYES_HAM(-3.00)[99.99%]; IP_REPUTATION_HAM(-1.13)[asn: 50673(-0.32), country: NL(-0.01), ip: 178.21.23.139(-0.81)]; NEURAL_HAM(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; DKIM_REPUTATION(-0.82)[-0.81568261952269]; SPF_REPUTATION_HAM(-0.61)[-0.61451727240354]; R_MISSING_CHARSET(0.50)[]; MV_CASE(0.50)[]; DMARC_POLICY_ALLOW(-0.50)[disroot.org,quarantine]; R_DKIM_ALLOW(0.27)[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: 4Mn8tN0jcKzyn 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 Reviewed-by: Michael Tremer --- 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; }