From: Nicolas Graves via Guix-patches via <guix-patches@gnu.org>
To: 57387@debbugs.gnu.org
Subject: [bug#57387] [PATCH] gnu: Add restartd.
Date: Thu, 25 Aug 2022 11:14:53 +0200 [thread overview]
Message-ID: <87y1vck7le.fsf@ngraves.fr> (raw)
In-Reply-To: <87czcp8wet.fsf@ngraves.fr>
* 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 © 2021 Artyom V. Poptsov <poptsov.artyom@gmail.com>
;;; Copyright © 2022 Wamm K. D. <jaft.r@outlook.com>
;;; Copyright © 2022 Roman Riabenko <roman@riabenko.com>
+;;; Copyright © 2022 Nicolas Graves <ngraves@ngraves.fr>
;;;
;;; 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 <sudipm.mukherjee@gmail.com>
+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 <sudipm.mukherjee@gmail.com>
+---
+ 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 <yinkangkai@xiaomi.com>
+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 <interval_sec>: 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");
--
2.37.2
next prev parent reply other threads:[~2022-08-25 9:19 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-24 15:59 [bug#57387] [PATCH] gnu: Add restartd Nicolas Graves via Guix-patches via
2022-08-24 18:09 ` Maxime Devos
2022-08-24 18:14 ` ( via Guix-patches via
2022-08-25 9:14 ` Nicolas Graves via Guix-patches via [this message]
2022-08-25 9:16 ` Nicolas Graves via Guix-patches via
2022-08-25 10:34 ` Maxime Devos
2022-08-25 11:33 ` Maxime Devos
2022-08-26 7:32 ` Nicolas Graves via Guix-patches via
2022-08-26 14:03 ` Maxime Devos
2022-08-26 16:57 ` Nicolas Graves via Guix-patches via
2022-08-26 19:07 ` Maxime Devos
2022-08-26 22:16 ` Nicolas Graves via Guix-patches via
2022-08-28 17:38 ` Maxime Devos
2022-09-11 14:53 ` Mathieu Othacehe
2022-09-11 18:13 ` Nicolas Graves via Guix-patches via
2022-09-12 7:36 ` Mathieu Othacehe
2022-09-13 8:45 ` Nicolas Graves via Guix-patches via
2022-09-14 7:48 ` Mathieu Othacehe
2024-02-03 14:07 ` Nicolas Graves via Guix-patches via
2024-02-03 13:36 ` [bug#57387] [PATCH v2] " Nicolas Graves via Guix-patches via
2024-02-03 14:06 ` [bug#57387] [PATCH v3] " Nicolas Graves via Guix-patches via
2024-02-18 14:54 ` bug#57387: " Ludovic Courtès
[not found] <87edvu1hy9.fsf@ngraves.fr>
2022-09-29 13:14 ` [bug#57387] [PATCH] " Nicolas Graves via Guix-patches via
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87y1vck7le.fsf@ngraves.fr \
--to=guix-patches@gnu.org \
--cc=57387@debbugs.gnu.org \
--cc=ngraves@ngraves.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.