Skip to content

Commit

Permalink
Merge pull request inspektor-gadget#2641 from inspektor-gadget/alban_…
Browse files Browse the repository at this point in the history
…fix_ownership

pkg/oci: make fixMetadataOwner more generic
  • Loading branch information
alban authored Mar 25, 2024
2 parents d0b0822 + ef66135 commit 92c3134
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/oci/build_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func createOrUpdateMetadataFile(ctx context.Context, opts *BuildGadgetImageOpts)

// fix owner of created metadata file
if !update {
if err := fixMetadataOwner(opts); err != nil {
if err := fixOwner(opts.MetadataPath, opts.EBPFSourcePath); err != nil {
log.Warnf("Failed to fix metadata file owner: %v", err)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ import (
"syscall"
)

func fixMetadataOwner(opts *BuildGadgetImageOpts) error {
info, err := os.Stat(opts.EBPFSourcePath)
func fixOwner(targetFile, modelFile string) error {
info, err := os.Stat(modelFile)
if err != nil {
return err
}
if stat, ok := info.Sys().(*syscall.Stat_t); ok {
err := os.Chown(opts.MetadataPath, int(stat.Uid), int(stat.Gid))
err := os.Chown(targetFile, int(stat.Uid), int(stat.Gid))
if err != nil {
return err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ package oci

import "fmt"

func fixMetadataOwner(opts *BuildGadgetImageOpts) error {
return fmt.Errorf("fixMetadataOwner not implemented on this platform")
func fixOwner(_, _ string) error {
return fmt.Errorf("fixOwner not implemented on this platform")
}

0 comments on commit 92c3134

Please sign in to comment.