-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
reduce the chance of parsing /etc/passwd & /etc/group #4042
Conversation
42d0004
to
3cd5c86
Compare
Signed-off-by: lifubang <[email protected]>
3cd5c86
to
6d0d22c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The number to string to number conversion is ugly.
I think we should do a change like this:
@@ -68,8 +68,9 @@ type initConfig struct {
ProcessLabel string `json:"process_label"`
AppArmorProfile string `json:"apparmor_profile"`
NoNewPrivileges bool `json:"no_new_privileges"`
- User string `json:"user"`
- AdditionalGroups []string `json:"additional_groups"`
+ UID int `json:"uid"`
+ GID int `json:"gid"`
+ AdditionalGroups []int `json:"additional_groups"`
Config *configs.Config `json:"config"`
Networks []*network `json:"network"`
PassedFilesCount int `json:"passed_files_count"`
and the rest will be greatly simplified.
and the same for // Env specifies the environment variables for the process.
Env []string
- // User will set the uid and gid of the executing process running inside the container
+ // UID and GID of the executing process running inside the container
// local to the container's user and group configuration.
- User string
+ UID, GID int
// AdditionalGroups specifies the gids that should be added to supplementary groups
// in addition to those that the user belongs to.
- AdditionalGroups []string
+ AdditionalGroups []int
// Cwd will change the processes current working directory inside the container's rootfs.
Cwd string |
In fact, I forgot I had the code doing all that already. Rebased it, PTAL: #3999 |
OK, thanks, leave one to save our reviewing time. |
According to #3998 (comment), we can do the third step to reduce the chance of parsing /etc/passwd & /etc/group when start or exec to a container.
Because in
runtime-spec
(https://github.com/opencontainers/runtime-spec/blob/v1.0.2/config.md#posix-platform-user),uid
,gid
, andadditionalGids
are all defined as a numeric field/array. It is no need to parse a numeric id from/etc/passwd
or/etc/group
, except$HOME
is empty or gid is not provided(Butruntime-spec
said gid is required).