Skip to content
This repository has been archived by the owner on Feb 24, 2020. It is now read-only.

stage1/enterexec: remove trailing \n in environment variables. #2901

Merged
merged 2 commits into from
Jul 11, 2016

Conversation

alepuccetti
Copy link
Contributor

Loading environment retained the new line character (\n),
this produced an incorrect evaluation of the environment variables.

Fixes: #2893
Related to: #2839

@s-urbaniak
Copy link
Contributor

@alepuccetti do you mind filing an issue for a functional test follow-up, and assign it to you?

@s-urbaniak
Copy link
Contributor

@alepuccetti also, do you mind writing a more elaborate commit message adhering to https://github.com/coreos/rkt/blob/master/CONTRIBUTING.md#format-of-the-commit-message?

@@ -445,7 +445,9 @@ func (e *envFileMap) Set(s string) error {

scanner := bufio.NewScanner(file)
for scanner.Scan() {
// TODO parse '\' to skip new line character
if len(scanner.Text()) == 0 {
continue
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sounds ok.

But I just noticed that the skipLine() test with len(s) == 0 below for "Empty line" is wrong because strings.SplitN(..., "=", 2) should never return an empty array of string.

Copy link
Contributor Author

@alepuccetti alepuccetti Jul 11, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alban len(s) == 0 is wrong but I think it should be len(s) < 2 because if a line do not have an = SplitN() returns one element. Do we want to allow that? I prefer that if the user wants an empty variable have to write variable=

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, I don't want to implicitly set empty variables if the user does not write the =.

But IMO this is a detail, and it's not related to the issue being fixed.

@alepuccetti alepuccetti changed the title stage1/enterexec: Bug fix. stage1/enterexec: remove trailing \n in environment variables. Jul 11, 2016
@alban
Copy link
Member

alban commented Jul 11, 2016

LGTM

Alessandro Puccetti added 2 commits July 11, 2016 20:14
Loading environment retained the new line character (`\n`),
this produced an incorrect evaluation of the environment variables.

Fixes: rkt#2893
Bug introduced by: rkt#2839
This patch returns an error if the environment file contains a malformed
variable. For example, if a variable is unnamed (e.g. `=value`) or without
the equals sign (e.g. `VAR_1`). Empty variables may be set by `VAR_1=`.
Users may prefix with `#` or `;` those varibles to ignore. This patch
skips empty lines in the environment file.
@alepuccetti
Copy link
Contributor Author

Patch updated, first commit addresses the main bug. Second commit addresses a bug I found while testing.

@alepuccetti
Copy link
Contributor Author

Semaphoreci fails in setup phase ./tests/install-deps.sh # Setup

WARNING: The following packages cannot be authenticated!
  libmount-dev libmount1

@s-urbaniak
Copy link
Contributor

@alepuccetti triggered rebuild on semaphore

@s-urbaniak s-urbaniak merged commit 7753a3f into rkt:master Jul 11, 2016
alepuccetti pushed a commit to kinvolk/rkt that referenced this pull request Jul 18, 2016
This path implements the test for rkt#2901,
it tests that `$PATH` does not end with `\n\0` but with `\0`.

This fixes rkt#2905
Related to rkt#2893
alepuccetti pushed a commit to kinvolk/rkt that referenced this pull request Jul 18, 2016
This path implements the test for rkt#2901,
it tests that `$PATH` does not end with `\n\0` but with `\0`.

This fixes rkt#2905
Related to rkt#2893

This path also introduces the `--check-path` flag in `inspect.go` to carry out the test.
alepuccetti pushed a commit to kinvolk/rkt that referenced this pull request Jul 18, 2016
This path implements the test for rkt#2901,
it tests that `$PATH` does not end with `\n\0` but with `\0`.

This fixes rkt#2905
Related to rkt#2893

This path also introduces the `--check-path` flag in `inspect.go` to carry out the test.
alepuccetti pushed a commit to kinvolk/rkt that referenced this pull request Jul 18, 2016
This patch implements the test for rkt#2901,
it tests that `$PATH` does not end with `\n\0` but with `\0`.

This fixes rkt#2905
Related to rkt#2893

This patch also introduces the `--check-path` flag in `inspect.go` to carry out the test.
alepuccetti pushed a commit to kinvolk/rkt that referenced this pull request Jul 18, 2016
This patch implements the test for rkt#2901,
it tests that `$PATH` does not contain `\n`.

This fixes rkt#2905
Related to rkt#2893

This patch also introduces the `--check-path` flag in `inspect.go` to carry out the test.
jjlakis pushed a commit to jjlakis/rkt that referenced this pull request Jul 19, 2016
This patch implements the test for rkt#2901,
it tests that `$PATH` does not contain `\n`.

This fixes rkt#2905
Related to rkt#2893

This patch also introduces the `--check-path` flag in `inspect.go` to carry out the test.
akshaykarle pushed a commit to akshaykarle/rkt that referenced this pull request Jul 26, 2016
This patch implements the test for rkt#2901,
it tests that `$PATH` does not contain `\n`.

This fixes rkt#2905
Related to rkt#2893

This patch also introduces the `--check-path` flag in `inspect.go` to carry out the test.
akshaykarle pushed a commit to akshaykarle/rkt that referenced this pull request Jul 26, 2016
This patch implements the test for rkt#2901,
it tests that `$PATH` does not contain `\n`.

This fixes rkt#2905
Related to rkt#2893

This patch also introduces the `--check-path` flag in `inspect.go` to carry out the test.
antoni pushed a commit to intelsdi-x/rkt that referenced this pull request Sep 9, 2016
This patch implements the test for rkt#2901,
it tests that `$PATH` does not contain `\n`.

This fixes rkt#2905
Related to rkt#2893

This patch also introduces the `--check-path` flag in `inspect.go` to carry out the test.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants