Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #15845 > unrolled thread

Re: Preventing Bash Variable Confusion

Started byGreg Wooledge <wooledg@eeg.ccf.org>
First post2020-01-29 13:57 -0500
Last post2020-01-29 13:57 -0500
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Preventing Bash Variable Confusion Greg Wooledge <wooledg@eeg.ccf.org> - 2020-01-29 13:57 -0500

#15845 — Re: Preventing Bash Variable Confusion

FromGreg Wooledge <wooledg@eeg.ccf.org>
Date2020-01-29 13:57 -0500
SubjectRe: Preventing Bash Variable Confusion
Message-ID<mailman.59.1580324272.2384.bug-bash@gnu.org>
On Thu, Jan 30, 2020 at 01:03:31AM +0700, Robert Elz wrote:
> It actually doesn't, or not generally - it allows the function to avoid
> namespace collisions with random globals (or other locals) that might exist
> up the call stack, but doesn't prevent functions that are called from
> trampling all over this function's local vars.

OK, true.  But then the real issue is that you're calling broken functions.
Stop calling broken functions.

Yeah, yeah, I know, trying to get people to STOP WRITING broken functions
is impossible... but still, you shouldn't be running around with the
idea in your head that bash scripts should use LIBRARIES OF FUNCTIONS.
The language is just not robust enough for that to work in real life.

A script is supposed to be a self-contained entity, as much as possible.
It isn't supposed to be part of some web of tangled dependencies.

> It could be fixed by
> 
> 	sigint_handler() {
> 		command local My_Var=$$
> 		command trap - INT
> 		command kill -s INT "${My_Var}"
> 	}

You mean "builtin" instead of "command" in every one of those cases,
right?  Well, if you're using maliciously broken "library functions"
in a bash script, the problem is, the malicious library can also
override the "command" command and the "builtin" command.

And yes, it can also override the "/bin/kill" command and so on.

Untrusted libraries are HIDEOUSLY EVIL in bash.  There is no workaround,
other than those I've already stated.

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web