Bug#1112120: trixie-pu: package mc/3:4.8.33-1+deb13u1
Package: release.debian.org
Severity: normal
Tags: trixie
X-Debbugs-Cc: tg@mirbsd.de, mc@packages.debian.org
Control: affects -1 + src:mc
User: release.debian.org@packages.debian.org
Usertags: pu
Please pre-approve upload of mc (= 3:4.8.33-1+deb13u1).
[ Reason ]
This is a fix for a rather severe bug that caused exactly ten
seconds delay upon each start of mc depending on the user’s shell
and other environmental circumstances.
[ Impact ]
Rather annoying delays (I’ve found it impossible to work with it,
which is why I invested effort into fixing it).
[ Tests ]
None.
[ Risks ]
Low to nōn-existent. While the fix merely changes the order of two
code blocks so a file descriptor gets a slightly lower number, it
can only fix the issue, not introduce a regression (worst case is
it doesn’t fix it, but for the code in trixie, AFAICT it’ll always
end up with a suitable fd number with this patch applied).
The patch is merged upstream (though upstream will want to refactor
their startup code to reduce chances of this regressing when more
code is added to mc in the future).
I’ve been running this exact patch for months now.
[ Checklist ]
[x] *all* changes are documented in the d/changelog
[x] I reviewed all changes and I approve them
[x] attach debdiff against the package in (old)stable
[ ] the issue is verified as fixed in unstable
[ Changes ]
The patch moves two code blocks that allocate file descriptors
so the critical one gets a number smaller than 10.
[ Other info ]
I’ve NMU’d the package to get this fixed in unstable in 5 days.
diff -Nru mc-4.8.33/debian/changelog mc-4.8.33/debian/changelog
--- mc-4.8.33/debian/changelog 2025-01-29 06:43:17.000000000 +0000
+++ mc-4.8.33/debian/changelog 2025-08-26 16:08:19.000000000 +0000
@@ -1,3 +1,10 @@
+mc (3:4.8.33-1+deb13u1) trixie; urgency=high
+
+ * Non-maintainer upload.
+ * Added debian/patches/subshell-fd.patch (Closes: #1108061)
+
+ -- Thorsten Glaser <tg@mirbsd.de> Tue, 26 Aug 2025 16:08:19 +0000
+
mc (3:4.8.33-1) unstable; urgency=medium
* New upstream release.
diff -Nru mc-4.8.33/debian/patches/series mc-4.8.33/debian/patches/series
--- mc-4.8.33/debian/patches/series 2024-05-02 10:56:45.000000000 +0000
+++ mc-4.8.33/debian/patches/series 2025-08-26 16:04:06.000000000 +0000
@@ -1,5 +1,6 @@
## UPSTREAM / FORWARDED:
2987.patch
+subshell-fd.patch
## DEBIAN FIXES AND ENHANCEMENTS:
dummy-zip-password.patch
diff -Nru mc-4.8.33/debian/patches/subshell-fd.patch mc-4.8.33/debian/patches/subshell-fd.patch
--- mc-4.8.33/debian/patches/subshell-fd.patch 1970-01-01 00:00:00.000000000 +0000
+++ mc-4.8.33/debian/patches/subshell-fd.patch 2025-08-26 16:04:06.000000000 +0000
@@ -0,0 +1,90 @@
+Description: fix accidental use of >&10 for subshells
+ POSIX requires shells to only support fd numbers of up to 9
+ for I/O redirections but mc inserts PS1 with “pwd>&%d”, where
+ %d is subshell_pipe[WRITE] which can be a number ≥ 10 which
+ can cause a number of failures in shells that don’t extend
+ beyond POSIX: an error seen when stracing; a ten-second delay
+ at startup; “Pause after run” ignored…
+ .
+ This patch moves the pipe(2) call to slightly earlier so the
+ chance to get a low enough fd is better.
+Bug: https://github.com/MidnightCommander/mc/issues/4634
+Forwarded: https://github.com/MidnightCommander/mc/pull/4724
+Author: Thorsten Glaser <tglaser@b1-systems.de>
+
+--- a/src/subshell/common.c
++++ b/src/subshell/common.c
+@@ -1537,36 +1537,6 @@ init_subshell (void)
+ if (mc_global.shell->type == SHELL_NONE)
+ return;
+
+- /* Open a pty for talking to the subshell */
+-
+- /* FIXME: We may need to open a fresh pty each time on SVR4 */
+-
+-#ifdef HAVE_OPENPTY
+- if (openpty (&mc_global.tty.subshell_pty, &subshell_pty_slave, NULL, NULL, NULL))
+- {
+- fprintf (stderr, "Cannot open master and slave sides of pty: %s\n",
+- unix_error_string (errno));
+- mc_global.tty.use_subshell = FALSE;
+- return;
+- }
+-#else
+- mc_global.tty.subshell_pty = pty_open_master (pty_name);
+- if (mc_global.tty.subshell_pty == -1)
+- {
+- fprintf (stderr, "Cannot open master side of pty: %s\r\n", unix_error_string (errno));
+- mc_global.tty.use_subshell = FALSE;
+- return;
+- }
+- subshell_pty_slave = pty_open_slave (pty_name);
+- if (subshell_pty_slave == -1)
+- {
+- fprintf (stderr, "Cannot open slave side of pty %s: %s\r\n",
+- pty_name, unix_error_string (errno));
+- mc_global.tty.use_subshell = FALSE;
+- return;
+- }
+-#endif /* HAVE_OPENPTY */
+-
+ /* Create a pipe for receiving the subshell's CWD */
+
+ if (mc_global.shell->type == SHELL_TCSH)
+@@ -1608,6 +1578,36 @@ init_subshell (void)
+ mc_global.tty.use_subshell = FALSE;
+ return;
+ }
++
++ /* Open a pty for talking to the subshell */
++
++ /* FIXME: We may need to open a fresh pty each time on SVR4 */
++
++#ifdef HAVE_OPENPTY
++ if (openpty (&mc_global.tty.subshell_pty, &subshell_pty_slave, NULL, NULL, NULL))
++ {
++ fprintf (stderr, "Cannot open master and slave sides of pty: %s\n",
++ unix_error_string (errno));
++ mc_global.tty.use_subshell = FALSE;
++ return;
++ }
++#else
++ mc_global.tty.subshell_pty = pty_open_master (pty_name);
++ if (mc_global.tty.subshell_pty == -1)
++ {
++ fprintf (stderr, "Cannot open master side of pty: %s\r\n", unix_error_string (errno));
++ mc_global.tty.use_subshell = FALSE;
++ return;
++ }
++ subshell_pty_slave = pty_open_slave (pty_name);
++ if (subshell_pty_slave == -1)
++ {
++ fprintf (stderr, "Cannot open slave side of pty %s: %s\r\n",
++ pty_name, unix_error_string (errno));
++ mc_global.tty.use_subshell = FALSE;
++ return;
++ }
++#endif /* HAVE_OPENPTY */
+ }
+
+ /* Fork the subshell */
Reply to: