Skip to content

Commit 6b04c63

Browse files
committed
config: add "umask" field to POSIX "user" section
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]>
1 parent 75c847a commit 6b04c63

File tree

4 files changed

+13
-0
lines changed

4 files changed

+13
-0
lines changed

config.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ For POSIX platforms the `user` structure has the following fields:
217217

218218
* **`uid`** (int, REQUIRED) specifies the user ID in the [container namespace](glossary.md#container-namespace).
219219
* **`gid`** (int, REQUIRED) specifies the group ID in the [container namespace](glossary.md#container-namespace).
220+
* **`umask`** (int, OPTIONAL) specifies the [umask][umask_2] of the user. If unspecified, the umask should not be changed from the calling process' umask.
220221
* **`additionalGids`** (array of ints, OPTIONAL) specifies additional group IDs in the [container namespace](glossary.md#container-namespace) to be added to the process.
221222

222223
_Note: symbolic name for uid and gid, such as uname and gname respectively, are left to upper levels to derive (i.e. `/etc/passwd` parsing, NSS, etc)_
@@ -233,6 +234,7 @@ _Note: symbolic name for uid and gid, such as uname and gname respectively, are
233234
"user": {
234235
"uid": 1,
235236
"gid": 1,
237+
"umask": 63,
236238
"additionalGids": [5, 6]
237239
},
238240
"env": [
@@ -291,6 +293,7 @@ _Note: symbolic name for uid and gid, such as uname and gname respectively, are
291293
"user": {
292294
"uid": 1,
293295
"gid": 1,
296+
"umask": 7,
294297
"additionalGids": [2, 8]
295298
},
296299
"env": [
@@ -843,6 +846,7 @@ Here is a full example `config.json` for reference.
843846
[selinux]:http://selinuxproject.org/page/Main_Page
844847
[no-new-privs]: https://www.kernel.org/doc/Documentation/prctl/no_new_privs.txt
845848
[proc_2]: https://www.kernel.org/doc/Documentation/filesystems/proc.txt
849+
[umask.2]: http://pubs.opengroup.org/onlinepubs/009695399/functions/umask.html
846850
[semver-v2.0.0]: http://semver.org/spec/v2.0.0.html
847851
[ieee-1003.1-2008-xbd-c8.1]: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_01
848852
[ieee-1003.1-2008-functions-exec]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/exec.html

schema/config-schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@
109109
"id": "https://opencontainers.org/schema/bundle/process/user/gid",
110110
"$ref": "defs.json#/definitions/GID"
111111
},
112+
"umask": {
113+
"id": "https://opencontainers.org/schema/bundle/process/user/umask",
114+
"$ref": "defs.json#/definitions/Umask"
115+
},
112116
"additionalGids": {
113117
"id": "https://opencontainers.org/schema/bundle/process/user/additionalGids",
114118
"$ref": "defs.json#/definitions/ArrayOfGIDs"

schema/defs.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@
6060
"GID": {
6161
"$ref": "#/definitions/uint32"
6262
},
63+
"Umask": {
64+
"$ref": "#/definitions/uint32"
65+
},
6366
"ArrayOfGIDs": {
6467
"type": "array",
6568
"items": {

specs-go/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ type User struct {
8585
UID uint32 `json:"uid" platform:"linux,solaris"`
8686
// GID is the group id.
8787
GID uint32 `json:"gid" platform:"linux,solaris"`
88+
// Umask is the umask for the init process.
89+
Umask uint32 `json:"umask,omitempty" platform:"linux,solaris"`
8890
// AdditionalGids are additional group ids set for the container's process.
8991
AdditionalGids []uint32 `json:"additionalGids,omitempty" platform:"linux,solaris"`
9092
// Username is the user name.

0 commit comments

Comments
 (0)