News for hackers. Stuff that matters.
Re:The tale of aux.c by drfuchs on Monday September 25, 2017 @10:11PM (#15335657)
So, you smug Linux guys think it can't happen to you? Well, before you get off my lawn, let me tell you a story...

Early versions of FrameMaker kept all resource files (internationalized strings, dialog box layouts, etc.) in the two subdirectories .../FrameMaker/Resources/{Unix,Core} (the first one for the Unix platform-specific resources, and the second for the cross-platform ones also used by the Mac and Windows ports). We had hundreds of happy customers, and had been shipping for 4 years or more.

But one new customer was calling in a panic. They'd installed the product, and it would work fine, but the next morning, it wouldn't even start up, and they had to re-install it. And then it would break again over night. After much pulling of hair and gnashing of teeth, it turns out that due to some other flakey product they were running, they had previously instituted a nightly cron job that ran around removing any core files it could find (since they were large and wasteful of precious disk space back in the day). And the knucklehead who wrote the script had it do a case-insensitive match on "core" and had it essentially do a "rm -rf" even though no true core file could be a directory. So, every night, our Core resource directory was blown away.

We actually had to change the product, as this was a big, important customer, and they outright refused to fix their cron script. Never had this problem on the Windows and Mac ports.

Re:The tale of aux.c by angelsl on Monday September 25, 2017 @11:29PM (#15335917)
This doesn't really have anything to do with *nix, but rather the customer being an idiot.
Re:The tale of aux.c by jlgaddis on Monday September 25, 2017 @11:19PM (#15335873)
While an interesting story, this is more of a self-imposed customer screw-up and not quite the same thing, IMO.
Re:The tale of aux.c by drfuchs on Tuesday September 26, 2017 @12:04AM (#15336045)
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.
Re:The tale of aux.c by TheDong on Tuesday September 26, 2017 @12:23AM (#15336141)
They 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.

Re:The tale of aux.c by inopinatus on Tuesday September 26, 2017 @05:25AM (#15337282)
If 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/ has the detail.

Re:The tale of aux.c by inopinatus on Tuesday September 26, 2017 @07:30AM (#15337728)
(^predictability)
Re:The tale of aux.c by jovial_cavalier on Tuesday September 26, 2017 @05:39AM (#15337324)
>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.

Re:The tale of aux.c by oblio on Tuesday September 26, 2017 @08:08AM (#15337888)
> 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.

Re:The tale of aux.c by jovial_cavalier on Tuesday September 26, 2017 @08:11AM (#15337898)
>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.

Re:The tale of aux.c by oblio on Tuesday September 26, 2017 @08:17AM (#15337927)
Well, 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

Re:The tale of aux.c by mort96 on Tuesday September 26, 2017 @04:16PM (#15342141)
I'm a professional software developer (well, "professional"; I have a part time programmming job next to studies), where I program in C++, compiling with GCC. I have never read GCC's manual. Expecting newcomers to read the 18 thousand lines of man page before trying to make a program isn't reasonable.

Of course, the man page is a great resource for looking things up, but I can't imagine many people sit down with GCC's man page and actually read it through.

Re:The tale of aux.c by Sean1708 on Tuesday September 26, 2017 @09:15AM (#15338317)
> Ah, yes, the age old Unix trope of, "it's not the system, it's the user's fault"

Except that example could also happen on Windows.

Re:The tale of aux.c by kps on Tuesday September 26, 2017 @10:19AM (#15338836)

  > For those that don't remember how tar works, the arguments are reversed compared to, say, cp.
Tar doesn't have positional file arguments; you use the 'f' flag to specify an archive file. You might be thinking of zip or some similar archiver in the DOS heritage.
Re:The tale of aux.c by oblio on Tuesday September 26, 2017 @11:57AM (#15339788)
My bad, I was actually talking about a very common tar idiom which is almost an automatism for me:

tar cvf/czvf/cjvf archive files (or -cvf/-czvf/-cjvf).

I don't think I've ever seen anyone actually using tar by going:

tar -c files -f archive

Online tutorials seem to also use my form: http://www.thegeekstuff.com/2010/04/unix-tar-command-example...

Either way, bad form, I'm glad they fixed it :)

Re:The tale of aux.c by _jal on Tuesday September 26, 2017 @10:12AM (#15338790)
Looks like it is time for this again...

> Ah, yes, the age old Unix trope of, "it's not the system, it's the user's fault"

Ah, yes, the age-old complaint that a car driver should be able to run a forklift with no practice.

I don't think Unixen should strive for 'user friendliness'. Hacking in "Do you really want to" dialogs would (a) be contrary to all expectations developed over a long time, (b) break a lot of existing software, (b) annoy the bloody hell out of everyone, and (d) not solve anything, because those dialogs don't prevent mistakes.

Not all systems need to converge, and Unix has been a professional toolchain since the beginning. You're expected to know something about it, just like you don't let kids run plasma cutters.

Re:The tale of aux.c by boomlinde on Wednesday September 27, 2017 @09:23AM (#15347530)
"My video of my kid's first at-bat, on a DVD in front of my plasma cutter, got mysteriously clobbered when I turned the cutter on."
Re:The tale of aux.c by TorKlingberg on Tuesday September 26, 2017 @04:48AM (#15337159)
If 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 "-".
Re:The tale of aux.c by zanchey on Tuesday September 26, 2017 @04:59AM (#15337200)
There's something in my environment that keeps creating a file called "-" in my home directory, and it's driving me crazy.
Re:The tale of aux.c by jovial_cavalier on Tuesday September 26, 2017 @05:36AM (#15337310)
By convention, when a unix program is passed "--" it means there are no more flags being passed. Try the following:

$ rm -- -

Re:The tale of aux.c by ConfucianNardin on Tuesday September 26, 2017 @06:33AM (#15337515)
This will not work with all rm implementations, in which case you can fall back to: rm ./-
Re:The tale of aux.c by zanchey on Tuesday September 26, 2017 @09:09AM (#15338264)
Oh, I can remove it... And a few hours or days later it's back!
Re:The tale of aux.c by jovial_cavalier on Tuesday September 26, 2017 @10:06AM (#15338739)
Okay, you're gonna want to type $sudo crontab -e...
Re:The tale of aux.c by codedokode on Tuesday September 26, 2017 @12:20PM (#15340076)
It is better to write EDITOR=nano sudo crontab ... otherwise instead of edititng the crontab you will be solving the problem of exiting vi.
Re:The tale of aux.c by zanchey on Wednesday September 27, 2017 @12:47AM (#15345002)
All the interest encouraged me to dig in and find it, and it turned out to be in one of zsh's many startup scripts.
Re:The tale of aux.c by RHSeeger on Tuesday September 26, 2017 @09:11AM (#15338283)
Open the parent directory with emacs and you can use it to delete the rogue directory/file. Admittedly, there's easier ways for a "-" named file, but its a good solution to know since you can use it to delete even the most difficult filenames.
Re:The tale of aux.c by jsymolon on Tuesday September 26, 2017 @06:37AM (#15337527)
list the file showing inode number, rm by that particular inode.
Re:The tale of aux.c by YSFEJ4SWJUVU6 on Tuesday September 26, 2017 @10:48AM (#15339122)
While GNU's not unix... afaik GNU coreutils' rm has done exactly what you expect it to when given a single dash as an argument for who knows how long.

The problem is names that could be interpreted like options, like '-f' or '--help'.

Re:The tale of aux.c by mort96 on Tuesday September 26, 2017 @04:21PM (#15342184)
Interestingly, when the shell expands * , it won't do anything to make sure files starting with - are handled properly.

This means, if you're in a directory with the files a, b, -rf, and the directories foo/ and bar/, running "rm * " will not delete all the files and keep all the directories; instead it will be turned into "rm a b bar foo -rf", meaning it will delete all the files and directories except for the file -rf.

Re:The tale of aux.c by xelxebar on Wednesday September 27, 2017 @01:43AM (#15345195)
I've definitely run into this on bash and zsh (iirc). I'm curious if this glob expansion behaviour is set in posix somewhere.
Re:The tale of aux.c by jlgaddis on Tuesday September 26, 2017 @06:43AM (#15337551)

  rm -- -
[dead]
Re:The tale of aux.c by ComputerGuru on Tuesday September 26, 2017 @07:39AM (#15337772)
> I wonder how you fare with using more complex software, like a web browser...

That snark isn’t necessary. It’s easier to use a web browser than to delete a file called - from the terminal. Or haven’t you used a non-GUI system before?

Re:The tale of aux.c by exprA on Tuesday September 26, 2017 @07:52AM (#15337824)
I don't agree with that at all; a web browser has easily a more complex user interface than a single-purpose command-line tool like “rm” – and that is even before we open any document at all, with all their conventions we have to learn before we can effectively navigate them.

Everything has a learning curve, of course, but are you sure you're just not much more familiar with one of these two?

(edit: just to clarify, what do you expect a decent rm to do when given a single argument of “-”? While there may still be systems where that does not do what you'd expect it to do – it's no different to existing obsolete versions of browsers that do nothing at all when you type in something other than a valid URL in the address bar – and are thus considerably harder to use for some not familiar with the technology. The harder corner case would be to try and remove a file with name that can be confused for a valid flag – like '-i' – but even then, that's about the only corner case for the tool, and not a steep step to learn. Any recent coreutils rm will even suggest a valid command to remove files that look like options, but are not actually valid options, so some thought has been given to discoverability as well.)

Re:The tale of aux.c by gkya on Tuesday September 26, 2017 @04:23AM (#15337049)
You 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.
Re:The tale of aux.c by inopinatus on Tuesday September 26, 2017 @07:31AM (#15337734)
Actually, not only did they do exactly that, they could even be induced to do so through a symlimk, with hilarious results.
Re:The tale of aux.c by gkya on Tuesday September 26, 2017 @10:22AM (#15338863)
I'm really curious about them hilarious results now :)
Re:The tale of aux.c by mort96 on Tuesday September 26, 2017 @04:28PM (#15342227)
Actually, 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 :)

Re:The tale of aux.c by cannam on Tuesday September 26, 2017 @07:50AM (#15337811)
We had a source directory named "core" in an early version of the Rosegarden sequencer. At the time our build system was a simple Makefile, but in 2000 we switched to Automake and quickly learned that in some circumstances, using the Automake-generated Makefiles, "make clean" would delete the entire directory. Have generally avoided that name since then.
Re:The tale of aux.c by technofiend on Monday September 25, 2017 @10:38PM (#15335740)
Seriously? They couldn't be bothered to add -type f? Depending on context I can be a big customer but I'd be embarrassed to ask you to work around something like that. My odd-ball only on Wall Street security system I can't do much about but sheesh that's like a couple of minutes to test. They probably couldn't push it everywhere easily?
Re:The tale of aux.c by batat on Tuesday September 26, 2017 @09:16AM (#15338327)
Re:The tale of aux.c by exprA on Tuesday September 26, 2017 @09:34AM (#15338458)
I.e. “how do I operate my shell”. You certainly want to understand shell expansion to get stuff done effectively.
Re:The tale of aux.c by hossbeast on Monday September 25, 2017 @10:35PM (#15335730)
How is this specific to Linux?
Re:The tale of aux.c by drfuchs on Monday September 25, 2017 @11:11PM (#15335849)
Ok, "unix-derivative" if you prefer. FWIW, it actually happened on SunOS or maybe HP-UX, and it was before Linux existed.
Re:The tale of aux.c by flukus on Tuesday September 26, 2017 @12:42AM (#15336236)
But it could have just as easily been a windows batch file, it's not related to the OS at all.
Re:The tale of aux.c by kieranelby on Tuesday September 26, 2017 @03:16AM (#15336805)
Well, apart from the fact that UNIX-like systems have traditionally dumped core files in programs' working directories if they crash, so needing a script to clean them up.

Linux still does, though many distros set ulimit or /proc/sys/kernel/core_pattern to disable it.

Re:The tale of aux.c by SolarNet on Tuesday September 26, 2017 @04:54AM (#15337181)
Windows does this too, except it hides them in it's system folders, it even comes with a built in clean-up script you can run. Not a problem that is worse on *nix.
Re:The tale of aux.c by pjc50 on Tuesday September 26, 2017 @05:53AM (#15337378)
I'm reminded of when I discovered on a production system that "killall" is very different on Solaris to Linux.
Re:The tale of aux.c by alexeiz on Tuesday September 26, 2017 @09:53AM (#15338611)
I hope that customer paid you enough for you trouble. But obviously it wasn't as much as it would have cost them to fix their crappy cron script.
Re:The tale of aux.c by bitwize on Tuesday September 26, 2017 @11:01AM (#15339242)
The lesson here is "suck it up and build software for the systems your customers use, not the ones you wish they used".
Re:The tale of aux.c by cup-of-tea on Tuesday September 26, 2017 @07:48AM (#15337804)
Nice story, but unrelated. And I'm not sure why you mention Linux at all.