Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config: add "umask" field to POSIX "user" section #941

Merged
merged 1 commit into from
Dec 17, 2019

Conversation

cyphar
Copy link
Member

@cyphar cyphar commented Dec 6, 2017

Users may want to specify the umask(2) of the init process in a
container. This value is identical in semantics to POSIX. This is in
order to allow usage of an OCI container for a service which normally
only inherits the umask given to it.

See-also: opencontainers/runc#1650
Requested-by: @leberknecht
Signed-off-by: Aleksa Sarai [email protected]

Users may want to specify the umask(2) of the init process in a
container. This value is identical in semantics to POSIX. This is in
order to allow usage of an OCI container for a service which normally
only inherits the umask given to it.

Signed-off-by: Aleksa Sarai <[email protected]>
@crosbymichael
Copy link
Member

When do you plan to set this during init? Right before exec or when the rootfs is being setup like the existing umask settings?

@@ -217,6 +217,7 @@ For POSIX platforms the `user` structure has the following fields:

* **`uid`** (int, REQUIRED) specifies the user ID in the [container namespace](glossary.md#container-namespace).
* **`gid`** (int, REQUIRED) specifies the group ID in the [container namespace](glossary.md#container-namespace).
* **`umask`** (int, OPTIONAL) specifies the [umask][umask_2] of the user. If unspecified, the umask should not be changed from the calling process' umask.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: the possessive of “process” is “process's”, see us here and the Linux man pages here.

nit: the “If unspecified…” sentence should go on its own line.

@@ -60,6 +60,9 @@
"GID": {
"$ref": "#/definitions/uint32"
},
"Umask": {
Copy link
Contributor

Choose a reason for hiding this comment

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

The indent here is a bit strange. You can automatically format these files by running make fmt in the schema directory.

@wking
Copy link
Contributor

wking commented Dec 6, 2017

When do you plan to set this during init? Right before exec or when the rootfs is being setup…

The way the spec reads now (#700), runtimes will be able to chose either of those as they see fit.

@@ -843,6 +846,7 @@ Here is a full example `config.json` for reference.
[selinux]:http://selinuxproject.org/page/Main_Page
[no-new-privs]: https://www.kernel.org/doc/Documentation/prctl/no_new_privs.txt
[proc_2]: https://www.kernel.org/doc/Documentation/filesystems/proc.txt
[umask.2]: http://pubs.opengroup.org/onlinepubs/009695399/functions/umask.html
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: POSIX functions should go be in section 3 (or 3p), so umask.2 should be umask.3. umask.2 would be the Linux kernel docs for umask.

nit: you're linking to the 2004 edition of POSIX. I'd rather stay consistent with our other links and use the 2016 edition (#858).

@@ -85,6 +85,8 @@ type User struct {
UID uint32 `json:"uid" platform:"linux,solaris"`
// GID is the group id.
GID uint32 `json:"gid" platform:"linux,solaris"`
// Umask is the umask for the init process.
Umask uint32 `json:"umask,omitempty" platform:"linux,solaris"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Zero is a valid umask (it means “leave the permissions entirely up to the process itself”), so I think we need a pointer here.

@cyphar
Copy link
Member Author

cyphar commented Dec 6, 2017

@crosbymichael In runc I would want to do this right before exec because it refers to the container process, no? But maybe there's an argument for it to be done earlier -- I'm not sure?

@vbatts
Copy link
Member

vbatts commented Apr 4, 2018

@cyphar @crosbymichael I interpret this as being set right before exec. Perhaps that could be clearer.

@wking
Copy link
Contributor

wking commented Apr 4, 2018 via email

@stain
Copy link

stain commented Oct 17, 2018

As this is still pending approval since April - what needs to be done to progress this PR?

@leberknecht
Copy link

Anything we can do here?

@@ -233,6 +234,7 @@ _Note: symbolic name for uid and gid, such as uname and gname respectively, are
"user": {
"uid": 1,
"gid": 1,
"umask": 63,
Copy link
Member

Choose a reason for hiding this comment

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

i get that they're just ints, but i wish octals were a viewable in json, and 077 wouldn't be 77

@vbatts
Copy link
Member

vbatts commented Nov 19, 2018

When do you plan to set this during init? Right before exec or when the rootfs is being setup like the existing umask settings?

I would see this as right before exec. What would you're hopes be?

@cyphar
Copy link
Member Author

cyphar commented Nov 19, 2018

I think right before exec would be most reasonable, since it's a setting about the container and not about configuring devices and others such things. Generally most config.json options aren't meant to impact internal runtime setup (except in cases where it can't be avoided like cgroups).

@rhatdan
Copy link
Contributor

rhatdan commented Aug 6, 2019

This has come up again in a request for Podman. Is there anything we could do to move this forward?

@giuseppe
Copy link
Member

giuseppe commented Aug 6, 2019

@crosbymichael In runc I would want to do this right before exec because it refers to the container process, no? But maybe there's an argument for it to be done earlier -- I'm not sure?

doing it just before exec seems like the correct thing to me. Currently runc does it in finalizeRootfs (https://github.com/opencontainers/runc/blob/master/libcontainer/rootfs_linux.go#L151). The umask inside the container is always set to 022

@crosbymichael
Copy link
Member

crosbymichael commented Aug 6, 2019

LGTM

Approved with PullApprove

@leberknecht
Copy link

@caniszczyk @dqminh @hqhq @mrunalp @philips @tianon @vbatts @vishh
sorry for spamming, but can someone please do the required second review here? :)

@caniszczyk
Copy link
Contributor

RFC @opencontainers/runtime-spec-maintainers

@tianon
Copy link
Member

tianon commented Oct 7, 2019

I think @wking's comments look to be relevant and should be addressed (especially the inconsistent formatting). It also seems like a good idea IMO to clarify when this is expected to be applied, per @crosbymichael's comments.

@vbatts
Copy link
Member

vbatts commented Dec 17, 2019

LGTM
And as this is OPTIONAL it is a non-breaking, forward compatible feature.

Approved with PullApprove

@vbatts vbatts merged commit cd13d2d into opencontainers:master Dec 17, 2019
@vbatts vbatts mentioned this pull request Jan 9, 2020
@cyphar cyphar deleted the config-umask-option branch February 24, 2020 00:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants