News for hackers. Stuff that matters.
Re:Linux distros without systemd by dullgiulio on Monday May 20, 2019 @01:12PM (#19962581)
Bash is memory safe until you run 'rm -rf $DIR/' when DIR is unset.

Let's just say the language choice went from bad to equally bad.

Re:Linux distros without systemd by effie on Monday May 20, 2019 @01:35PM (#19962828)
If you run or write that command into script without checking what DIR variable contains, the problem is in your lack of experience with shell, not the language choice. Also nowadays, rm itself has --preserve-root as default, so this won't delete your root fs.
Re:Linux distros without systemd by int_19h on Monday May 20, 2019 @06:32PM (#19965966)
By the same logic, if an app written in C has a security issue due to a null pointer or buffer overflow, the problem is clearly the coder's lack of experience with C.
Re:Linux distros without systemd by effie on Friday May 24, 2019 @08:43AM (#20000853)
Actually yes, because it is possible to write correct C, and because they could have chosen other language less conducive to those pitfalls. But your analogy doesn't hold, because in case of shell, the situation is different: the pitfalls are easy to avoid, and for unix admin tasks, there is no compelling alternative to shell.
Re:Linux distros without systemd by eropple on Monday May 20, 2019 @04:43PM (#19964986)
This is true if you are running the GNU userland. It's not necessarily true with other userlands that are often run on top of Linux. In a discussion touching on systemd, it strikes me as a little surprising that somebody would rely on a quirk of another replaceable component. ;)
Re:Linux distros without systemd by dijit on Monday May 20, 2019 @05:38PM (#19965523)
I’m sure the irony is not lost on you regarding the fact that systemd can not possibly run on an alternative platform, thus the situation you just ascribed is not “better” with systemd.
Re:Linux distros without systemd by eropple on Monday May 20, 2019 @05:43PM (#19965568)
Sure. That wasn't in favor of systemd, though? I comfortably write code against the GNU userland and I use systemd where it crops up. Just not a big deal to me; if somebody wanted to use my stuff elsewhere I'd just say "pull requests welcome!". I found the inconsistency striking, that's all.
Re:Linux distros without systemd by effie on Friday May 24, 2019 @08:46AM (#20000880)
Checking for content of a variable before passing it to rm is a basic instinct that should be done in all shell scripts. The comment about --preserve-root is just a reminder that the problem of deleting / is very rare.
Re:Linux distros without systemd by ink_13 on Monday May 20, 2019 @01:43PM (#19962935)
That's not a memory-safe error.
Re:Linux distros without systemd by blibble on Monday May 20, 2019 @01:44PM (#19962949)
do beginner bash guides not tell you to "set -u"? all the system scripts on my system have it

it causes the script to terminate with an error if it encounters use of an unset variable

Re:Linux distros without systemd by tetha on Monday May 20, 2019 @01:58PM (#19963123)
Not just -u - always <set -euo pipefail> unless you have a good reason. Fail on non-zero exit code outside of some special cases, undefined variables, and non-zero exit codes in a pipeline. And always use shellcheck, shellcheck is too good not to use tbh.
Re:Linux distros without systemd by trickstra on Monday May 20, 2019 @10:53PM (#19967252)
Are you saying something in C++ is preventing you from issuing that 'rm -rf' command?
Re:Linux distros without systemd by kbumsik on Tuesday May 21, 2019 @05:59AM (#19968799)
He is saying that Bash can also cause catastrophic behaviors by an as simple mistake as unsetting $DIR. C++ at least reject to compile when a variable is not set.
Re:Linux distros without systemd by trickstra on Tuesday May 21, 2019 @06:09AM (#19968829)
Any language can cause a catastrophic scenario like that. It's not a feature of the language. Not even the goal of the language to protect from something like rm -rf. The variable could have been set to empty string and C++ would just comply with what the programmer wrote (not what they meant, but that's a completely different thing).