-
Notifications
You must be signed in to change notification settings - Fork 252
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
chunked: honor the ForceMask setting #1971
Changes from all commits
f37aea9
e717273
eec2a60
f35833c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,6 @@ const ( | |
maxNumberMissingChunks = 1024 | ||
autoMergePartsThreshold = 1024 // if the gap between two ranges is below this threshold, automatically merge them. | ||
newFileFlags = (unix.O_CREAT | unix.O_TRUNC | unix.O_EXCL | unix.O_WRONLY) | ||
containersOverrideXattr = "user.containers.override_stat" | ||
bigDataKey = "zstd-chunked-manifest" | ||
chunkedData = "zstd-chunked-data" | ||
chunkedLayerDataKey = "zstd-chunked-layer-data" | ||
|
@@ -1340,11 +1339,14 @@ func (c *chunkedDiffer) ApplyDiff(dest string, options *archive.TarOptions, diff | |
} | ||
|
||
filesToWaitFor := 0 | ||
for i, r := range mergedEntries { | ||
for i := range mergedEntries { | ||
r := &mergedEntries[i] | ||
if options.ForceMask != nil { | ||
value := fmt.Sprintf("%d:%d:0%o", r.UID, r.GID, r.Mode&0o7777) | ||
r.Xattrs[containersOverrideXattr] = base64.StdEncoding.EncodeToString([]byte(value)) | ||
r.Mode = int64(*options.ForceMask) | ||
value := idtools.FormatContainersOverrideXattr(r.UID, r.GID, int(r.Mode)) | ||
if r.Xattrs == nil { | ||
r.Xattrs = make(map[string]string) | ||
} | ||
r.Xattrs[idtools.ContainersOverrideXattr] = base64.StdEncoding.EncodeToString([]byte(value)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It feels a bit unclean to mutate the input here; I'd trust you if you said it was safe, but still. In ostree we have something very similar to the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be safe because Ultimately, that is still safe because There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In Rust:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I’d sign up to be a platinum member of the Go haters club, but that’s not really under discussion in this PR. (If you wanted to make a case for rewriting the stack in Rust, I’d not oppose that at all.) I do agree that this would be safer with a deep copy, but then … Go doesn’t have a language-native deep copy operation either. So it’s either risk of bugs due to overwriting data (if it ever turned from single use into multiple-use) or risk of bugs due to missing a field copy (if we ever added a field), and to me that feels like a wash, up to @giuseppe . |
||
} | ||
|
||
mode := os.FileMode(r.Mode) | ||
|
@@ -1393,7 +1395,7 @@ func (c *chunkedDiffer) ApplyDiff(dest string, options *archive.TarOptions, diff | |
return err | ||
} | ||
defer file.Close() | ||
if err := setFileAttrs(dirfd, file, mode, &r, options, false); err != nil { | ||
if err := setFileAttrs(dirfd, file, mode, r, options, false); err != nil { | ||
return err | ||
} | ||
return nil | ||
|
@@ -1408,7 +1410,7 @@ func (c *chunkedDiffer) ApplyDiff(dest string, options *archive.TarOptions, diff | |
if r.Name == "" || r.Name == "." { | ||
output.RootDirMode = &mode | ||
} | ||
if err := safeMkdir(dirfd, mode, r.Name, &r, options); err != nil { | ||
if err := safeMkdir(dirfd, mode, r.Name, r, options); err != nil { | ||
return output, err | ||
} | ||
continue | ||
|
@@ -1422,12 +1424,12 @@ func (c *chunkedDiffer) ApplyDiff(dest string, options *archive.TarOptions, diff | |
dest: dest, | ||
dirfd: dirfd, | ||
mode: mode, | ||
metadata: &r, | ||
metadata: r, | ||
}) | ||
continue | ||
|
||
case tar.TypeSymlink: | ||
if err := safeSymlink(dirfd, mode, &r, options); err != nil { | ||
if err := safeSymlink(dirfd, mode, r, options); err != nil { | ||
return output, err | ||
} | ||
continue | ||
|
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.
Either the first line can crash, or the second one is unnecessary.
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.
thanks, opened a PR: #1984