From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id aLL4GaA+B2NqcAEAbAwnHQ (envelope-from ) for ; Thu, 25 Aug 2022 11:19:28 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id 0DjEGaA+B2Nm1wAAauVa8A (envelope-from ) for ; Thu, 25 Aug 2022 11:19:28 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id F0C3731944 for ; Thu, 25 Aug 2022 11:19:27 +0200 (CEST) Received: from localhost ([::1]:56430 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oR91J-0002Gc-89 for larch@yhetil.org; Thu, 25 Aug 2022 05:19:26 -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) 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 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" Reply-to: Nicolas Graves X-ACL-Warn: , Nicolas Graves via Guix-patches From: Nicolas Graves via Guix-patches via X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1661419168; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=rUCLIAsjoIDj06FeTqOEi7XlrcR3yMIRGjNtVkT+NMM=; b=ojYamUU4WkCvWyem/AGgR85FgeS3lkDPDwM8ATi20UjO8Ku16SnwshVEmOKTRuJs5PrhyR bNFnpWcX207sEYgKR4wUF2pCnFc12BBmCYgn6OjYRcssTy31jy71eINfDZ/+IjssCjF5pr tAyjIHcjBsCFVGNIm4xMyd8AKRZh6lAsPugzFLJLb988fReYyBq6b4o6n4vgMYHxxyIPb9 UyvVyUiYeC4y2vhYL9bP70J6uWVn0LJFKfOkXzPxnKtbStZImyr4zKDYgXG+ZC5jpb8JoZ b5+8qi/ffWu+vxv6MFyCSJWOk50muqS6v5yeeIMlHXK4/tc1bw5cXbz+C7JoQg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1661419168; a=rsa-sha256; cv=none; b=eamr8TbQU6c0z9FBInqZnyRduS0gJG3SmbxRjgMULfb/1ou//YQFSCIHvmm8iCMyKH/VJ0 YQ+szatyxHOCXbIwAwwTCcqQGjgw26yrd9mVSZW9EPnJ8F2nk82lpYfMT7GByfUKieWwQM Fa4oCWRpwF6L3Ty53NfoupHElgr2Sd8x5cvdp0MI1/5NTGu6yQ5lhUFpINprM/Zktj4AGO LWxIXiw/HbYFon2jXVeQRGr9OGih/eDMJbBJWjDFIw+n38Ur/NovUkiAHUo+pwM61Na2DQ 5T0uwkoVXpdOzT77io9vrR4z1e6iMWa1BfddY4m5e60m9xvp9TrL/pOXBWaZVw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -3.31 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: F0C3731944 X-Spam-Score: -3.31 X-Migadu-Scanner: scn1.migadu.com X-TUID: Weu0OBRP9Dn1 * 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 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 =C2=A9 2021 Artyom V. Poptsov ;;; Copyright =C2=A9 2022 Wamm K. D. ;;; Copyright =C2=A9 2022 Roman Riabenko +;;; Copyright =C2=A9 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=3D" #$(cc-for-target))) + #:phases + #~(modify-phases %standard-phases + (delete 'configure) + (replace 'install + (lambda _ + (install-file "restartd.conf" (string-append #$output "/et= c")) + (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 an= d 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/pack= ages/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 =3D 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"); -- 2.37.2