10 ms·
A more direct (though fictional) illustration that Unix also has reserved file names that you'd better avoid: "I was writing a novel about digging to the center
by drfuchs 9y ago
A more direct (though fictional) illustration that Unix also has reserved file names that you'd better avoid: "I was writing a novel about digging to the center of the Earth, entitled "core". One day I was running some program that crashed, and my novel turned into a bunch of binary gibberish." Or how about: "My video of my kid's first at-bat, in a file I named a.out, got mysteriously clobbered when I took my first programming class." These are more insidious than the MSDOS examples, which at least fail right away.
- TheDong 9y agoThey are less insidious by far. You're really reaching for threads here. The first, `core`, isn't relevant. `/proc/sys/kernel/core_pattern` configures that value, and by default it's named "core.$PID" nowadays. That's far better than windows' wart since it's configurable, disableable, etc. Your second example is even more contrived. If you run a tool which writes files, of course it can overwrite files. I don't complain that in windows when I type "copy foo bar" my "bar" file is overwritten by "foo". In the same way, someone who voluntarily runs "gcc x.c" or "cat > foo" should not be surprised when "a.out" and "foo" respectively are overwritten. There's a massive difference between an unconfigurable gotcha based on a filename and an explicit action which writes a file.
- gkya 9y agoYou don't really put videos into a program's source tree. Also I don't think any modern Unix-like OS would overweite a file with a core dump no matter what is the name, and doubt that ancient versions did so too. Having the same set of device files under every directory is quite a different thing.
- inopinatus 9y agoActually, not only did they do exactly that, they could even be induced to do so through a symlimk, with hilarious results.
- gkya 9y agoI'm really curious about them hilarious results now :)
- mort96 9y agoActually, when I just want to test something silly, I often just go to ~, make a file test.c or something, write the short test program, and run `gcc -o test test.c`. It's not that rare to have videos in your home directory, and if I had one named a.out, and forgot the -o option, it'd get overwritten. Not saying it's remotely likely, just saying that having video files in a program's source tree isn't the only way it could happen :)
- TorKlingberg 9y agoIf we're going to criticise Unix file naming, I'd rather talk about how file names with spaces in them break things, or how hard it is do delete a file named "-".
- zanchey 9y agoThere's something in my environment that keeps creating a file called "-" in my home directory, and it's driving me crazy.
- jovial_cavalier 9y agoBy convention, when a unix program is passed "--" it means there are no more flags being passed. Try the following: $ rm -- -
- ConfucianNardin 9y agoThis will not work with all rm implementations, in which case you can fall back to: rm ./-
- zanchey 9y agoOh, I can remove it... And a few hours or days later it's back!
- jovial_cavalier 9y agoOkay, you're gonna want to type $sudo crontab -e...
- codedokode 9y agoIt is better to write EDITOR=nano sudo crontab ... otherwise instead of edititng the crontab you will be solving the problem of exiting vi.
- zanchey 9y ago
- inopinatus 9y agoIf you'd like a real world example, I once used the predictably of core dump filenames to (legitimately) gain root access to a busy public nameserver. https://inopinatus.org/2015/08/24/privilege-escalation/ https://inopinatus.org/2015/08/24/privilege-escalation/ has the detail.
- inopinatus 9y ago(^predictability)
- jovial_cavalier 9y ago>My video of my kid's first at-bat, in a file I named a.out, got mysteriously clobbered when I took my first programming class. This is a failure to understand GCC's default behavior, not a fundamental flaw with your operating system. The "core" thing is a little more understandable, but it can all be remedied by choosing reasonable filenames with accurate file extensions. "aux.c" isn't that unreasonable, and if I'm reading it right, he could've called it "aux.foo" and it still would've been broken.
- oblio 9y ago> This is a failure to understand [Program X]'s default behavior, not a fundamental flaw with your operating system. Ah, yes, the age old Unix trope of, "it's not the system, it's the user's fault". As a Linux user for many years, that doesn't excuse such boneheaded errors. By default no application should clobber existing files, unless asked to. Avoid data loss and all that. Heck, I remember back when: tar myfile.txt myarchive.tar would result in myfile.txt being truncated to 0 bytes (therefore deleting its contents) and a snarky message that myarchive.tar can't be archived because it can't be found. For those that don't remember how tar works, the arguments are reversed compared to, say, cp. At least I think they've fixed it, newer tar version says something like "Cowardly refusing to create an empty archive". The Unix ecosystem, dragged kicking and screaming towards user-friendliness since 1970.
- jovial_cavalier 9y ago>Ah, yes, the age old Unix trope of, "it's not the system, it's the user's fault". Well, if the user had read the manual before using GCC, it wouldn't have happened. Regardless, I don't blame them or look down my nose at them. It's bad design. If it's anyone's fault, it's GCC's. But it's certainly not a problem with Unix. This makes it incomparable to the system-level issue of having global filenames like DOS did, apparently.
- oblio 9y agoWell, as far as modern design goes, I doubt many people argue that Unix was better designed than DOS. DOS was a single user, single tasking OS meant for very limited hardware. While Unix was kind of Ok, when coupled with its common userland utilities, the whole often felt like a cactus. Possibly useful, if you don't mind the scars :D