-
Notifications
You must be signed in to change notification settings - Fork 85
Set ownership on symlinks created by build actions during their execution #211
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?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -219,16 +219,16 @@ func main() { | |
| normalizer = virtual.CaseInsensitiveComponentNormalizer | ||
| } | ||
|
|
||
| defaultAttributesSetter := func(requested virtual.AttributesMask, attributes *virtual.Attributes) { | ||
| // No need to set ownership attributes | ||
| // on the top-level directory. | ||
| } | ||
| symlinkFactory = virtual.NewHandleAllocatingSymlinkFactory( | ||
| virtual.BaseSymlinkFactory, | ||
| virtual.NewBaseSymlinkFactory(defaultAttributesSetter), | ||
| handleAllocator.New()) | ||
| characterDeviceFactory = virtual.NewHandleAllocatingCharacterDeviceFactory( | ||
| virtual.BaseCharacterDeviceFactory, | ||
| handleAllocator.New()) | ||
| defaultAttributesSetter := func(requested virtual.AttributesMask, attributes *virtual.Attributes) { | ||
| // No need to set ownership attributes | ||
| // on the top-level directory. | ||
| } | ||
| virtualBuildDirectory = virtual.NewInMemoryPrepopulatedDirectory( | ||
| virtual.NewHandleAllocatingFileAllocator( | ||
| virtual.NewPoolBackedFileAllocator( | ||
|
|
@@ -343,6 +343,13 @@ func main() { | |
| } | ||
| runnerClient := runner_pb.NewRunnerClient(runnerConnection) | ||
|
|
||
| defaultAttributesSetter := func(requested virtual.AttributesMask, attributes *virtual.Attributes) { | ||
| attributes.SetOwnerUserID(runnerConfiguration.BuildDirectoryOwnerUserId) | ||
| attributes.SetOwnerGroupID(runnerConfiguration.BuildDirectoryOwnerGroupId) | ||
| } | ||
| symlinkFactory := virtual.NewHandleAllocatingSymlinkFactory( | ||
|
Member
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. Given that |
||
| virtual.NewBaseSymlinkFactory(defaultAttributesSetter), | ||
| handleAllocator.New()) | ||
| for threadID := uint64(0); threadID < runnerConfiguration.Concurrency; threadID++ { | ||
| // Per-worker separate writer of the Content | ||
| // Addressable Storage that batches writes after | ||
|
|
@@ -391,10 +398,7 @@ func main() { | |
| symlinkFactory, | ||
| characterDeviceFactory, | ||
| handleAllocator, | ||
| /* defaultAttributesSetter = */ func(requested virtual.AttributesMask, attributes *virtual.Attributes) { | ||
| attributes.SetOwnerUserID(runnerConfiguration.BuildDirectoryOwnerUserId) | ||
| attributes.SetOwnerGroupID(runnerConfiguration.BuildDirectoryOwnerGroupId) | ||
| }, | ||
| defaultAttributesSetter, | ||
| clock.SystemClock, | ||
| ) | ||
| } else { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,19 +13,30 @@ import ( | |
| "google.golang.org/grpc/status" | ||
| ) | ||
|
|
||
| type symlinkFactory struct{} | ||
| type symlinkFactory struct { | ||
|
Member
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. While there, can we rename this to |
||
| defaultAttributesSetter DefaultAttributesSetter | ||
| } | ||
|
|
||
| func (symlinkFactory) LookupSymlink(target []byte) LinkableLeaf { | ||
| return symlink{target: target} | ||
| func (f *symlinkFactory) LookupSymlink(target []byte) LinkableLeaf { | ||
| return symlink{ | ||
| defaultAttributesSetter: f.defaultAttributesSetter, | ||
| target: target, | ||
| } | ||
| } | ||
|
|
||
| // BaseSymlinkFactory can be used to create simple immutable symlink nodes. | ||
| var BaseSymlinkFactory SymlinkFactory = symlinkFactory{} | ||
| // NewBaseSymlinkFactory creates a SymlinkFactory that can be used to create | ||
| // simple immutable symlink nodes. | ||
| func NewBaseSymlinkFactory(defaultAttributesSetter DefaultAttributesSetter) SymlinkFactory { | ||
| return &symlinkFactory{ | ||
| defaultAttributesSetter: defaultAttributesSetter, | ||
| } | ||
| } | ||
|
|
||
| type symlink struct { | ||
| placeholderFile | ||
|
|
||
| target []byte | ||
| defaultAttributesSetter DefaultAttributesSetter | ||
| target []byte | ||
| } | ||
|
|
||
| func (f symlink) readlinkParser() (path.Parser, error) { | ||
|
|
@@ -48,6 +59,7 @@ func (f symlink) readlinkString() (string, error) { | |
| } | ||
|
|
||
| func (f symlink) VirtualGetAttributes(ctx context.Context, requested AttributesMask, attributes *Attributes) { | ||
| f.defaultAttributesSetter(requested, attributes) | ||
| attributes.SetChangeID(0) | ||
| attributes.SetFileType(filesystem.FileTypeSymlink) | ||
| attributes.SetHasNamedAttributes(false) | ||
|
|
||
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.
If we are going to give the top level directory a SymlinkFactory that differs from the one that's used per build directory, what are your thoughts on giving it an instance that always returns an error? There should be no need for anyone to ever place symlinks in there. This does require changing
SymlinkFactory.LookupSymlink()to return anerror.