-
Notifications
You must be signed in to change notification settings - Fork 1
Fix owner issues #21
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
base: main
Are you sure you want to change the base?
Fix owner issues #21
Conversation
The syscall.Chown requires root permissions. With this, tests can replace it with a dummy function.
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 | ||
} |
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.
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?
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.
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.
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.