Earlier quoted context omitted.
Agreed, I should've elaborated. All it takes is something like this in the init script without checking if the variable is empty: rm -rf "$STEAMROOT/"*
I feel like it would be a frighteningly common bug. I remember one like this from 2011 [1]. Install/packaging/utility scripts usually do not get as much attention and testing as the application code itself. [1] https://github.com/MrMEEE/bumblebee-Old-and-abbandoned/issue...
Bug 1202858 – Restarting squid results in deleting all files in hard-drive
71–80 of 179 posts
Re: Bug 1202858 – Restarting squid results in deleting all files in hard-drive
#72Scary. Even more scary is the fact that the bug has been open for a week, one person has confirmed 100% reproducibility, and no one seems to care at Red Hat. Isn't deleting peoples hard drives a big no no ?
Ahh Redhat, the distro which chose to symlink a bunch of binary lib files from Apache into the etc directory. "Why is grepping /etc taking so long? Binary files in /etc?!? WTF?!?" Coming from Debian, Redhat seems to make a lot of irk-worthy choices.
Re: Bug 1202858 – Restarting squid results in deleting all files in hard-drive
#73My good old trick to mitigate that is: touch /-@ I also always do it in my home directory: touch ~/-@ That's the first thing I do on a new host. When accidentally running rm -f *, the command expands to -@ first, which is not a valid option and makes the command fail before doing any harm rm: illegal option -- @ usage: rm [-f | -i] [-dPRrvW] file ...
That won't actually help with rm -rf /* , only with rm -rf * in / or $HOME.
Re: Bug 1202858 – Restarting squid results in deleting all files in hard-drive
#74Earlier quoted context omitted.
Agreed, I should've elaborated. All it takes is something like this in the init script without checking if the variable is empty: rm -rf "$STEAMROOT/"*
And this is why it is important to write something like set -eu on top of your bash scripts -- execution will stop on errors (non-zero retvals) and on undefined variables.
Re: Bug 1202858 – Restarting squid results in deleting all files in hard-drive
#75My good old trick to mitigate that is: touch /-@ I also always do it in my home directory: touch ~/-@ That's the first thing I do on a new host. When accidentally running rm -f *, the command expands to -@ first, which is not a valid option and makes the command fail before doing any harm rm: illegal option -- @ usage: rm [-f | -i] [-dPRrvW] file ...
As someone who uses the commandline a lot but isn't exactly a wizard, why does this work?
Example:
$ echo /*
/bin /boot /dev /etc /home (...)
Re: Bug 1202858 – Restarting squid results in deleting all files in hard-drive
#76Earlier quoted context omitted.
or check the variable before using it, like any other programming language: [[ "$VAR" ]] && rm -rf "$VAR/*" I think most of these issues stem from the fact that most developers that write shell scripts don't actually understand what they're doing, treating the script as a necessary annoyance rather than a component of the software.
> like any other programming language some real-world programming languages don't have undefined variables :)
Being the emptys string "" would work just as well.
Re: Bug 1202858 – Restarting squid results in deleting all files in hard-drive
#77Maybe I would add a new record to this https://github.com/icy/bash-coding-style#good-lessons
Re: Bug 1202858 – Restarting squid results in deleting all files in hard-drive
#78Earlier quoted context omitted.
That's kind of scary — in that case I guess I should avoid creating a file named -rf.
That is really interesting. Can someone knowledgeable about the shell expand on this? I don't dare test it on my machine.
$ touch important
$ chmod 400 important
$ rm *
override r-------- vbezhenar/staff for important? n
$ touch -- -rf
$ ls -l
total 0
-rw-r--r-- 1 vbezhenar staff 0 Mar 24 14:35 -rf
-r-------- 1 vbezhenar staff 0 Mar 24 14:35 important
$ rm *
$ ls -l
total 0
-rw-r--r-- 1 vbezhenar staff 0 Mar 24 14:35 -rf
$ rm -- -rfRe: Bug 1202858 – Restarting squid results in deleting all files in hard-drive
#79Earlier quoted context omitted.
That's kind of scary — in that case I guess I should avoid creating a file named -rf.
That is really interesting. Can someone knowledgeable about the shell expand on this? I don't dare test it on my machine.
Re: Bug 1202858 – Restarting squid results in deleting all files in hard-drive
#80Scary. Even more scary is the fact that the bug has been open for a week, one person has confirmed 100% reproducibility, and no one seems to care at Red Hat. Isn't deleting peoples hard drives a big no no ?