GNU logs - #57378, boring messages


Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#57378: 28.1; Missing frame-new-frame-choice variable (wishlist)
Resent-From: Rudi Schlatte <rudi@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Wed, 24 Aug 2022 10:56:01 +0000
Resent-Message-ID: <handler.57378.B.166133853327771 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: report 57378
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 57378 <at> debbugs.gnu.org
X-Debbugs-Original-To: bug-gnu-emacs@HIDDEN
Received: via spool by submit <at> debbugs.gnu.org id=B.166133853327771
          (code B ref -1); Wed, 24 Aug 2022 10:56:01 +0000
Received: (at submit) by debbugs.gnu.org; 24 Aug 2022 10:55:33 +0000
Received: from localhost ([127.0.0.1]:45726 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oQo2n-0007Dr-2o
	for submit <at> debbugs.gnu.org; Wed, 24 Aug 2022 06:55:33 -0400
Received: from lists.gnu.org ([209.51.188.17]:44120)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <rudi@HIDDEN>) id 1oQo2m-0007Dk-2D
 for submit <at> debbugs.gnu.org; Wed, 24 Aug 2022 06:55:32 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:53430)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <rudi@HIDDEN>)
 id 1oQo2l-0004HY-M4
 for bug-gnu-emacs@HIDDEN; Wed, 24 Aug 2022 06:55:31 -0400
Received: from out1-smtp.messagingengine.com ([66.111.4.25]:37669)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <rudi@HIDDEN>)
 id 1oQo2j-0004Rl-T6
 for bug-gnu-emacs@HIDDEN; Wed, 24 Aug 2022 06:55:31 -0400
Received: from compute2.internal (compute2.nyi.internal [10.202.2.46])
 by mailout.nyi.internal (Postfix) with ESMTP id 4375C5C00D5;
 Wed, 24 Aug 2022 06:55:27 -0400 (EDT)
Received: from mailfrontend2 ([10.202.2.163])
 by compute2.internal (MEProxy); Wed, 24 Aug 2022 06:55:27 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
 messagingengine.com; h=cc:content-transfer-encoding:content-type
 :date:date:feedback-id:feedback-id:from:from:in-reply-to
 :message-id:mime-version:reply-to:sender:subject:subject:to:to
 :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=
 fm1; t=1661338527; x=1661424927; bh=FCbDBl7jgA3qHp4tD88BwsIjfsa2
 LwEvVuzBSpct16A=; b=psevluiqzQw/bpt3MYCTxwP42MwYpozgsKBAXMFupVyD
 PZZhSCUtZ2V3uLhfSyEXInlzOx/u3cnPTMlbsklF/UIeUvBKKfNXzhhrEIdlIfoo
 aqfPaFx5qqS5LnViJz9idSeMxBStqKALx+rRi2vbeTPddO0OqSGPyAtLREGyuo4F
 aEtrDTQOkioxs5kCkNClV9zJfxzThUT5FCTj/MFtjq9wEQ0n/VNONRPAlrKIM2U4
 i//Q467+3LBP6FIA+2TDfGU/9S4W0j4Fs+x5H3gHBn2wBcBEakuPFQ46NgNurc6y
 DnODg9XzU1Tklrmpiv8JLRMBqwBjw5XEdh8hBHHyrw==
X-ME-Sender: <xms:ngMGY6y4Dyg1Ay990VebmSvoTvHwBo7zro1crjcQ3LdOecdHq6TAvw>
 <xme:ngMGY2RFIt0_P-5y9qE-UhBWnuiF3qPZzv6mxhDIKVb0LpQ6cO8r12uHanTE-3ssY
 YKehcRMf_73n0TS4Q>
X-ME-Received: <xmr:ngMGY8W7f5lpLUw_BOuaedAhFgylgwQAvb68xpaeQsI_UtOZ5BXrUfzBrLSxj02HJUWElP9KFcm5QFmMTr9tkdn_oI6eJlhJiPdFPmaXeEtJ>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvdejuddgfeehucetufdoteggodetrfdotf
 fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen
 uceurghilhhouhhtmecufedttdenucenucfjughrpefhtgfgggffuffkvffosehtjehmtd
 hhtddvnecuhfhrohhmpeftuhguihcuufgthhhlrghtthgvuceorhhuughisegtohhnshht
 rghnthhlhidrrghtqeenucggtffrrghtthgvrhhnpeetueevgfekkeegudevveehhfelff
 ethfeiueduhfejieetvdehueehffeggeelfeenucevlhhushhtvghrufhiiigvpedtnecu
 rfgrrhgrmhepmhgrihhlfhhrohhmpehruhguihestghonhhsthgrnhhtlhihrdgrth
X-ME-Proxy: <xmx:ngMGYwhdlVLynbFhplcd6VK3KeYhrFtRZEmRjJnD8pzzrf-vBTSMhw>
 <xmx:ngMGY8CQ0UqD1Y7wTaSKcba1tDR1eql95i9OyTntvtx1_Fj9fyBy0A>
 <xmx:ngMGYxK-LZXW31BVljLBi4iuhukOaHMUnl15_HfuKGhWXQFs99Gt-Q>
 <xmx:nwMGY79AvF3sijy6feo7ozqiyXxIvvoOuQV6VX-ZIVE3UQ1vCzCq6Q>
Feedback-ID: i5b4840b3:Fastmail
Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed,
 24 Aug 2022 06:55:26 -0400 (EDT)
From: Rudi Schlatte <rudi@HIDDEN>
Content-Type: text/plain;
	charset=us-ascii
Content-Transfer-Encoding: 7bit
Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\))
Date: Wed, 24 Aug 2022 12:55:24 +0200
Message-Id: <D2A766B0-BE6C-4B08-8B35-3E20DD0EF825@HIDDEN>
X-Mailer: Apple Mail (2.3696.120.41.1.1)
Received-SPF: none client-ip=66.111.4.25; envelope-from=rudi@HIDDEN;
 helo=out1-smtp.messagingengine.com
X-Spam_score_int: -25
X-Spam_score: -2.6
X-Spam_bar: --
X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001,
 RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001,
 T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Hi,

The tab-bar library has a variable `tab-bar-new-tab-choice' that can be
used to specify the content of a new tab created via `tab-new' (`C-x t
2').  Would it make sense to offer the same functionality for frames
created via `make-frame-command', i.e., add a variable
`frame-new-frame-choice' that would allow the user to specify the
content of a new frame created via `C-x 5 2'?




Message sent:


Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-Mailer: MIME-tools 5.505 (Entity 5.505)
Content-Type: text/plain; charset=utf-8
X-Loop: help-debbugs@HIDDEN
From: help-debbugs@HIDDEN (GNU bug Tracking System)
To: Rudi Schlatte <rudi@HIDDEN>
Subject: bug#57378: Acknowledgement (28.1; Missing frame-new-frame-choice
 variable (wishlist))
Message-ID: <handler.57378.B.166133853327771.ack <at> debbugs.gnu.org>
References: <D2A766B0-BE6C-4B08-8B35-3E20DD0EF825@HIDDEN>
X-Gnu-PR-Message: ack 57378
X-Gnu-PR-Package: emacs
Reply-To: 57378 <at> debbugs.gnu.org
Date: Wed, 24 Aug 2022 10:56:02 +0000

Thank you for filing a new bug report with debbugs.gnu.org.

This is an automatically generated reply to let you know your message
has been received.

Your message is being forwarded to the package maintainers and other
interested parties for their attention; they will reply in due course.

Your message has been sent to the package maintainer(s):
 bug-gnu-emacs@HIDDEN

If you wish to submit further information on this problem, please
send it to 57378 <at> debbugs.gnu.org.

Please do not send mail to help-debbugs@HIDDEN unless you wish
to report a problem with the Bug-tracking system.

--=20
57378: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D57378
GNU Bug Tracking System
Contact help-debbugs@HIDDEN with problems


Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#57378: [PATCH] gnu: Add restartd.
References: <D2A766B0-BE6C-4B08-8B35-3E20DD0EF825@HIDDEN>
In-Reply-To: <D2A766B0-BE6C-4B08-8B35-3E20DD0EF825@HIDDEN>
Resent-From: Nicolas Graves <ngraves@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Thu, 29 Sep 2022 12:31:02 +0000
Resent-Message-ID: <handler.57378.B57378.16644546374182 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 57378
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 57378 <at> debbugs.gnu.org
Cc: maximedevos@HIDDEN, ngraves@HIDDEN, othacehe@HIDDEN
Received: via spool by 57378-submit <at> debbugs.gnu.org id=B57378.16644546374182
          (code B ref 57378); Thu, 29 Sep 2022 12:31:02 +0000
Received: (at 57378) by debbugs.gnu.org; 29 Sep 2022 12:30:37 +0000
Received: from localhost ([127.0.0.1]:36513 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1odsgW-00015O-GH
	for submit <at> debbugs.gnu.org; Thu, 29 Sep 2022 08:30:37 -0400
Received: from 18.mo583.mail-out.ovh.net ([178.33.45.10]:57327)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ngraves@HIDDEN>) id 1odsgR-000151-Ms
 for 57378 <at> debbugs.gnu.org; Thu, 29 Sep 2022 08:30:35 -0400
Received: from player696.ha.ovh.net (unknown [10.111.172.60])
 by mo583.mail-out.ovh.net (Postfix) with ESMTP id 8F50323C74
 for <57378 <at> debbugs.gnu.org>; Thu, 29 Sep 2022 12:30:29 +0000 (UTC)
Received: from ngraves.fr (met42-h01-213-44-161-47.dsl.sta.abo.bbox.fr
 [213.44.161.47]) (Authenticated sender: ngraves@HIDDEN)
 by player696.ha.ovh.net (Postfix) with ESMTPSA id CF9CC24F4D4CF;
 Thu, 29 Sep 2022 12:30:23 +0000 (UTC)
Authentication-Results: garm.ovh; auth=pass
 (GARM-103G005a166dff7-390d-4401-a5aa-599fe5b0b55e,
 B0E8D5270CD01EFF20DD9E8B4F81152F34611B42) smtp.auth=ngraves@HIDDEN
X-OVh-ClientIp: 213.44.161.47
From: Nicolas Graves <ngraves@HIDDEN>
Date: Thu, 29 Sep 2022 14:30:22 +0200
Message-ID: <87edvu1hy9.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Ovh-Tracer-Id: 10368412243943154190
X-VR-SPAMSTATE: OK
X-VR-SPAMSCORE: 0
X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvfedrfeehtddgheegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucenucfjughrpefhvfevufffkfggtgfgsehtqhertddttdejnecuhfhrohhmpefpihgtohhlrghsucfirhgrvhgvshcuoehnghhrrghvvghssehnghhrrghvvghsrdhfrheqnecuggftrfgrthhtvghrnhepveegieegkedvtdevgeeuveeludeigeduffelkeevvdeuffeigeffffdtveejffdvnecuffhomhgrihhnpehgihhthhhusgdrtghomhdplhgruhhntghhphgrugdrnhgvthdpuggvsghirghnrdhorhhgnecukfhppedtrddtrddtrddtpddvudefrdeggedrudeiuddrgeejnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmohguvgepshhmthhpohhuthdphhgvlhhopehplhgrhigvrheileeirdhhrgdrohhvhhdrnhgvthdpihhnvghtpedtrddtrddtrddtpdhmrghilhhfrhhomhepnhhgrhgrvhgvshesnhhgrhgrvhgvshdrfhhrpdhnsggprhgtphhtthhopedupdhrtghpthhtohepheejfeejkeesuggvsggsuhhgshdrghhnuhdrohhrghdpoffvtefjohhsthepmhhoheekfe
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* gnu/packages/admin.scm (restartd): New variable.
---
 gnu/packages/admin.scm                        |  51 +++
 .../patches/restartd-update-robust.patch      | 295 ++++++++++++++++++
 2 files changed, 346 insertions(+)
 create mode 100644 gnu/packages/patches/restartd-update-robust.patch

diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm
index 1a213adfdd..c696384211 100644
--- a/gnu/packages/admin.scm
+++ b/gnu/packages/admin.scm
@@ -53,6 +53,7 @@
 ;;; Copyright =C2=A9 2022 Roman Riabenko <roman@HIDDEN>
 ;;; Copyright =C2=A9 2022 Petr Hodina <phodina@HIDDEN>
 ;;; Copyright =C2=A9 2022 Andreas Rammhold <andreas@HIDDEN>
+;;; Copyright =C2=A9 2022 Nicolas Graves <ngraves@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -5489,6 +5490,56 @@ (define-public fail2ban
 mechanisms if you really want to protect services.")
     (license license:gpl2+)))
=20
+(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-update-robust.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-update-robust.patch b/gnu/packag=
es/patches/restartd-update-robust.patch
new file mode 100644
index 0000000000..d279ebd8ff
--- /dev/null
+++ b/gnu/packages/patches/restartd-update-robust.patch
@@ -0,0 +1,295 @@
+From 01cd2d15a9bf1109e0e71b3e31b835d63dcf9cd8 Mon Sep 17 00:00:00 2001
+From: Maxime Devos <maximedevos@HIDDEN>, Yin Kangkai <yinkangkai@xiaom=
i.com>, Sudip Mukherjee <sudipm.mukherjee@HIDDEN>
+Subject: [PATCH]
+
+Fix segfault when run as normal user
+
+Also exit immediately when "restartd -h"
+Signed-off-by: Yin Kangkai <yinkangkai@HIDDEN>
+
+Fix build with gcc-10
+
+Bug: https://bugs.debian.org/957761
+Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@HIDDEN>
+
+Handle memory allocation failures.
+
+This makes the code a little more robust.
+Signed-off-by: Maxime Devos <maximedevos@HIDDEN>
+
+Handle fopen failures.
+
+This makes the code a little more robust. What if /var/run does not
+exist, or we do not have permission to open
+/var/run/restartd.pid (EPERM?) due to SELinux misconfiguration?
+Signed-off-by: Maxime Devos <maximedevos@HIDDEN>
+
+Handle printf and fprintf failures.
+
+This makes the code a little more robust. What if the write was
+refused to the underlying device being removed?
+
+The --help, debug and stderr printfs were ignored because there error
+handling does not appear important to me.
+Signed-off-by: Maxime Devos <maximedevos@HIDDEN>
+
+Handle fclose failures when writing.
+
+This makes the code a little more robust. What if a quotum is exceeded?
+Signed-off-by: Maxime Devos <maximedevos@HIDDEN>
+---
+ config.c   | 19 +++++++++----
+ config.h   | 14 ++++++----
+ restartd.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++-------
+ 3 files changed, 92 insertions(+), 21 deletions(-)
+
+diff --git a/config.c b/config.c
+index f307b8a..5cc0271 100644
+--- a/config.c
++++ b/config.c
+@@ -57,7 +57,11 @@ int read_config(void)
+     config_process_number =3D 0;
+=20
+     line1 =3D (char *) malloc(MAX_LINE_LENGTH);
++    if (!line1)
++      oom_failure();
+     line2 =3D (char *) malloc(MAX_LINE_LENGTH);
++    if (!line2)
++      oom_failure();
+=20
+     if ((config_fd =3D fopen(config_file, "rt")) =3D=3D NULL) {
+         fprintf(stderr, "Error at opening config file: %s\n", config_file=
);
+@@ -155,11 +159,16 @@ void dump_config(void) {
+     int i;
+=20
+     for(i=3D0; i<config_process_number; i++) {
+-        printf("ID=3D%d\n  name=3D%s\n  regexp=3D%s\n  running=3D%s\n  no=
t_running=3D%s\n", i,
+-            config_process[i].name,
+-            config_process[i].regexp,
+-            config_process[i].running,
+-            config_process[i].not_running);
++      if (printf("ID=3D%d\n  name=3D%s\n  regexp=3D%s\n  running=3D%s\n  =
not_running=3D%s\n", i,
++                 config_process[i].name,
++                 config_process[i].regexp,
++                 config_process[i].running,
++                 config_process[i].not_running) < 0) {
++        /* Maybe stdout points to a file and a file system quotum was exc=
eeded? */
++        fprintf(stderr, "Failed to dump the configuration. Exiting.\n");
++        syslog(LOG_ERR, "Failed to dump the configuration. Exiting.");
++        exit(1);
++      }
+     }
+=20
+ }
+diff --git a/config.h b/config.h
+index fabaa2b..2ba1cbe 100644
+--- a/config.h
++++ b/config.h
+@@ -1,6 +1,7 @@
+ /* restartd - Process checker and/or restarter daemon
+  * Copyright (C) 2000-2002 Tibor Koleszar <oldw@HIDDEN>
+  * Copyright (C) 2006 Aur=C3=A9lien G=C3=89R=C3=94ME <ag@HIDDEN>
++ * Copyright (C) 2022 Maxime Devos <maximedevos@HIDDEN>
+  *
+  * This program is free software; you can redistribute it and/or
+  * modify it under the terms of the GNU General Public License
+@@ -25,12 +26,12 @@
+=20
+ #define DEFAULT_CONFIG "/etc/restartd.conf"
+=20
+-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;
+=20
+ typedef struct config_process_type {
+   char name[64];
+@@ -43,5 +44,6 @@ typedef struct config_process_type {
+=20
+ int read_config(/* char *config_file */);
+ void dump_config(void);
++void oom_failure(void);
+=20
+ #endif /* RESTARTD_CONFIG_H */
+diff --git a/restartd.c b/restartd.c
+index 2aa720c..aa74334 100644
+--- a/restartd.c
++++ b/restartd.c
+@@ -1,6 +1,7 @@
+ /* restartd - Process checker and/or restarter daemon
+  * Copyright (C) 2000-2002 Tibor Koleszar <oldw@HIDDEN>
+  * Copyright (C) 2006 Aur=C3=A9lien G=C3=89R=C3=94ME <ag@HIDDEN>
++ * Copyright (C) 2022 Maxime Devos <maximedevos@HIDDEN>
+  *
+  * This program is free software; you can redistribute it and/or
+  * modify it under the terms of the GNU General Public License
+@@ -35,6 +36,13 @@
+=20
+ #include "config.h"
+=20
++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)
+ {
+@@ -52,6 +60,17 @@ void got_signal(int sig)
+     }
+ }
+=20
++/* Ignoring out-of-memory failures is risky on systems without virtual me=
mory
++   where additionally at address 0 there is actually something important
++   mapped. Additionally, while often on Linux the OOM killer will kill pr=
ocesses
++   where an OOM happens, this is not always the case and there exist othe=
r systems
++   without an OOM killer (e.g. the Hurd). */
++void oom_failure()
++{
++  syslog(LOG_ERR, "Failed to allocate memory. Exiting.");
++  exit(1);
++}
++
+ int main(int argc, char *argv[])
+ {
+     DIR *procdir_id;
+@@ -75,15 +94,21 @@ int main(int argc, char *argv[])
+=20
+     /* Options */
+     config_file =3D strdup(DEFAULT_CONFIG);
++    if (!config_file)
++      oom_failure();
++
+     list_only =3D 0;
+=20
+     for(i =3D 0; i < argc; i++) {
+         if (!strcmp(argv[i], "-c") || !strcmp(argv[i], "--config")) {
+             config_file =3D strdup(argv[i + 1]);
++	    if (!config_file)
++	      oom_failure();
+         }
+         if (!strcmp(argv[i], "-v") || !strcmp(argv[i], "--version")) {
+             printf("restard %s - Copyright 2000-2002 Tibor Koleszar <oldw=
@debian.org>\n"
+-                   "                Copyright 2006 Aur=C3=A9lien G=C3=89R=
=C3=94ME <ag@HIDDEN>\n",
++                   "                Copyright 2006 Aur=C3=A9lien G=C3=89R=
=C3=94ME <ag@HIDDEN>\n"
++                   "                Copyright 2022 Maxime Devos <maximede=
vos@HIDDEN>\n",
+                    VERSION);
+             exit(0);
+         }
+@@ -118,10 +143,13 @@ 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);
+         }
+     }
+=20
+     config_process =3D malloc(sizeof(struct config_process_type) * 128);
++    if (!config_process)
++      oom_failure();
+=20=20=20
+     read_config();
+     if (list_only) {
+@@ -133,9 +161,17 @@ int main(int argc, char *argv[])
+            config_process_number);
+=20=20=20
+     procdir_dirent =3D malloc(sizeof(struct dirent));
++    if (!procdir_dirent)
++      oom_failure();
+     proc_cmdline_str =3D (char *) malloc(1024);
++    if (!proc_cmdline_str)
++      oom_failure();
+     proc_cmdline_name =3D (char *) malloc(1024);
++    if (!proc_cmdline_name)
++      oom_failure();
+     regc =3D malloc(1024);
++    if (!regc)
++      oom_failure();
+=20=20=20
+     /* Catch signals */
+     signal(SIGTERM, got_signal);
+@@ -187,8 +223,19 @@ int main(int argc, char *argv[])
+         }
+=20
+         out_proc =3D fopen("/var/run/restartd.pid", "wt");
+-        fprintf(out_proc, "%d", getpid());
+-        fclose(out_proc);
++	if (!out_proc) {
++		syslog(LOG_ERR, "Failed to open /var/run/restartd.pid");
++		return -1;
++	}
++        if (fprintf(out_proc, "%d", getpid()) < 0) {
++          syslog(LOG_ERR, "Failed to write to /var/run/restartd.pid. Exit=
ing.");
++          return -1;
++        }
++        if (fclose(out_proc) < 0) { /* errors can happen when flushing th=
e buffer */
++          syslog(LOG_ERR, "Failed to write to /var/run/restartd.pid. Exit=
ing.");
++          return -1;
++        }
++
+=20
+         while(1) {
+             if ((procdir_id =3D opendir("/proc")) =3D=3D NULL) {
+@@ -237,16 +284,23 @@ int main(int argc, char *argv[])
+            now =3D time(NULL);
+=20
+            out_proc =3D fopen("/var/run/restartd", "wt");
++           if (!out_proc) {
++             syslog(LOG_ERR, "Failed to open /var/run/restartd.pid");
++             return -1;
++           }
+=20
+-           fprintf(out_proc, "%s\n", ctime(&now));
++           if (fprintf(out_proc, "%s\n", ctime(&now)) < 0) {
++             syslog(LOG_ERR, "Failed to write to /var/run/restartd. Exiti=
ng.");
++             return -1;
++           }
+=20
+            for(i=3D0; i<config_process_number; i++) {
+                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");
+@@ -267,12 +321,18 @@ int main(int argc, char *argv[])
+                     strcpy(config_process[i].status, "not running");
+                 }
+=20
+-                fprintf(out_proc, "%-12s %-12s      %s\n",
+-                        config_process[i].name, config_process[i].status,
+-                        config_process[i].processes);
++                if (fprintf(out_proc, "%-12s %-12s      %s\n",
++                            config_process[i].name, config_process[i].sta=
tus,
++                            config_process[i].processes) < 0) {
++                  syslog(LOG_ERR, "Failed to write to /var/run/restartd. =
Exiting.");
++                  return -1;
++                }
+             }
+=20
+-            fclose(out_proc);
++            if (fclose(out_proc) < 0) {
++              syslog(LOG_ERR, "Failed to write to /var/run/restartd.pid. =
Exiting.");
++              return -1;
++            }
+=20
+             sleep(check_interval);
+         }
+--=20
+2.37.3
+
--=20
2.37.3





Last modified: Thu, 29 Sep 2022 12:45:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.