-
Notifications
You must be signed in to change notification settings - Fork 141
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
validate/env: add env name begins with digit check #80
validate/env: add env name begins with digit check #80
Conversation
LGTM! |
On Thu, May 26, 2016 at 03:56:10AM -0700, 梁辰晔 (Liang Chenye) wrote:
In the in-flight opencontainers/runtime-spec#427, I'm suggesting we Other applications may have difficulty dealing with environment So it's legal but not recommended. I think we want to land |
@wking I think you just past half sentence in POSIX 1, the charset and leading-digit restrictions are for “Environment variable names used by the utilities in the Shell and Utilities volume of IEEE Std 1003.1-2001 consist solely of uppercase letters, digits, and the '_' (underscore) from the characters defined in Portable Character Set and do not begin with a digit.” |
@wking sorry, I did not elaborate clearly. I mean runtime spec misses |
On Thu, May 26, 2016 at 06:21:53PM -0700, Ma Shimiao wrote:
No, it says “Environment variable names used by the utilities in the The “Other applications may have difficulty…” line I quoted earlier |
@wking yes, runc is not in a utility list. But most configed processes in runc may call or just be utilities in the list. And "Other applications may have difficulty dealing with environment variable names that start with a digit. For this reason, use of such names is not recommended anywhere." I think |
On Thu, May 26, 2016 at 11:09:33PM -0700, Ma Shimiao wrote:
The POSIX spec is about the environment variables used by those $ env - 123=5 HOME=$HOME env works fine (at least with GNU coreutils 8.23 running on glibc 2.21).
This is the distinction between MUST 1 and SHOULD 2. We can And the wording in opencontainers/runtime-spec#427 is just formal for |
This seems OK. But I'm not sure this is the right way to use environment variables. |
On Fri, May 27, 2016 at 12:07:15AM -0700, Ma Shimiao wrote:
I have one here 1.
That's one way to set an environment variable in a child process, but
I checked BusyBox v1.24.1 and dash 0.5.7 and neither of them liked $ python3 -c "import subprocess as s; s.Popen(['env'], env={'1test': '43'})" I expect the general pattern is “parsing shell commands is complicated |
@wking Yes, some programs accept environment variable name begin with digit. But there still some programs can't handle it as POSIX says. |
On Fri, May 27, 2016 at 12:51:35AM -0700, Ma Shimiao wrote:
I think a linter that warns folks about this sort of thing is fine, |
ping @liangchenye @mrunalp How do you think? |
As @wking pointed out, IEEE std 1003.1-2001 says clearly that begin with a digit is not a MUST restriction: Also I think we need to clarify it in runtime spec.
There is no 'MUST/SHOULD' restriction in the above paragraph. My understanding is: no matter what kind of restriction it has, literally the restriction of |
@liangchenye, how does the language in opencontainers/runtime-spec#427 look to you? |
@wking I like that :) |
As you both think adding warning is better, I agree to updating the PR. |
b9bd253
to
e53991c
Compare
if !unicode.IsDigit(ch) && !unicode.IsLetter(ch) && ch != '_' { | ||
return false | ||
} | ||
if i == 0 && unicode.IsDigit(ch) { | ||
logrus.Warnf("Env %v: variable name begin with digit is not recommended.", env) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/begin/beginning/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mrunalp fixed, thanks.
Signed-off-by: Ma Shimiao <mashimiao.fnst@cn.fujitsu.com>
e53991c
to
5a03d31
Compare
LGTM |
ping @liangchenye |
LGTM |
Signed-off-by: Ma Shimiao mashimiao.fnst@cn.fujitsu.com
env name should not begin with a digit