Skip to content

Commit

Permalink
Fix build of Windows MSI when running as root (#28)
Browse files Browse the repository at this point in the history
Use permissive file permissions to allow mounting files into Wix Docker container.

Fixes #1424
  • Loading branch information
zwass authored Jul 20, 2021
1 parent c4b2e7f commit d56042d
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Orbit is the recommended agent for Fleet. But Orbit can be used with or without

## Try Orbit

#### With [`fleetctl preview` already running](https://github.com/fleetdm/fleet#try-fleet) and [Go](https://golang.org/doc/install) installed:
#### With [`fleetctl preview` already running](https://github.com/fleetdm/fleet#try-fleet) and [Go](https://golang.org/doc/install) 1.16 installed:

```bash
# From within the top-level directory of this repo…
Expand Down
1 change: 1 addition & 0 deletions changes/.keep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
IGNORE BUT DO NOT REMOVE. THIS IS HERE SO THAT THE DIRECTORY REMAINS
1 change: 1 addition & 0 deletions changes/build-msi-root
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Fix permissions for building MSI when packaging as root user. Fixes fleetdm/fleet#1424
2 changes: 1 addition & 1 deletion cmd/package/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func main() {
&cli.StringFlag{
Name: "version",
Usage: "Version for package product",
Value: "0.0.2",
Value: "0.0.3",
Destination: &opt.Version,
},
&cli.BoolFlag{
Expand Down
15 changes: 15 additions & 0 deletions pkg/packaging/packaging.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package packaging

import (
"io"
"io/fs"
"io/ioutil"
"os"
"path/filepath"
Expand Down Expand Up @@ -114,3 +115,17 @@ func writeSecret(opt Options, orbitRoot string) error {

return nil
}

func chmodRecursive(path string, perm os.FileMode) error {
return filepath.Walk(path, func(path string, info fs.FileInfo, err error) error {
if err != nil {
return errors.Wrap(err, "walk error")
}

if err := os.Chmod(path, perm); err != nil {
return errors.Wrap(err, "chmod")
}

return nil
})
}
5 changes: 5 additions & 0 deletions pkg/packaging/windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ func BuildMSI(opt Options) error {
return errors.Wrap(err, "write wix file")
}

// Make sure permissions are permissive so that the `wine` user in the Wix Docker container can access files.
if err := chmodRecursive(tmpDir, os.ModePerm); err != nil {
return err
}

if err := wix.Heat(tmpDir); err != nil {
return errors.Wrap(err, "package root files")
}
Expand Down

0 comments on commit d56042d

Please sign in to comment.