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

Rework shared/idmap #369

Merged
merged 50 commits into from
Jan 8, 2024
Merged

Rework shared/idmap #369

merged 50 commits into from
Jan 8, 2024

Conversation

stgraber
Copy link
Member

@stgraber stgraber commented Jan 6, 2024

This re-organizes and modernizes the shared/idmap package to the point of mostly having it fully rewritten. The main changes are:

  • Moved everything to one of three types:
    • Range
    • Entry
    • Set
  • Re-organized filesystem structure to match the various types
  • Made the majority of the code (and test) work on all platforms
  • De-coupled and simplified the set loaders:
    • NewSetFromJSON
    • NewSetFromIncusIDMap
    • NewSetFromCurrentProcess
    • NewSetFromSystem
  • Changes to default Set contents
    • Made all sets return all entries regardless of size by default
    • Introduced FilterPOSIX to filter out any entry smaller than 65536 uid/gid
  • Changes to Shift/Unshift functions
    • Removed all existing Shift/Unshift functions
    • Replaced by a set of two functions
      • ShiftPath
      • UnshiftPath
    • Both functions take a path and skipper function which can be set to nil if not useful
    • The skipper function now receives the newuid and newgid and can return filepath.SkipDir/filepath.SkipAll as an error, or any other error to skip (nil to proceed)
  • Added a Split function to Set which allows finding a subset of a given size
  • Added an Includes function to Set which makes it easy to see if a set is a superset of another

Signed-off-by: Stéphane Graber <[email protected]>
Signed-off-by: Stéphane Graber <[email protected]>
Signed-off-by: Stéphane Graber <[email protected]>
Signed-off-by: Stéphane Graber <[email protected]>
Signed-off-by: Stéphane Graber <[email protected]>
Signed-off-by: Stéphane Graber <[email protected]>
Signed-off-by: Stéphane Graber <[email protected]>
Signed-off-by: Stéphane Graber <[email protected]>
Signed-off-by: Stéphane Graber <[email protected]>
Signed-off-by: Stéphane Graber <[email protected]>
This properly capitalizes:
 - UID
 - GID
 - ID
 - NS
 - LXC
 - MapRange

Signed-off-by: Stéphane Graber <[email protected]>
Signed-off-by: Stéphane Graber <[email protected]>
@stgraber stgraber marked this pull request as draft January 6, 2024 00:12
Signed-off-by: Stéphane Graber <[email protected]>
Signed-off-by: Stéphane Graber <[email protected]>
Signed-off-by: Stéphane Graber <[email protected]>
Signed-off-by: Stéphane Graber <[email protected]>
This replaces:
 - ShiftRootfs
 - UnshiftRootfs
 - ShiftIntoContainer
 - ShiftFromContainer
 - ShiftFile

WIth just the two:
 - ShiftPath (equivalent of ShiftRootfs)
 - UnshiftPath (equivalent of UnshiftRootfs)

The testmode argument is gone and can instead be replaced by passing in
a simple skipper function that performs the same role.

ShiftFile is removed as it was just an alias to ShiftRoofs (now ShiftPath).

Signed-off-by: Stéphane Graber <[email protected]>
Signed-off-by: Stéphane Graber <[email protected]>
Signed-off-by: Stéphane Graber <[email protected]>
Copy link
Member

@tych0 tych0 left a comment

Choose a reason for hiding this comment

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

Looks good to me, this is some of the oldest code in the tree... wild.

Signed-off-by: Stéphane Graber <[email protected]>
Copy link
Member

@hallyn hallyn left a comment

Choose a reason for hiding this comment

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

Thanks!

@hallyn hallyn merged commit b1687e6 into lxc:main Jan 8, 2024
24 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants