Skip to content

runsc: exec: Use container spec as default when --process is not provided. #11137

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

Merged
merged 1 commit into from
Nov 8, 2024

Conversation

copybara-service[bot]
Copy link

@copybara-service copybara-service bot commented Nov 7, 2024

runsc: exec: Use container spec as default when --process is not provided.

This is consistent with runc. This fixes several bugs with runsc exec:

  • When --process flag is specified, the process spec should be validated. The
    process spec should not inherit values from the OCI spec except capabilities.
    Earlier, we were setting WorkingDirectory and Envv from the spec if these
    were not set in the process file.
  • When --process flag is not specified, we should use the Process defined in
    the container spec as the base and append the following flags onto that
    process spec. Earlier if these flags were specified, we were not using the
    container spec values and just setting to these passed flags, hence making it
    look like runsc is "clearing" these fields when their flags are passed.
    • additional-gids
    • cap
    • env
  • When --process flag is not specified, we should use the following values
    defined in the container spec's Process. Those values should be selectively
    overridden when the corresponding flag is set. Earlier, we were always using
    the flag values, even when the flag was not set. One implication was that we
    were always running with UID=GID=0 when --process and --user are not set.
    • user
    • cwd
  • When --cap is set, it should not append to the Inheritable capabilities
    defined in the spec. And it should only be appended to Ambient if Inheritable
    in the original spec is non-empty.

Fixes #11108

@copybara-service copybara-service bot added the exported Issue was exported automatically label Nov 7, 2024
@copybara-service copybara-service bot force-pushed the test/cl694260484 branch 2 times, most recently from 975845f to 2eb9354 Compare November 8, 2024 21:17
…ided.

This is consistent with runc. This fixes several bugs with runsc exec:
- When --process flag is specified, the process spec should be validated. The
  process spec should not inherit values from the OCI spec except capabilities.
  Earlier, we were setting WorkingDirectory and Envv from the spec if these
  were not set in the process file.
- When --process flag is not specified, we should use the Process defined in
  the container spec as the base and append the following flags onto that
  process spec. Earlier if these flags were specified, we were not using the
  container spec values and just setting to these passed flags, hence making it
  look like runsc is "clearing" these fields when their flags are passed.
    - additional-gids
    - cap
    - env
- When --process flag is not specified, we should use the following values
  defined in the container spec's Process. Those values should be selectively
  overridden when the corresponding flag is set. Earlier, we were always using
  the flag values, even when the flag was not set. One implication was that we
  were always running with UID=GID=0 when --process and --user are not set.
    - user
    - cwd
- When --cap is set, it should not append to the Inheritable capabilities
  defined in the spec. And it should only be appended to Ambient if Inheritable
  in the original spec is non-empty.

Fixes #11108

PiperOrigin-RevId: 694642077
@copybara-service copybara-service bot merged commit 0009d4e into master Nov 8, 2024
@copybara-service copybara-service bot deleted the test/cl694260484 branch November 8, 2024 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exported Issue was exported automatically
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Runsc exec wipes capabilities if they are provided
1 participant