Skip to content

Commit

Permalink
manifest: remove explicit ownership from insights files
Browse files Browse the repository at this point in the history
When creating the service drop-in file and directory for running the
insights client on boot, don't specify ownership.  This is for the same
reasons as for the other files we create in the subscription pipeline:
there is no `chown` binary in the subscription pipeline tree, which
would be required to explicitly set the file's ownership.

Update tests to match.
  • Loading branch information
achilleas-k committed Sep 5, 2024
1 parent 5c12835 commit 9152156
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions pkg/manifest/subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,16 @@ func runInsightsClientOnBoot() (*fsnode.Directory, *fsnode.File, error) {
// all the options we need. This is a temporary workaround
// until we get the stage updated to support everything we need.
icDropinFilepath, icDropinContents := insightsClientDropin()
icDropinDirectory, err := fsnode.NewDirectory(filepath.Dir(icDropinFilepath), nil, "root", "root", true)

// NOTE: Ownership is left as nil:nil, which implicitly creates files as
// root:root. Adding an explicit owner requires chroot to run the
// org.osbuild.chown stage, which we can't run in the subscription pipeline
// since it has no packages.
icDropinDirectory, err := fsnode.NewDirectory(filepath.Dir(icDropinFilepath), nil, nil, nil, true)
if err != nil {
return nil, nil, err
}
icDropinFile, err := fsnode.NewFile(icDropinFilepath, nil, "root", "root", []byte(icDropinContents))
icDropinFile, err := fsnode.NewFile(icDropinFilepath, nil, nil, nil, []byte(icDropinContents))
if err != nil {
return nil, nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/manifest/subscription_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ Requisite=greenboot-healthcheck.service
After=network-online.target greenboot-healthcheck.service osbuild-first-boot.service
[Install]
WantedBy=multi-user.target`
icDropinFile, err := fsnode.NewFile("/etc/systemd/system/insights-client.service.d/override.conf", nil, "root", "root", []byte(dropinContents))
icDropinFile, err := fsnode.NewFile("/etc/systemd/system/insights-client.service.d/override.conf", nil, nil, nil, []byte(dropinContents))
if err != nil {
panic(err)
}
Expand All @@ -416,7 +416,7 @@ WantedBy=multi-user.target`

func mkInsightsDropinDir() *fsnode.Directory {

icDropinDirectory, err := fsnode.NewDirectory("/etc/systemd/system/insights-client.service.d", nil, "root", "root", true)
icDropinDirectory, err := fsnode.NewDirectory("/etc/systemd/system/insights-client.service.d", nil, nil, nil, true)
if err != nil {
panic(err)
}
Expand Down

0 comments on commit 9152156

Please sign in to comment.