-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove the magic A__z
environment var
#637
Comments
I had not heard about this but it seems necessary as otherwise, if I create a readonly variable, how
Interestingly, the above produces just:
No sign of the A__z variable??? Plus, setting it doesn't affect my
|
@dannyweldon That's because it only affects attributes of exported vars. You didn't export
I'll have to check if this mechanism affects |
I confirmed that disabling the magic
|
I knew about this undocumented misfeature because it bit me while developing modernish. Somehow relaunching the installer to use the user's chosen shell failed if ksh was involved. Took months to figure out what was going on. As @krader1961 says, this has nothing to do with subshells at all, it's trying to make sure that newly initialised ksh processes (which aren't subshells) inherit exported readonly variables as readonly. Which really seems like a Bad Idea™. There is no way to secure that A__z variable while in the environment since the environment has no concept of readonly. So there is nothing to stop any other process from manipulating that A__z environment variable and influencing/breaking the execution of any ksh scripts started as child processes. This is a potential attack vector. The only variables that should ever be readonly should be those declared readonly by the current script itself. Yes, please remove this misfeature. |
While trying to resolve #1038 I noticed this block of code: Line 1977 in 80e8b60
The problem is that it presumes that |
DEFPATH is exported for efficiency during installation, so for ksh93 compatibility it cannot be made read-only. Ref.: att/ast#637 (it bit me again!) bin/modernish: - Make DEFPATH read-only in the readonly command that's uncommented by the installer. Fixes ksh93 incompat introduced by b41a960.
DEFPATH is exported for efficiency during installation, so for ksh93 compatibility it cannot be made read-only. Ref.: att/ast#637 (it bit me again!) bin/modernish: - Make DEFPATH read-only in the readonly command that's uncommented by the installer. Fixes ksh93 incompat introduced by b41a960.
While fixing lint in the
env_init()
function I noticed the magicA__z
env var. This is a poorly documented mechanism for passing the properties of exported vars to subshells. I can't find any documentation of this in source code comments, the man page, or The Kornshell book. A google search turns up very few mentions of this mechanism. Two that I found:http://webcache.googleusercontent.com/search?q=cache:PK89YUimZ0gJ:paul.herger.at/knowhow/kornshell/a_z+&cd=1&hl=en&ct=clnk&gl=us
https://unix.stackexchange.com/questions/66627/is-there-anyway-to-set-a-readonly-environment-variable
I propose documenting this as deprecated and removing this mechanism in the next major release. Not least because it only works when a ksh process directly runs another ksh process. If you have an intermediate process that modifies the environment, and which doesn't know about this magic env var, and spawns a ksh subshell then it's possible for bad things to happen. If this isn't removed it needs to be clearly documented.
Be honest, how many of you knew about this mechanism?
The text was updated successfully, but these errors were encountered: