diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2025-08-01 18:16:46 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2025-08-01 18:16:46 +0200 |
| commit | 2d7ff2c909c6dce95a8780d00e2089f0c507dd25 (patch) | |
| tree | be6894435c00b47c0be5c2139914092871ec234a /coreutils/ls.c | |
| parent | 4f43bda9472aeea372f6ab30bbef229b6c5f2c76 (diff) | |
ls: don't do unnecessary tty operations when called from ftpd
function old new delta
ls_main 660 690 +30
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils/ls.c')
| -rw-r--r-- | coreutils/ls.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/coreutils/ls.c b/coreutils/ls.c index 200baff03..c24561576 100644 --- a/coreutils/ls.c +++ b/coreutils/ls.c @@ -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*)"."; |
