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 14, 2020
1 parent d1bf3e6 commit 43243fe
Show file tree
Hide file tree
Showing 35 changed files with 10,246 additions and 15 deletions.
4 changes: 2 additions & 2 deletions 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.SetProcessUmask(uint32(context.Int("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
4 changes: 2 additions & 2 deletions validate/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestJSONSchema(t *testing.T) {
}{
{
config: &rspec.Spec{},
error: "1 error occurred:\n\t* Version string empty\nRefer to: https://github.com/opencontainers/runtime-spec/blob/v1.0.1/config.md#specification-version\n\n",
error: "1 error occurred:\n\t* Version string empty\nRefer to: https://github.com/opencontainers/runtime-spec/blob/v1.0.2/config.md#specification-version\n\n",
},
{
config: &rspec.Spec{
Expand All @@ -62,7 +62,7 @@ func TestJSONSchema(t *testing.T) {
Version: "1.0.0",
Process: &rspec.Process{},
},
error: "process.args: Invalid type. Expected: array, given: null",
error: "1 error occurred:\n\t* args: args is required\n\n",
},
{
config: &rspec.Spec{
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

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

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.

65 changes: 57 additions & 8 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.

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

1 change: 1 addition & 0 deletions vendor/github.com/sirupsen/logrus/.gitignore

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

12 changes: 12 additions & 0 deletions vendor/github.com/sirupsen/logrus/.travis.yml

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

109 changes: 109 additions & 0 deletions vendor/github.com/sirupsen/logrus/CHANGELOG.md

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.

3 changes: 3 additions & 0 deletions vendor/golang.org/x/sys/AUTHORS

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

3 changes: 3 additions & 0 deletions vendor/golang.org/x/sys/CONTRIBUTORS

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

Loading

0 comments on commit 43243fe

Please sign in to comment.