[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: suggestion: $LS_ARGS
From: |
Eric Blake |
Subject: |
Re: suggestion: $LS_ARGS |
Date: |
Tue, 27 Feb 2018 07:59:02 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 |
On 02/27/2018 01:38 AM, Harald Dunkel wrote:
please consider
- there are tons of magic vars in wide use today: LANG and
LC_xxx,
These are required by POSIX. They are well-documented, and portable
scripts already know they exist.
LD_LIBRARY_PATH,
This one is already relatively well-known, and is frequently mentioned
as something that must be sanitized.
LS_COLORS,
This one does NOT change default behavior. Rather, it changes the
behavior when a non-default option is specified.
TAPE, etc. Some of them
are pretty close to a vulnerability, but they are in daily
use, still.
Our complaint is that we shouldn't be making the list longer, by
introducing NEW variables. Existing variables are harder to eradicate,
but we don't want to make the mess bigger.
- AFAICS coreutils' ls (as of 8.29) is not compatible to the
"standard" ls anyway, already changing its behavior on the
fly, unless (!) you define QUOTING_STYLE.
Changing interactive output on the fly does not violate POSIX, or we
would not have made the change. Setting QUOTING_STYLE indeed risks
making ls change what it produces in non-interactive output, but only
for filenames that are not portable to POSIX in the first place.
Sample:
% touch /tmp/a\ b
% ls -1 /tmp/a\ b
'/tmp/a b'
% src/ls -1 /tmp/a\ b | cut -d\' -f1
/tmp/a b
% export QUOTING_STYLE=shell
% src/ls -1 /tmp/a\ b | cut -d\' -f1
%
When did pipes become unreliable?
You just demonstrated why environment variables should NOT be relied on
to change default behaviors - the fact that the pipe produced different
output according to QUOTING_STYLE means that QUOTING_STYLE can silently
trip up scripts, and therefore scripts should probably sanitize
QUOTING_STYLE if they expect to parse ls output (although parsing ls
output is already a questionable activity).
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org