Your message dated Thu, 27 Aug 2026 15:18:53 +0000
with message-id <[email protected]>
and subject line Bug#1131375: fixed in debianutils 5.24
has caused the Debian Bug report #1131375,
regarding debianutils: Add options -A, --after and -B, --before for greater 
flexibility
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
1131375: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1131375
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: debianutils
Version: 5.23.2
Severity: wishlist
Tags: patch

Dear Maintainer,

I'm having troubles monitoring what happens during the cron.daily process.
While a --time option (see bug#282553) might help, I got the feeling that
after some trials I'd have to tweak it further.  So, for maximum flexibility,
I turned to -A and -B which allow a user-supplied utility to be called
after or before each script execution.  Such utility can log the time, but also
examine various other things.

I add a patch for run-parts.c and run-parts.8.


-- System Information:
Distributor ID: Devuan
Description:    Devuan GNU/Linux 6 (excalibur)
Release:        6
Codename:       excalibur
Architecture: x86_64

Kernel: Linux 6.12.73+deb13-amd64 (SMP w/8 CPU threads; PREEMPT)
Locale: LANG=en_IE.UTF-8, LC_CTYPE=en_IE.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/bash
Init: sysvinit (via /sbin/init)

Versions of packages debianutils depends on:
ii  libc6  2.41-12+deb13u2

debianutils recommends no packages.

debianutils suggests no packages.

-- no debconf information
Add optional arguments -A, --after and -B, --before for greater control.
--- a/run-parts.8
+++ b/run-parts.8
@@ -11,7 +11,8 @@
 .SH SYNOPSIS
 .B run\-parts
 [\-\-test] [\-\-verbose] [\-\-debug] [\-\-report] [\-\-lsbsysinit] 
[\-\-regex=RE]
-[\-\-umask=umask] [\-\-arg=argument] [\-\-exit\-on\-error] [\-\-help]
+[\-\-umask=umask] [\-\-arg=argument] [\-\-after=PROG] [\-\-before=PROG]
+[\-\-exit\-on\-error] [\-\-help]
 [\-\-version] [\-\-list] [\-\-reverse] [\-\-] DIRECTORY [DIRECTORY ...]
 .PP
 .B run\-parts
@@ -109,6 +110,24 @@
 .B \-\-arg
 once for each argument you want passed.
 .TP
+.BI "\-A, \-\-after=" program
+run
+.I program
+after each script runs.  The program will be called with three
+arguments: script name, exit status, and total amount written to
+the output and error streams.  The last argument will always be 0
+unless the \-\-report option is also specified.  If this option is
+used multiple times, only the last one will take effect.  If the
+called program exits with an error code, it won't be called again.
+.TP
+.BI "\-B, \-\-before=" program
+run
+.I program
+before running each script.  The program will be called with one
+argument: the script name.  If this option is used multiple
+times, only the last one will take effect.  If the called program
+exits with an error code, it won't be called again.
+.TP
 .B "\-\-"
 specifies that this is the end of the options.  Any filename after
 .B "\-\-"
--- a/run-parts.c
+++ b/run-parts.c
@@ -31,6 +31,7 @@
 #include <signal.h>
 #include <sys/time.h>
 #include <regex.h>
+#include <inttypes.h>
 
 #define RUNPARTS_NORMAL 0
 #define RUNPARTS_ERE 1
@@ -56,6 +57,8 @@
 char *custom_ere;
 regex_t hierre, tradre, excsre, classicalre, customre;
 
+char *run_before, *run_after;
+
 static void catch_signals();
 static void restore_signals();
 
@@ -108,6 +111,8 @@
          "      --regex=PATTERN validate filenames based on POSIX ERE pattern 
PATTERN.\n"
          "  -u, --umask=UMASK   sets umask to UMASK (octal), default is 022.\n"
          "  -a, --arg=ARGUMENT  pass ARGUMENT to scripts, use once for each 
argument.\n"
+         "  -A, --after=PROG    run PROG after each script runs.\n"
+         "  -B, --before=PROG   run PROG before running each script.\n"
          "  -V, --version       output version information and exit.\n"
          "  -h, --help          display this help and exit.\n");
   exit(0);
@@ -182,12 +187,79 @@
     return retval;
 }
 
+/* wait for call return */
+static void wait_for_call(pid_t pid, char *progname, char **run_what)
+{
+  int result, rtc = 0, r;
+  r = waitpid(pid, &result, 0);
+
+  if (r == -1) {
+    error("waitpid: %s", strerror(errno));
+    exit(1);
+  }
+
+  if (WIFEXITED(result) && WEXITSTATUS(result)) {
+    error("%s %s exited with return code %d", *run_what, progname,
+      rtc = WEXITSTATUS(result));
+  }
+  else if (WIFSIGNALED(result)) {
+    error("%s exited because of uncaught signal %d", *run_what,
+      WTERMSIG(result));
+    rtc = 1;
+  }
+
+  if (rtc)
+    *run_what = NULL;
+}
+
+/* run run_before */
+static void call_run_before(char *progname)
+{
+  pid_t pid = fork();
+  if (pid < 0) {
+    error("failed to fork: %s", strerror(errno));
+    exit(1);
+  }
+  else if (!pid) {
+    restore_signals();
+    char *argv[3] = {run_before, progname, NULL};
+    execvp(run_before, argv);
+    error("failed to exec %s: %s", run_before, strerror(errno));
+    exit(1);
+  }
+
+  wait_for_call(pid, progname, &run_before);
+}
+
+/* run run_after */
+static void call_run_after(char *progname, uint64_t tot_wrote)
+{
+  pid_t pid = fork();
+  if (pid < 0) {
+    error("failed to fork: %s", strerror(errno));
+    exit(1);
+  }
+  else if (!pid) {
+    char wrote[32], status[32];
+    restore_signals();
+    snprintf(status, sizeof status, "%d", exitstatus);
+    snprintf(wrote, sizeof wrote, "%" PRIu64, tot_wrote);
+    char *argv[5] = {run_after, progname, status, wrote, NULL};
+    execvp(run_after, argv);
+    error("failed to exec %s: %s", run_after, strerror(errno));
+    exit(1);
+  }
+
+  wait_for_call(pid, progname, &run_after);
+}
+
 /* Execute a file */
 void run_part(char *progname)
 {
   int result, waited;
   int pid, r;
   int pout[2], perr[2];
+  uint64_t tot_wrote = 0;
 
   waited = 0;
 
@@ -195,6 +267,10 @@
     error("pipe: %s", strerror(errno));
     exit(1);
   }
+
+  if (run_before)
+    call_run_before(progname);
+
   if ((pid = fork()) < 0) {
     error("failed to fork: %s", strerror(errno));
     exit(1);
@@ -303,6 +379,7 @@
              fflush(stdout);
              printflag = 1;
            }
+           tot_wrote += c;
            ignored = write(STDOUT_FILENO, buf, c);
          }
          else if (c == 0) {
@@ -323,6 +400,7 @@
              fflush(stderr);
              printflag = 1;
            }
+           tot_wrote += c;
            ignored = write(STDERR_FILENO, buf, c);
          }
          else if (c == 0) {
@@ -368,6 +446,9 @@
          WTERMSIG(result));
     exitstatus = 1;
   }
+
+  if (run_after)
+    call_run_after(progname, tot_wrote);
 }
 
 static void handle_signal(int s)
@@ -709,10 +790,12 @@
       {"stdin", 0, &stdin_mode, 1},
       {"exit-on-error", 0, &exit_on_error_mode, 1},
       {"new-session", 0, &new_session_mode, 1},
+      {"after", 1, 0, 'A'},
+      {"before", 1, 0, 'B'},
       {0, 0, 0, 0}
     };
 
-    c = getopt_long(argc, argv, "u:ha:vV", long_options, &option_index);
+    c = getopt_long(argc, argv, "u:ha:A:B:vV", long_options, &option_index);
     if (c == EOF)
       break;
     switch (c) {
@@ -736,6 +819,12 @@
     case 'd':
       debug_mode = 1;
       break;
+    case 'A':
+      run_after = optarg;
+      break;
+    case 'B':
+      run_before = optarg;
+      break;
     case 'V':
       version();
       break;

--- End Message ---
--- Begin Message ---
Source: debianutils
Source-Version: 5.24
Done: Ileana Dumitrescu <[email protected]>

We believe that the bug you reported is fixed in the latest version of
debianutils, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to [email protected],
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Ileana Dumitrescu <[email protected]> (supplier of updated 
debianutils package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing [email protected])


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Format: 1.8
Date: Thu, 27 Aug 2026 17:54:35 +0300
Source: debianutils
Architecture: source
Version: 5.24
Distribution: unstable
Urgency: medium
Maintainer: Ileana Dumitrescu <[email protected]>
Changed-By: Ileana Dumitrescu <[email protected]>
Closes: 1131363 1131375
Changes:
 debianutils (5.24) unstable; urgency=medium
 .
   * d/control: Bump standards version from 4.7.2 to 4.7.4, bump
     debhelper-compat version from 13 to 14, and remove redundant
     field, Rules-Requires-Root: no.
   * acinclude.m4: Update DEBIANUTILS_VERSION to 5.24.
   * run-parts.c: Recognise short option for --debug (Closes: #1131363).
   * run-parts: Add options -A, --after and -B, --before for greater
     flexibility (Closes: #1131375).
   * d/tests/run-parts.test: Extend testing of run-parts for new options.
Checksums-Sha1:
 67bb18377ec346973ed7fd07bf95931a8d1bde14 1631 debianutils_5.24.dsc
 8748ed38f4a18ea04be9574ec2e9cd9002f21879 83012 debianutils_5.24.tar.xz
 c3ad85476074ae10cde4d62d4162567f0db772bc 6258 debianutils_5.24_amd64.buildinfo
Checksums-Sha256:
 ad439aa6c596e74d6a72fd76029543d2d58145bb6bb79036e8fa8be77f6f35a7 1631 
debianutils_5.24.dsc
 bf79c301ad48e82ddb09d8c0770f6d44294ee9529ae5e54164072f7bf5c57016 83012 
debianutils_5.24.tar.xz
 6c309721c0bcf0884ef31c119aaacf4e0eeb973451f1f3790e1759e79dd632ea 6258 
debianutils_5.24_amd64.buildinfo
Files:
 e475d5f49f57e30ecdb39af5bbec2ee7 1631 utils required debianutils_5.24.dsc
 3fb89e6356cba52322b64135df0d3954 83012 utils required debianutils_5.24.tar.xz
 3450c60c1dea74a8fc73bea4d78e6ebb 6258 utils required 
debianutils_5.24_amd64.buildinfo

-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEE+ibKeEvhiJJ/IrmfZXDqARRvc1QFAmqQUNQACgkQZXDqARRv
c1TEdg/9FDaGqdHYd1ZQVm2ZjpDtUHwXnGUk3ikvGCD1yr6CTjp8iZXBsJHy7ADX
RjKJOWbxBqLAFveKTrsj9ZMEOgB8RhP7pP4TOJTsjSleZrDiZRA1he7apyaO85BJ
VR9hH9VkewUoqNq6H+o9kvsdm9qpt0tLn1QBqE3p+qLnvEUWZQ/PtrQYfiDlHzx1
MNawiwJF8iCE1Ex43v5Ux1OtO4i0wEQLlNf072xVFuK8OsIJzUH//VBDQQvUvpfJ
ZJ4hi/0Q/RdE5XzNMW5kgaa7ZrHRIZt31CLZOr7s5YeVcPuQzjpWLpwaSwQSIEE2
HDwpI7phdgnna0jAAAoZDSvyuxEB14/TN/2Eh+638Nau7teDAZGdTZ64pW0LTdd7
t4QnNG0RNltgDogPllYjUZ9v7Pt2FmSwr2o4DOtgI3tl3ss4vpLIoqwe3UA7Iylr
K33fbn1cnpl6EsCFVGnCEPavMQTAC63WVNIjxj5cNqTjiSGIb9/mNkY6K2TXQq+5
dheiyQvas/6aBhfcUe7xpOdDZQtb87zHADD90ZVuSFe3Hm5u/HqKWnDC8u+3V2du
nRp1eAXqN3wR7jtWbeGhJU7iCZerdp+lswXnGnApj0iuW6Ta5PYenDXuyTTv8D46
+n7xC1f1UWCKPNNLoK4F7jRBGP4oBwdxghruyrfcr1FRvsF8ReE=
=jc67
-----END PGP SIGNATURE-----

Attachment: pgpT7uHpxx3mB.pgp
Description: PGP signature


--- End Message ---

Reply via email to