Skip to content

Commit

Permalink
Add missing interface to set init processes Umask
Browse files Browse the repository at this point in the history
Umask is a field specified in the runtime spec, but we don't
have a method to set it in runtime-tools.  Some users might
want to modify the default Umask of a container.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
  • Loading branch information
rhatdan committed Jul 13, 2020
1 parent d1bf3e6 commit eadda1f
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions cmd/oci-runtime-tool/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ var generateFlags = []cli.Flag{
cli.BoolFlag{Name: "process-rlimits-remove-all", Usage: "remove all resource limits for processes inside the container. "},
cli.BoolFlag{Name: "process-terminal", Usage: "specifies whether a terminal is attached to the process"},
cli.IntFlag{Name: "process-uid", Usage: "uid for the process"},
cli.StringFlag{Name: "process-umask", Usage: "umask for the process"},
cli.StringFlag{Name: "process-username", Usage: "username for the process"},
cli.StringFlag{Name: "rootfs-path", Value: "rootfs", Usage: "path to the root filesystem"},
cli.BoolFlag{Name: "rootfs-readonly", Usage: "make the container's rootfs readonly"},
Expand Down Expand Up @@ -234,6 +235,10 @@ func setupSpec(g *generate.Generator, context *cli.Context) error {
g.SetProcessUsername(context.String("process-username"))
}

if context.IsSet("process-umask") {
g.SetProcessUsername(context.String("process-umask"))
}

if context.IsSet("process-gid") {
g.SetProcessGID(uint32(context.Int("process-gid")))
}
Expand Down
6 changes: 6 additions & 0 deletions generate/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,12 @@ func (g *Generator) SetProcessUsername(username string) {
g.Config.Process.User.Username = username
}

// SetProcessUmask sets g.Config.Process.User.Umask.
func (g *Generator) SetProcessUmask(umask uint32) {
g.initConfigProcess()
g.Config.Process.User.Umask = umask
}

// SetProcessGID sets g.Config.Process.User.GID.
func (g *Generator) SetProcessGID(gid uint32) {
g.initConfigProcess()
Expand Down
1 change: 1 addition & 0 deletions validation/process_user/process_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ func main() {
g.SetProcessUID(10)
g.SetProcessGID(10)
g.AddProcessAdditionalGid(5)
g.SetProcessUmask(002)
case "windows":
g.SetProcessUsername("test")
default:
Expand Down
2 changes: 1 addition & 1 deletion vendor/github.com/mndrix/tap-go/tap.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

83 changes: 67 additions & 16 deletions vendor/github.com/opencontainers/runtime-spec/specs-go/config.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions vendor/github.com/opencontainers/runtime-spec/specs-go/state.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/golang.org/x/sys/unix/syscall.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit eadda1f

Please sign in to comment.