-
Notifications
You must be signed in to change notification settings - Fork 550
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
use /etc/passwd in place of the User struct #191
Conversation
The type of `user` becomes `string` instead of platform-specific structure, so the Spec becomes a platform-agnostic structure. It makes we can parse the config.json as a Spec before knowing the os. It removes the User structure confliction for different platforms. For linux-based container, parsing the /etc/passwd gives us a consistent and more reliable way to assign the uid/gids to the process. Signed-off-by: Lai Jiangshan <[email protected]>
yes, please :-) see also #38 |
Seems reasonable to me. |
We can discuss this in today's call. |
* **uid** (int, required) specifies the user id. | ||
* **gid** (int, required) specifies the group id. | ||
* **additionalGids** (array of ints, optional) specifies additional group ids to be added to the process. | ||
* **user** (string, required) is the user name for the process. The runtime should resolve the required information for the process by its platform-specific ways. For Linux-based containers, the runtime could parse the /etc/passwd and /etc/group inside the rootfs. |
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.
“could parse /etc/passwd and /etc/group” is too wishy. A bundle author will need to know exactly how this lookup will be performed, so they can setup their bundle to support it. How about using the appc wording referenced from #38?
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.
getent is really the only correct way to handle this. Perhaps we just say if you want a UID map you can put that into your config.json similar to the mount points? https://github.com/opencontainers/specs/blob/master/config.md#mount-points
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.
On Tue, Dec 22, 2015 at 11:07:42PM -0800, Brandon Philips wrote:
+* user (string, required) is the user name for the
process. The runtime should resolve the required information for
the process by its platform-specific ways. For Linux-based
containers, the runtime could parse the /etc/passwd and /etc/group
inside the rootfs.getent is really the only correct way to handle this.
I don't buy that ;). For example, I don't see much difference
between:
Perhaps we just say if you want a UID map you can put that into your
config.json similar to the mount points?
https://github.com/opencontainers/specs/blob/master/config.md#mount-points
and defining the mappings in /etc/passwd and /etc/group. I think you
cover a useful subset of NSS implementations by supporting /etc/passwd
and /etc/group, and you allow runtimes to avoid running container-side
code to perform the lookup (for example, they can use a host-side NSS
implementation to parse the bundle's /etc/passwd and /etc/group).
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.
I don't think we should let random files inside of the container affect behavior of the runtime. And this is what /etc/passwd parsing does. It lets the contents inside of the container control the UID the runtime executes processes as.
We could trivially create a tool that extracts the /etc/passwd into a map and puts it into the JSON schema. Thoughts @jonboulle @vbatts ?
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.
On Wed, Dec 23, 2015 at 11:19:16AM -0800, Brandon Philips wrote:
+* user (string, required) is the user name for the
process. The runtime should resolve the required information for
the process by its platform-specific ways. For Linux-based
containers, the runtime could parse the /etc/passwd and
/etc/group inside the rootfs.I don't think we should let random files inside of the container
affect behavior of the runtime. And this is what /etc/passwd parsing
does. It lets the contents inside of the container control the UID
the runtime executes processes as.
I don't see a point in distinguishing between “inside the container”
(just /etc/passwd) and “inside the bundle” (both /etc/passwd and the
OCI configs). What do you gain by making such a distinction?
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 /etc/passwd may be modified at runtime by processes executing inside of that filesystem while the manifest is inaccessible. So, if we have operations like "launch another process" the behavior may change based on the new state of that file.
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.
On Wed, Dec 23, 2015 at 11:42:49AM -0800, Brandon Philips wrote:
+* user (string, required) is the user name for the
process. The runtime should resolve the required information for
the process by its platform-specific ways. For Linux-based
containers, the runtime could parse the /etc/passwd and
/etc/group inside the rootfs.The /etc/passwd may be modified at runtime by processes executing
inside of that filesystem while the manifest is inaccessible. So, if
we have operations like "launch another process" the behavior may
change based on the new state of that file.
Yeah, this lookup should happen in the container process after joining
the namespace but before exec'ing the user-configured code. So if
/etc/passwd changes and you launch a new process, you get the new UID.
I don't have a problem with that (it seems like what the user intended
when they modified /etc/passwd).
On Wed, Sep 16, 2015 at 02:29:49AM -0700, Lai Jiangshan wrote:
appc uses strings but keeps separate fields for user, group, and |
I just noticed it just reverts the 8af3eb6. @crosbymichael From the #10, I learned something bad about the pure string name. |
@wking suggested to use the structured-and-rich-information-encoded name as AppC used. Could any maintainer directly give an approach? I consider that mapping the User struct from the username is a good idea. Both the username and the map are only valid in the config file, so there is no security problem. And we can benefit from the User struct as current code. |
On Thu, Sep 17, 2015 at 01:01:25AM -0700, Lai Jiangshan wrote:
I think there are two things going on here:
I think most folks are on board with (1). In yesterday's meeting
We can add similar fields for userPath and groupPath if we want later
Waiting for approval from a maintainer is a good idea. Sometimes what
The security problem is if you call getent in the container before |
@philips can you check this out and see if it's inline with what you were thinking on your original issue? |
@philips @crosbymichael @vbatts looks like this issue stalled a few months ago, we're still maintaining a fork so we can run our tests on mac and would love to be able to stop doing that. There's also #166 which seems like a more generic approach to making the spec importable on multiple platforms, but it also hasn't been updated since September. In the meantime just making User a string as in this PR (and documenting the semantics) looks like it solves the problem. Any new thoughts about this? |
I don't think #166 is feasible in short time. https://github.com/hyperhq/runv/blob/master/Makefile.am#L19-L23 besides this issue, any better trick for the hyper/runv are also welcome. |
@laijs Haven't read the whole story, but I see the problem is you can still see Ignore it if I'm missing something big and totally wrong :) |
On Fri, Dec 04, 2015 at 01:35:34AM -0800, Qiang Huang wrote:
Hmm, this^ sounds more complicated to me. In the absence of native |
@hqhq the go build ignores the xxxx_linux.go in the mac. (the build tag in _linux.go is redundant if you add the tag) the runv supports linux containers on the mac, so it requires the linux specified User structure. so we have to change the file name to xxx-linux.go as a workaround, or put them in the linux/ directory without _linux suffix as a full solution: (string as user name + linux/) or ( #135, json.RawMessage as username + linux/) |
I think we should probably just retire ourselves to the fact that the concept of user is so platform specific that trying to put it into the shared part of the spec is impossible. More and more I don't think there is anything that can safely be shared between platforms besides environment variables. |
On Tue, Dec 22, 2015 at 11:09:06PM -0800, Brandon Philips wrote:
I don't see a platform-compatibility problem with the schema outlined
That is a pretty pessimistic view, and argues in favor of just |
On Wed, Dec 23, 2015 at 9:57 AM W. Trevor King [email protected]
With such a complex set of rules on each platform we might as well just And FWIW, I am not saying we should give up on shared language and shared |
On Wed, Dec 23, 2015 at 11:17:10AM -0800, Brandon Philips wrote:
Because it lets you agree where you can. For example, all of our
Currently the spec doesn't have much normative content outside the |
On Wed, Dec 23, 2015 at 11:44 AM W. Trevor King [email protected]
Sure, lets all use the same fields for the Cmd stuff and share that. But, for User it feels we should just make it explicit and pull it into the |
On Wed, Dec 23, 2015 at 11:49:35AM -0800, Brandon Philips wrote:
I have no problem with that. And once we actually have something I don't see the need to namespace this (like we do now with |
On Wed, Dec 23, 2015 at 11:57 AM W. Trevor King [email protected]
Ack. I don't see the need to namespace this (like we do now with
I don't think we are committed but there just isn't great tooling for an |
We are currently working on fixing this for cross platform concerns but as far as linux goes the passwd lookup should be done before config generation. There are many different problems defering this lookup to the runtime and it also removes the ability of using things like nss to looking the uid/gid for the system. We reviewed this together in the f2f oci meeting and are going to keep uid/gid as required for linux and consumers should do lookups with either nss or etc/passwd before populating the config for the container. |
Use libcontainer/user to parse the /etc/{passwd,group} files inside the container rootfs to allow us to handle string versions of user:group specifications. This also allows us to fill the AdditionalGids fields. Signed-off-by: Aleksa Sarai <[email protected]>
The type of
user
becomesstring
instead of platform-specificstructure, so the Spec becomes a platform-agnostic structure.
It makes we can parse the config.json as a Spec before knowing the
os. It removes the User structure confliction for different platforms.
For linux-based container, parsing the /etc/passwd gives us a consistent
and more reliable way to assign the uid/gids to the process.
Signed-off-by: Lai Jiangshan [email protected]