Skip to content

Commit

Permalink
fix: v0 user passwd, add test for root permission (#1379)
Browse files Browse the repository at this point in the history
Signed-off-by: Keming <kemingy94@gmail.com>

Signed-off-by: Keming <kemingy94@gmail.com>
  • Loading branch information
kemingy committed Jan 5, 2023
1 parent 51b586e commit 3c38b5e
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
4 changes: 4 additions & 0 deletions e2e/v0/language/runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,9 @@ var _ = Describe("runtime", Ordered, func() {
Expect(err).To(BeNil())
Expect(res).To(Equal("[2 3 4]"))
})
It("execute runtime command `root`", func() {
_, err := e.ExecRuntimeCommand("root")
Expect(err).To(BeNil())
})
AfterEach(e.DestroyContainer())
})
7 changes: 6 additions & 1 deletion e2e/v0/language/testdata/runtime/build.envd
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@ def build():
]
)
shell("zsh")
runtime.command(commands={"numpy": "python demo.py"})
runtime.command(
commands={
"numpy": "python demo.py",
"root": "sudo ls /root",
}
)
4 changes: 4 additions & 0 deletions e2e/v1/language/runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,9 @@ var _ = Describe("runtime", Ordered, func() {
Expect(err).To(BeNil())
Expect(res).To(Equal("[2 3 4]"))
})
It("execute runtime command `root`", func() {
_, err := e.ExecRuntimeCommand("root")
Expect(err).To(BeNil())
})
AfterEach(e.DestroyContainer())
})
7 changes: 6 additions & 1 deletion e2e/v1/language/testdata/runtime/build.envd
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@ def build():
]
)
shell("zsh")
runtime.command(commands={"numpy": "python demo.py"})
runtime.command(
commands={
"numpy": "python demo.py",
"root": "sudo ls /root",
}
)
2 changes: 1 addition & 1 deletion pkg/lang/ir/v0/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (g *generalGraph) compileUserGroup(root llb.State) llb.State {
res = root.
Run(llb.Shlexf(`groupadd -g %d envd`, g.gid),
llb.WithCustomName("[internal] create user group envd")).
Run(llb.Shlexf(`useradd -p \\ -u %d -g envd -s /bin/sh -m envd`, g.uid),
Run(llb.Shlexf(`useradd -p "" -u %d -g envd -s /bin/sh -m envd`, g.uid),
llb.WithCustomName("[internal] create user envd")).
Run(llb.Shlex("adduser envd sudo"),
llb.WithCustomName("[internal] add user envd to sudoers")).
Expand Down

0 comments on commit 3c38b5e

Please sign in to comment.