-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6829 from rhatdan/keepid
Add username to /etc/passwd inside of container if --userns keep-id
- Loading branch information
Showing
7 changed files
with
128 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// +build linux | ||
|
||
package libpod | ||
|
||
import ( | ||
"io/ioutil" | ||
"os" | ||
"testing" | ||
|
||
spec "github.com/opencontainers/runtime-spec/specs-go" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestGenerateUserPasswdEntry(t *testing.T) { | ||
dir, err := ioutil.TempDir("", "libpod_test_") | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
defer os.RemoveAll(dir) | ||
|
||
c := Container{ | ||
config: &ContainerConfig{ | ||
User: "123:456", | ||
Spec: &spec.Spec{}, | ||
}, | ||
state: &ContainerState{ | ||
Mountpoint: "/does/not/exist/tmp/", | ||
}, | ||
} | ||
user, err := c.generateUserPasswdEntry() | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
assert.Equal(t, user, "123:x:123:456:container user:/:/bin/sh\n") | ||
|
||
c.config.User = "567" | ||
user, err = c.generateUserPasswdEntry() | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
assert.Equal(t, user, "567:x:567:0:container user:/:/bin/sh\n") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters