409 reputation
26
bio website etalabs.net
location
age
visits member for 3 years, 7 months
seen 6 hours ago

Oct
8
comment How do I delete all of a set of files in a random order?
This answer is unsafe as written, at least in general. find outputs literal strings separated by newlines, and xargs reads a shell-quoted, whitespace-delimited list of names as input. A malicious name in the input can trick it into deleting something very different from what you intended to delete.
Sep
11
comment why 'echo --help' doesn't give me help page of echo?
@Tyilo: Rather than re-explaining it I liked to a page where I already explained the answer to that question.
Sep
10
comment why 'echo --help' doesn't give me help page of echo?
@Tyilo: See the specification in POSIX, or my coverage of the issue here: etalabs.net/sh_tricks.html
Sep
5
comment why 'echo --help' doesn't give me help page of echo?
Note that production of a help message by echo --help is a bug. Imagine what happens if you do: printf "The option you entered is: " ; echo "$opt" and the shell variable opt happens to be contain the text --help. Per the POSIX standard, echo is not permitted to behave in this way, but the GNU echo is obnoxiously non-conforming.
Aug
15
awarded  Yearling
Aug
9
awarded  Nice Answer
Aug
9
comment Why does ls accept duplicate switches?
@kasperd: Yes. Although putting -l in your ls alias seems like a bad idea, the same issue is likely to arise with options that are nice in an interactive ls alias like -p or --color=auto.
Aug
8
answered Why does ls accept duplicate switches?
Aug
3
comment Can GPL software be bought by a company and still released as GPL?
The license part of the question is actually irrelevant, since the people producing the malware-infected files advertised on sourceforge with ads that look like a legitimate download button have little reason to care if what they're doing is illegal. I think the important part of OP's question, even though it wasn't stated as such, is how this happened.
Aug
3
answered Can GPL software be bought by a company and still released as GPL?
Jun
10
comment Will Linux start killing my processes without asking me if memory gets short?
Citation: kernel.org/doc/Documentation/vm/overcommit-accounting
Jun
10
comment Will Linux start killing my processes without asking me if memory gets short?
Your understanding of the different values is wrong. 2 turns off overcommit off completely. 0 is the traditional "off" setting that doesn't really turn it off. 1 allows unlimited overcommit.
May
29
comment Is there a way in Linux to have one non root user check if another non root user has permissions to a folder / file?
Indeed, access is almost always a bug. It's subject to TOCTOU races and it uses the real uid/gid rather than the effective (or, if it's set differently, the Linux-specific fsuid/fsgid) uid/gid to determine permissions, which is almost never what you want unless they all happen to be equal.
May
26
comment Can the /home folder in Linux contain anything else but user folders?
@JamesN: If the other HD is formatted for use by windows, the problem is not going to be what it contains, but the fact that it's unsuitable for many uses that applications might expect to work. For instance, lacking symlink and hardlink support, case-sensitive filenames, fifos, unix sockets, ...
May
13
comment Why *not* parse `ls`?
@mikeserv: Then tell me what you want me to demonstrate. Patrick already gave you examples of directory contents which your method fails to parse (because they are indistinguishable by it). For any method you're using (please pick one for the sake of being specific) I'm happy to provide you a trivial example of a directory it fails to properly parse. The fact that you can construct specific examples which you think are "hard" and successfully parse them has no bearing on whether your method works in general.
May
13
comment Why *not* parse `ls`?
@mikeserv: The set command, like all commands to the shell, receives a list of arguments (ala argv[]) that come from shell words on the original command line. set itself does not do any word splitting. This is all described in POSIX XCU Chapter 2. Word-splitting is applied to the command line for set, like any other command, but it happens before glob expansion.
May
13
comment Why *not* parse `ls`?
@mikeserv: No, I just gave the most trivial example to explain the point that concatenation does not occur. The correct usage of set -- with globs also avoids any concatenation and word splitting. The incorrect usage of set -- with the output of ls does involve concatenation (inherent in the way ls writes output: as a stream of bytes, not a list of strings) and word splitting.
May
13
comment Why *not* parse `ls`?
@mikeserv: No it doesn't. I think this is the core of your misunderstanding. The shell never concatenates the filenames to begin with. In the shell, globs expand each result to a separate shell word. Thus usages like for i in * ; do ... ; done are safe, whereas usages like for i in $(echo *) ; do ... ; done are not (the latter has a concatenation step followed by a separate word-splitting step).
May
13
comment Why *not* parse `ls`?
@mikeserv: Your claim is simply wrong. If you have a sequence of strings and you concatenate them using a separator that can appear in the individual strings, there is no way to recover the original list of strings. To solve this problem you would need a reversible form of escaping, which ls does not provide. If it did provide such a feature you could write a very complex script to recover the filenames, but it's utter nonsense when the shell gives you a trivially-correct way to do the same thing with no danger of misinterpreting the results.
May
13
comment Why *not* parse `ls`?
@mikeserv: You have a stream of text produced by ls that can contain any bytes except the null byte or the slash. There is fundamentally no way to recover that into a list of filenames. The transformation ls does is non-reversible, even if it doesn't replace any nonprintable characters. When it replaces non-printable characters, you're in an even worse situation.