bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can not declare a local variable if an global ro-variable exists wit


From: Greg Wooledge
Subject: Re: Can not declare a local variable if an global ro-variable exists with the same name
Date: Fri, 29 Mar 2019 08:45:02 -0400
User-agent: NeoMutt/20170113 (1.7.2)

On Wed, Mar 27, 2019 at 02:06:51PM +0100, address@hidden wrote:
>       If I declare a global read-only variable and I try to declare a local 
> variable with that name, I can not create
>       the local variable.
>       I expect that local variables can be declared independently for the 
> global variables.

The purpose of the readonly flag on shell variables is to support the
restricted shell.  I will pause while you laugh and/or cry.

In order for a restricted shell to have half a chance of working (keeping
the user imprisoned), the PATH variable has to be immutable.  If the
user can modify PATH, they can run a real shell and escape.

So, in rbash and friends, PATH gets marked readonly, and bash treats
the readonly flag as sacrosanct.  Allowing a user to work around it
simply by creating a function would let them break out of the restricted
shell too easily.

Readonly is forever.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]