From patchwork Thu Aug 25 09:14:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Nicolas Graves X-Patchwork-Id: 41948 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 7FC1327BBEA; Thu, 25 Aug 2022 10:19:44 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id C5F3227BBE9 for ; Thu, 25 Aug 2022 10:19:43 +0100 (BST) Received: from localhost ([::1]:56430 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oR91a-0002Gc-S8 for patchwork@mira.cbaines.net; Thu, 25 Aug 2022 05:19:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46980) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oR8x5-0008IG-NZ for guix-patches@gnu.org; Thu, 25 Aug 2022 05:15:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:59211) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oR8x5-00066E-E7 for guix-patches@gnu.org; Thu, 25 Aug 2022 05:15:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oR8x5-00037F-3D for guix-patches@gnu.org; Thu, 25 Aug 2022 05:15:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#57387] [PATCH] gnu: Add restartd. References: <87czcp8wet.fsf@ngraves.fr> In-Reply-To: <87czcp8wet.fsf@ngraves.fr> Resent-From: Nicolas Graves Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 25 Aug 2022 09:15:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57387 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 57387@debbugs.gnu.org Received: via spool by 57387-submit@debbugs.gnu.org id=B57387.166141889911937 (code B ref 57387); Thu, 25 Aug 2022 09:15:03 +0000 Received: (at 57387) by debbugs.gnu.org; 25 Aug 2022 09:14:59 +0000 Received: from localhost ([127.0.0.1]:48958 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oR8x1-00036S-7W for submit@debbugs.gnu.org; Thu, 25 Aug 2022 05:14:59 -0400 Received: from 5.mo582.mail-out.ovh.net ([46.105.54.31]:42307) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oR8wy-00036I-Ga for 57387@debbugs.gnu.org; Thu, 25 Aug 2022 05:14:57 -0400 Received: from player779.ha.ovh.net (unknown [10.110.115.139]) by mo582.mail-out.ovh.net (Postfix) with ESMTP id 57F4B257CE for <57387@debbugs.gnu.org>; Thu, 25 Aug 2022 09:14:55 +0000 (UTC) Received: from ngraves.fr (met42-h01-213-44-161-47.dsl.sta.abo.bbox.fr [213.44.161.47]) (Authenticated sender: ngraves@ngraves.fr) by player779.ha.ovh.net (Postfix) with ESMTPSA id B1F8E2DB91EED for <57387@debbugs.gnu.org>; Thu, 25 Aug 2022 09:14:53 +0000 (UTC) Authentication-Results: garm.ovh; auth=pass (GARM-103G00540c523a8-9420-454c-87b0-2e27840c7e5d, EE7AED07EA83ED23F885A8103ECAE878C220A66D) smtp.auth=ngraves@ngraves.fr X-OVh-ClientIp: 213.44.161.47 Date: Thu, 25 Aug 2022 11:14:53 +0200 Message-ID: <87y1vck7le.fsf@ngraves.fr> MIME-Version: 1.0 X-Ovh-Tracer-Id: 4435482683604329157 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvfedrvdejfedgudefucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucenucfjughrpefhvffufffkgggtgfesthhqredttddtjeenucfhrhhomheppfhitgholhgrshcuifhrrghvvghsuceonhhgrhgrvhgvshesnhhgrhgrvhgvshdrfhhrqeenucggtffrrghtthgvrhhnpeevhffflefhhfffvedtkedvudfggfeifeeljedtueeutdeiieefueejieeuhffgieenucffohhmrghinhepghhithhhuhgsrdgtohhmpdhlrghunhgthhhprggurdhnvghtpdguvggsihgrnhdrohhrghenucfkpheptddrtddrtddrtddpvddufedrgeegrdduiedurdegjeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhhouggvpehsmhhtphhouhhtpdhhvghlohepphhlrgihvghrjeejledrhhgrrdhovhhhrdhnvghtpdhinhgvtheptddrtddrtddrtddpmhgrihhlfhhrohhmpehnghhrrghvvghssehnghhrrghvvghsrdhfrhdpnhgspghrtghpthhtohepuddprhgtphhtthhopeehjeefkeejseguvggssghughhsrdhgnhhurdhorhhgpdfovfetjfhoshhtpehmohehkedv X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" Reply-to: Nicolas Graves X-ACL-Warn: , Nicolas Graves via Guix-patches X-Patchwork-Original-From: Nicolas Graves via Guix-patches via From: Nicolas Graves X-getmail-retrieved-from-mailbox: Patches * gnu/packages/admin.scm (restartd): New variable. --- gnu/packages/admin.scm | 53 +++++++++++++++++++ .../patches/restartd-fix-compilation.patch | 53 +++++++++++++++++++ .../restartd-fix-segfault-normal-user.patch | 45 ++++++++++++++++ 3 files changed, 151 insertions(+) create mode 100644 gnu/packages/patches/restartd-fix-compilation.patch create mode 100644 gnu/packages/patches/restartd-fix-segfault-normal-user.patch -- 2.37.2 diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm index a4c5189222..17ebd5fd7b 100644 --- a/gnu/packages/admin.scm +++ b/gnu/packages/admin.scm @@ -51,6 +51,7 @@ ;;; Copyright © 2021 Artyom V. Poptsov ;;; Copyright © 2022 Wamm K. D. ;;; Copyright © 2022 Roman Riabenko +;;; Copyright © 2022 Nicolas Graves ;;; ;;; This file is part of GNU Guix. ;;; @@ -5455,6 +5456,58 @@ (define-public fail2ban mechanisms if you really want to protect services.") (license license:gpl2+))) +(define-public restartd + (let* ((commit "7044125ac55056f2663536f7137170edf92ebd75") + ;; Version is 0.2.4 in the version file in the repo + ;; but not in github tags. + ;; It is released as 0.2.3-1.1 for other distributions. + ;; Probably because of the lack of activity upstream. + (revision "1")) + (package + (name "restartd") + (version (git-version "0.2.3" revision commit)) + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/ajraymond/restartd") + (commit commit))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "1m1np00b4zvvwx63gzysbi38i5vj1jsjvh2s0p9czl6dzyz582z0")) + (patches + (search-patches "restartd-fix-segfault-normal-user.patch" + "restartd-fix-compilation.patch")))) + (build-system gnu-build-system) + (arguments + (list + #:tests? #f ; no tests + #:make-flags + #~(list (string-append "CC=" #$(cc-for-target))) + #:phases + #~(modify-phases %standard-phases + (delete 'configure) + (replace 'install + (lambda _ + (install-file "restartd.conf" (string-append #$output "/etc")) + (install-file "restartd" (string-append #$output "/sbin")) + (install-file "restartd.8" + (string-append #$output "/share/man/man8")) + (mkdir-p (string-append #$output "/share/man/fr/man8")) + (copy-file + "restartd.fr.8" + (string-append #$output "/share/man/fr/man8/restartd.8"))))))) + (home-page "https://launchpad.net/debian/+source/restartd") + (synopsis "Daemon for restarting processes") + (description "This package provides a daemon for checking running and not +running processes. It reads the /proc directory every n seconds and does a +POSIX regexp on the process names. The daemon runs an user-provided script +when it detects a program in the running processes, or an alternate script if +it doesn't detect the program. The daemon can only be called by the root +user, but can use @code{sudo -u user} in the process called if needed.") + (license license:gpl2+)))) + (define-public rex (package (name "rex") diff --git a/gnu/packages/patches/restartd-fix-compilation.patch b/gnu/packages/patches/restartd-fix-compilation.patch new file mode 100644 index 0000000000..a380205675 --- /dev/null +++ b/gnu/packages/patches/restartd-fix-compilation.patch @@ -0,0 +1,53 @@ +From 84edc2042bb0a82e65bd4d165b706519886b4075 Mon Sep 17 00:00:00 2001 +From: Sudip Mukherjee +Date: Mon, 10 Aug 2020 19:39:30 +0100 +Subject: [PATCH] Fix build with gcc-10 + +Bug: https://bugs.debian.org/957761 +Signed-off-by: Sudip Mukherjee +--- + config.h | 12 ++++++------ + restartd.c | 7 +++++++ + 2 files changed, 13 insertions(+), 6 deletions(-) + +diff --git a/config.h b/config.h +index fabaa2b..a79b28e 100644 +--- a/config.h ++++ b/config.h +@@ -25,12 +25,12 @@ + + #define DEFAULT_CONFIG "/etc/restartd.conf" + +-int debug; +-int config_process_number; +-int check_interval; +-int foreground; +-struct config_process_type *config_process; +-char *config_file; ++extern int debug; ++extern int config_process_number; ++extern int check_interval; ++extern int foreground; ++extern struct config_process_type *config_process; ++extern char *config_file; + + typedef struct config_process_type { + char name[64]; +diff --git a/restartd.c b/restartd.c +index 2aa720c..617b298 100644 +--- a/restartd.c ++++ b/restartd.c +@@ -35,6 +35,13 @@ + + #include "config.h" + ++int debug; ++int config_process_number; ++int check_interval; ++int foreground; ++struct config_process_type *config_process; ++char *config_file; ++ + /* SIGTERM & SIGHUP handler */ + void got_signal(int sig) + { diff --git a/gnu/packages/patches/restartd-fix-segfault-normal-user.patch b/gnu/packages/patches/restartd-fix-segfault-normal-user.patch new file mode 100644 index 0000000000..5c28c3b2ad --- /dev/null +++ b/gnu/packages/patches/restartd-fix-segfault-normal-user.patch @@ -0,0 +1,45 @@ +From 67d7308ba52d2c605d0175c14c34ff09c9d322fb Mon Sep 17 00:00:00 2001 +From: Yin Kangkai +Date: Sat, 1 Oct 2016 13:52:58 +0800 +Subject: [PATCH] Fix segfault when run as normal user + +Also exit immediately when "restartd -h" +--- + restartd.c | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +diff --git a/restartd.c b/restartd.c +index 2aa720c..1d46fe1 100644 +--- a/restartd.c ++++ b/restartd.c +@@ -118,6 +118,7 @@ int main(int argc, char *argv[]) + " -i : the check interval in second\n" + " -l : list configuration options\n" + " -h : help\n\n", VERSION); ++ exit(0); + } + } + +@@ -187,6 +188,10 @@ int main(int argc, char *argv[]) + } + + out_proc = fopen("/var/run/restartd.pid", "wt"); ++ if (!out_proc) { ++ syslog(LOG_ERR, "Failed to open /var/run/restartd.pid"); ++ return -1; ++ } + fprintf(out_proc, "%d", getpid()); + fclose(out_proc); + +@@ -244,9 +249,9 @@ int main(int argc, char *argv[]) + if (strlen(config_process[i].processes) > 0) { + if (strlen(config_process[i].running) > 0) { + strcpy(config_process[i].status, "running"); +- syslog(LOG_INFO, "%s is running, executing '%s'", ++ /* syslog(LOG_INFO, "%s is running, executing '%s'", + config_process[i].name, +- config_process[i].running); ++ config_process[i].running); */ + system(config_process[i].running); + } else { + strcpy(config_process[i].status, "running");