Live data from Hacker News

Bug 1202858 – Restarting squid results in deleting all files in hard-drive

bugzilla.redhat.com

161–170 of 179 posts

Re: Bug 1202858 – Restarting squid results in deleting all files in hard-drive

#161
post #46

Earlier 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.

If anyone understands shell scripts, it would be people writing init scripts at Red Hat :) Anyways, that is not anything like other programming languages. Checking in that way is error prone and not really an improvement (nor equivalent to set -o). [[ "$DAEMON_PATH" ]] && rm -rf "$DEAMON_PATH/*" See what I did there? It's an rm -rf /* bug because "checking variables" is not the answer. In other programming languages,…

Bash has the ability to also flag use of an undefined variable an error, it is just not on by default.

set -u

Man page quote: "Treat unset variables and parameters other than the special parameters "@" and "*" as an error when performing parameter expansion. If expansion is attempted on an unset variable or parameter, the shell prints an error message, and, if not interactive, exits with a non-zero status."

Re: Bug 1202858 – Restarting squid results in deleting all files in hard-drive

#162
post #30
post #19

Earlier quoted context omitted.

When you're a QA engineer at RHEL working on an UNRELEASED PRODUCT then no, I don't think you need an apology. Maybe a thanks for finding the bug, but this is the whole point of QA and the whole point of QA-ing before it's released. The context matters a lot. This title is linkbait. It omits mentioning that this was not publicly released and the reporter is a QA for Red Hat. Given that context I doubt you'll still ag…

This being said, the bugtracker isn't very clear when it comes to ticket status. Currently the status is 'on_qa'. I guess if you use it a lot you're aware of it, but it strikes me as iffy UI.

[deleted]

Re: Bug 1202858 – Restarting squid results in deleting all files in hard-drive

#163
post #81

Earlier quoted context omitted.

Elephant in the room- shell is a bizarre language

Yeah, everyone always loves to shit on BAT (which is fair, it is terrible) and VBS (which is slightly less fair) but inspite of how many problems Bash has (least of all the massive security issue last year), it gets off almost scot free. These bugs are indicative of Bash's design problems. Why is it used for init scripts? And don't even get me started on how Bash interprets filenames as part of the arguments list whe…

>And don't even get me started on how Bash interprets filenames as part of the arguments list when using * (e.g. file named "-rf")

That's not Bash. That's just... programs in Unix. Such is life when everything is stringly typed.

Re: Bug 1202858 – Restarting squid results in deleting all files in hard-drive

#164
post #62

Earlier quoted context omitted.

The * is expanded by the shell to a space-delimited list of filenames, but the shell does not adequately escape filenames that can be misinterpreted as arguments to 'rm'.

That's kind of scary — in that case I guess I should avoid creating a file named -rf.

I think it may be more scary for code that allows arbitrary execution using command-line arguments. Commands like find or xargs using without defense against this would be a problem. For example, site that does something precious with your uploaded pet pictures.

Defending against this being the use of -- to signal an end of command line arguments.

Re: Bug 1202858 – Restarting squid results in deleting all files in hard-drive

#165
post #81

Earlier quoted context omitted.

Elephant in the room- shell is a bizarre language

Yeah, everyone always loves to shit on BAT (which is fair, it is terrible) and VBS (which is slightly less fair) but inspite of how many problems Bash has (least of all the massive security issue last year), it gets off almost scot free. These bugs are indicative of Bash's design problems. Why is it used for init scripts? And don't even get me started on how Bash interprets filenames as part of the arguments list whe…

> it gets off almost scot free.

Not just scot free - during the Great systemd War of 2014 is was a talking point for the antis that using anything other than the pure, reliable simplicity of shell for service management was MADNESS!

Re: Bug 1202858 – Restarting squid results in deleting all files in hard-drive

#166

Earlier quoted context omitted.

I believe that "--preserve-root" applies only to / itself. That means `rm -rf /*` will expand to `rm -rf /bin /dev /etc /lib ...` and delete all anyway.

This just happened to my coworker today. I'm sitting behind him telling him which commands to type (he's new to Linux...) when suddenly he jumps the gun and pushes enter just as I say "slash". My heart nearly stopped. I didn't even know preserve-root existed (plus I always iterate not to log in as root). It was a snapshotted vm but we still would have lost the day's work.

[deleted]

Re: Bug 1202858 – Restarting squid results in deleting all files in hard-drive

#167

Earlier quoted context omitted.

I believe that "--preserve-root" applies only to / itself. That means `rm -rf /*` will expand to `rm -rf /bin /dev /etc /lib ...` and delete all anyway.

This just happened to my coworker today. I'm sitting behind him telling him which commands to type (he's new to Linux...) when suddenly he jumps the gun and pushes enter just as I say "slash". My heart nearly stopped. I didn't even know preserve-root existed (plus I always iterate not to log in as root). It was a snapshotted vm but we still would have lost the day's work.

Coworker - intern? :P

Re: Bug 1202858 – Restarting squid results in deleting all files in hard-drive

#168
post #113

Earlier quoted context omitted.

'exceptionally clear'? How do you detect that bug status from across the room? If that bug page was up on a big screen, how do you detect it's status? How do you tell at a glance from a meter away what the status is? All of those things should be doable for an 'exceptionally clear' status. Developers don't have mysteriously different visual capabilities from 'joes'. this is a work tool used by developers and QE Becau…

> How do you detect that bug status from across the room? Know and understand the tools you are working with, and simply click the Modified (History) link at the top to determine the bug timeline: https://bugzilla.redhat.com/show_activity.cgi?id=1202858

I don't understand why I'm getting pounded by downvoters. First someone tells me that a small-typeface 'status' is 'exceptionally clear' and UI doesn't really matter for developers. Next I'm told that in order to detect something from across the room, I have to click through a link.

I realise my comment was snarky, but both of these responses were in a patronising tone themselves. Does bugzilla have some sort of rabid fanbase akin to the vim/emacs wars?

Re: Bug 1202858 – Restarting squid results in deleting all files in hard-drive

#169
post #168

Earlier quoted context omitted.

> How do you detect that bug status from across the room? Know and understand the tools you are working with, and simply click the Modified (History) link at the top to determine the bug timeline: https://bugzilla.redhat.com/show_activity.cgi?id=1202858

I don't understand why I'm getting pounded by downvoters. First someone tells me that a small-typeface 'status' is 'exceptionally clear' and UI doesn't really matter for developers. Next I'm told that in order to detect something from across the room, I have to click through a link. I realise my comment was snarky, but both of these responses were in a patronising tone themselves. Does bugzilla have some sort of rabi…

its like, the very first line of the bug's informational body. And it shows up in bugzilla searches too: https://bugzilla.redhat.com/buglist.cgi?quicksearch=deleting...

I don't think anyone else has had a tone other than short-spoken

Re: Bug 1202858 – Restarting squid results in deleting all files in hard-drive

#170
post #140

Earlier quoted context omitted.

I think a better alternative is something like rm -r "${VAR:-var_is_not_set_so_please_fix_this_script}" which substitutes the var_is_... if VAR is not set. BTW, I hate hate hate -f. It has two meanings: 1. 'force' the removal 2. ignore any error I've seen an instance of this sort of bug in my sysadmin career that I remember. It was a Solaris patch which wiped a chunk of the system.

No, this will remove 'var_is_not_set_so_please_fix_this_script' file if one exists. If you're suggesting using parameter expansion, at least suggest the correct one (i.e. one that will give a meaningful error message): ${parameter:?word} http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3...

Yep, better. Thanks.
Post reply on HN