Skip to content

Commit

Permalink
Ignore ErrNotExists when fixing permissions (#27846) (#27877)
Browse files Browse the repository at this point in the history
* Ignore ErrNotExists when fixing permissions on Windows

* Ignore ErrNotExist for unix instances

(cherry picked from commit 13e3466)

Co-authored-by: Michel Laterman <82832767+michel-laterman@users.noreply.github.com>
  • Loading branch information
mergify[bot] and michel-laterman authored Sep 11, 2021
1 parent 2b6b8e5 commit 16e7cb3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions x-pack/elastic-agent/CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@
- Change output.elasticsearch.proxy_disabled flag to output.elasticsearch.proxy_disable so fleet uses it. {issue}27670[27670] {pull}27671[27671]
- Add validation for certificate flags to ensure they are absolute paths. {pull}27779[27779]
- Migrate state on upgrade {pull}27825[27825]
- Add "_monitoring" suffix to monitoring instance names to remove ambiguity with the status command. {issue}25449[25449]
- Ignore ErrNotExists when fixing permissions. {issue}27836[27836] {pull}27846[27846]

==== New features

Expand Down
3 changes: 3 additions & 0 deletions x-pack/elastic-agent/pkg/agent/install/perms_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package install

import (
"errors"
"io/fs"
"os"
"path/filepath"
Expand All @@ -29,6 +30,8 @@ func recursiveRootPermissions(path string) error {
}
// remove any world permissions from the file
err = os.Chmod(name, info.Mode().Perm()&0770)
} else if errors.Is(err, fs.ErrNotExist) {
return nil
}
return err
})
Expand Down
3 changes: 3 additions & 0 deletions x-pack/elastic-agent/pkg/agent/install/perms_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package install

import (
"errors"
"io/fs"
"path/filepath"

Expand All @@ -30,6 +31,8 @@ func recursiveSystemAdminPermissions(path string) error {
inherit = false
}
err = systemAdministratorsOnly(name, inherit)
} else if errors.Is(err, fs.ErrNotExist) {
return nil
}
return err
})
Expand Down

0 comments on commit 16e7cb3

Please sign in to comment.