Unix Wildcards Gone Wild
11–20 of 54 posts
Re: Unix Wildcards Gone Wild
#12David A. Wheeler, FOSS (and occasionally security) luminary, who also happens to be creator of the popular sloccount tool, has an excellent page that covers this topic and how to use paths safely and portably in shell scripts (spoiler: it's hard ) : http://www.dwheeler.com/essays/filenames-in-shell.html I strongly recommend his many other essays to HN readers: http://www.dwheeler.com/ Edit: a simple way to avoid thes…
Re: Unix Wildcards Gone Wild
#13David A. Wheeler, FOSS (and occasionally security) luminary, who also happens to be creator of the popular sloccount tool, has an excellent page that covers this topic and how to use paths safely and portably in shell scripts (spoiler: it's hard ) : http://www.dwheeler.com/essays/filenames-in-shell.html I strongly recommend his many other essays to HN readers: http://www.dwheeler.com/ Edit: a simple way to avoid thes…
The double dash -- to stop option parsing is not a GNU thing – it comes from the POSIX standard.
Re: Unix Wildcards Gone Wild
#14 rsync example.com:/foo/* .
My workaround is to quote the argument, but it's annoying.Re: Unix Wildcards Gone Wild
#15Tangentially, anyone know how to make zsh less greedy about parsing wildcards? Something like this will fail with "no files matched", and the command won't run: rsync example.com:/foo/* . My workaround is to quote the argument, but it's annoying.
rsync -a example.com:/foo/. .
rsync example.com:/foo/"*" .Re: Unix Wildcards Gone Wild
#16There's a reason this isn't talked about, it's not an actual legitimate/common vector to compromise a server.
Re: Unix Wildcards Gone Wild
#17Tangentially, anyone know how to make zsh less greedy about parsing wildcards? Something like this will fail with "no files matched", and the command won't run: rsync example.com:/foo/* . My workaround is to quote the argument, but it's annoying.
rsync accepts globbing it's not a shell expansion that makes it work.
rsync example.com:/foo/\* .Re: Unix Wildcards Gone Wild
#18Re: Unix Wildcards Gone Wild
#19 echo rm *
echo chown -R nobody:nobody *.php
echo chmod 000 *
echo tar cvvf archive.tar *
echo tar cf archive.tar *
echo rsync -t *.c foo:src
This article starts with the premise that the person executing the command has no idea what files are in the current working directory. That is itself a more serious problem than the behaviour of wildcards.Later in the article we learn that it also assumes GNU utilities. That is a second problem (IMO), and arguably also one more serious than the behaviour of wildcards. GNU userland and unneeded complexity (e.g. more features than any user will ever use) are practically synonymous.
Then there is the peculiar assumption that someone can place arbitrary files beginning with - or -- on this system. That itself is a far more serious problem than the behaviour of wildcards; I would say with that capability it is more or less "game over". In BSD you have, at the very least, mtree. How does the Linux user know she isn't executing some substituted executable?
Moreover, if caution was important to the hypothetical user in the examples, I think they would be in the form
/path/to/program *