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

fix: parent directory permissions #128

Merged
merged 34 commits into from
Apr 12, 2024

Conversation

letFunny
Copy link
Collaborator

  • Have you signed the CLA?

This commit fixes three bugs regarding parent directory creation.

The first one is that implicit folders were overwriting the permissions
of explicit ones in slice definitions (e.g. slice A declares /foo/bar
and slice B /foo, if slice A was installed after B then the implicit
permissions of /foo from A would prevail.

The second one is that we were creating parent directories of optional
files which did not exist.

The third bug is that we were not using the permissions from the tarball
for parent directories if the path was a glob.


This PR depends on #124, the new commit is a2805d0.

I had a discussion with @niemeyer that we need to discuss and agree on way to record parent paths in chisel db. However, I think that meanwhile we should fix these three bugs which are in the code right now.

To make the content transparent and facilitate changing the package,
this commit creates the deb used for testing programmatically instead of
embedding it as a base64-encoded blob directly.
The entries not mentioned explicitly in the slice definition will not be
added to the report (e.g. copyright, parent directories). Additionally,
we have removed the Globbed option and simplified it.
This commit fixes three bugs regarding parent directory creation.

The first one is that implicit folders were overwriting the permissions
of explicit ones in slice definitions (e.g. slice A declares /foo/bar
and slice B /foo, if slice A was installed after B then the implicit
permissions of /foo from A would prevail.

The second one is that we were creating parent directories of optional
files which did not exist.

The third bug is that we were not using the permissions from the tarball
for parent directories if the path was a glob.
@letFunny letFunny requested a review from rebornplusplus March 12, 2024 15:22
@cjdcordeiro cjdcordeiro requested a review from niemeyer March 14, 2024 10:03
@niemeyer niemeyer changed the title bugfix: parent directory permissions fix: parent directory permissions Apr 1, 2024
Copy link
Contributor

@niemeyer niemeyer left a comment

Choose a reason for hiding this comment

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

Thanks for fixing these issues, Alberto. A few questions below.

internal/deb/extract.go Show resolved Hide resolved
internal/deb/extract.go Outdated Show resolved Hide resolved
internal/deb/extract.go Outdated Show resolved Hide resolved
internal/deb/extract.go Outdated Show resolved Hide resolved
internal/deb/extract.go Outdated Show resolved Hide resolved
internal/deb/extract.go Show resolved Hide resolved
internal/deb/extract.go Outdated Show resolved Hide resolved
internal/deb/extract.go Outdated Show resolved Hide resolved
@letFunny letFunny requested a review from niemeyer April 3, 2024 09:12
@cjdcordeiro cjdcordeiro added the Priority Look at me first label Apr 5, 2024
internal/deb/extract.go Show resolved Hide resolved
@@ -16,6 +16,8 @@ type CreateOptions struct {
Mode fs.FileMode
Data io.Reader
Link string
// If OverrideMode is true and a directory exists, its mode will be modified.
OverrideMode bool
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not looking right, for two reasons:

  1. We've added a flag to control behavior that was standard until this commit, meaning every single call site for the Create function was the equivalent of OverrideMode: true. Yet, we're not using this flag anywhere apparently, which means it's false 100% of the time and the behavior has been disabled. That implies to me that the old behavior has turned irrelevant after the last couple of changes, so we can just drop the behavior altogether.

  2. This flag doesn't seem to sit well in the API as a whole. It doesn't make sense for this flag to work only on directories, for example.

GIven (1), what's the situation? Can we just delete the behavior altogether?

Copy link
Collaborator Author

@letFunny letFunny Apr 12, 2024

Choose a reason for hiding this comment

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

Agree with both. I was keeping it for future compatibility but when we need it we can just add it back to the API. Deleting unused code is the best code.

Copy link
Contributor

@niemeyer niemeyer left a comment

Choose a reason for hiding this comment

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

This ended up as a great PR, thanks Alberto.

@niemeyer niemeyer merged commit 94c4656 into canonical:main Apr 12, 2024
13 of 14 checks passed
@letFunny letFunny deleted the parent-dir-permissions branch October 17, 2024 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority Look at me first
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants