Skip to content

Conversation

taukakao
Copy link
Contributor

The current implementation has a huge oversight. If the uids in the image change, which they regularly do, they also change on the installed system.

This is a very big problem since it means that system services will not have access to the right folders in that case.
More information about this can be found here: Vanilla-OS/ABRoot#419

This PR is a complete rework of EtcBuilder which has logic that dynamically adds new users and groups from the image/lower dir. It also changes the owner and group of the lower files to adjust them to the specific system they're on.

A rework was needed since it would have been very messy to implement this with the old structure. The API does stay the same, except for the settings file for "special Files", which doesn't exist anymore.

Comment on lines +11 to +34
func CarbonCopyRecursive(from, to string) error {

err := fs.WalkDir(os.DirFS(from), ".", func(path string, d fs.DirEntry, err error) error {
if err != nil {
return fmt.Errorf("can't search path \"%s\": %w", path, err)
}

from := filepath.Join(from, path)
to := filepath.Join(to, path)

err = CarbonCopy(from, to)
if err != nil {
return fmt.Errorf("can't copy \"%s\": %w", path, err)
}

return nil
})

if err != nil {
return fmt.Errorf("can't copy all files: %w", err)
}

return nil
}
Copy link
Member

Choose a reason for hiding this comment

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

Everything looks good, I just have a doubt here. If the root folder does not exist for some rasons, it won't be created with this change. Am I wrong?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fs.WalkDir starts with the "." path, so it will be copied from the old upper etc.
But you're right, if the old upper etc doesn't exist then it would fail. I should probably add os.MkdirAll for the folders to ensure they all exist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants