← Commit list

2d7ff2c90

Denys Vlasenko
Denys Vlasenko
2025-08-01
SUCCESS Duration: 152s

Subject

ls: don't do unnecessary tty operations when called from ftpd

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

coreutils/ls.c+13 -5
@@ -1206,6 +1206,18 @@ int ls_main(int argc UNUSED_PARAM, char **argv)
exit(0);
#endif
+ /* ftpd secret backdoor? */
+ if (ENABLE_FTPD && applet_name[0] == 'f') {
+ /* dirs first are much nicer */
+ opt = option_mask32 |= OPT_dirs_first;
+ /* don't show SEcontext */
+ IF_SELINUX(opt = option_mask32 &= ~OPT_Z;)
+ /* do not query stdout about size and tty-ness */
+ IF_FEATURE_LS_WIDTH(G_terminal_width = INT_MAX;)
+ G.tty_out = 1; /* not a tty */
+ goto skip_if_ftpd;
+ }
+
#if ENABLE_FEATURE_LS_WIDTH
if ((int)G_terminal_width < 0) {
/* obtain the terminal width */
@@ -1256,6 +1268,7 @@ int ls_main(int argc UNUSED_PARAM, char **argv)
}
}
#endif
+ skip_if_ftpd:
/* sort out which command line options take precedence */
if (ENABLE_FEATURE_LS_RECURSIVE && (opt & OPT_d))
@@ -1279,11 +1292,6 @@ int ls_main(int argc UNUSED_PARAM, char **argv)
if (!(opt & OPT_q) && G_isatty())
opt = option_mask32 |= OPT_q;
- if (ENABLE_FTPD && applet_name[0] == 'f') {
- /* ftpd secret backdoor. dirs first are much nicer */
- opt = option_mask32 |= OPT_dirs_first;
- }
-
argv += optind;
if (!argv[0])
*--argv = (char*)".";