-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Non-Root] Add support for running without root permissions on Linux (#…
…3598) * Work on non-root. * Only create group and user if not existing. * More work on non-root for darwin. * Fix FindUID. * More fixes. * Fix service. Add linux user commands. * Fix control socket path. * Trim unix://. * Fix permissions on socket path create. * More socket fixes. * Use MkdirAll. * Fix SysProcAttr. * Only Linux. * mage check * Add non-root install integration tests. * Fix imports. * Fix windows build. * Testing fixes. * Fix non-root base path test. * Empty commit. * More non-root fixes. * Fix issue from merge. * Upgrade unpack prevent world permissions. * Add group permissions for logs in non-root mode. * Fix permissions for internal logger. * Fixes from code review. * Change to using a structure. * More code review fixes. * Update to fmt.Errorf.
- Loading branch information
1 parent
6456394
commit f7dcbd7
Showing
35 changed files
with
934 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
// or more contributor license agreements. Licensed under the Elastic License; | ||
// you may not use this file except in compliance with the Elastic License. | ||
|
||
//go:build !windows | ||
|
||
package info | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/elastic/elastic-agent/pkg/utils" | ||
) | ||
|
||
func fixInstallMarkerPermissions(markerFilePath string, ownership utils.FileOwner) error { | ||
err := os.Chown(markerFilePath, ownership.UID, ownership.GID) | ||
if err != nil { | ||
return fmt.Errorf("failed to chown %d:%d %s: %w", ownership.UID, ownership.GID, markerFilePath, err) | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
// or more contributor license agreements. Licensed under the Elastic License; | ||
// you may not use this file except in compliance with the Elastic License. | ||
|
||
//go:build windows | ||
|
||
package info | ||
|
||
import ( | ||
"github.com/elastic/elastic-agent/pkg/utils" | ||
) | ||
|
||
func fixInstallMarkerPermissions(markerFilePath string, ownership utils.FileOwner) error { | ||
// TODO(blakerouse): Fix the market permissions on Windows. | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
// or more contributor license agreements. Licensed under the Elastic License; | ||
// you may not use this file except in compliance with the Elastic License. | ||
|
||
//go:build !windows | ||
|
||
package cmd | ||
|
||
import ( | ||
"os/exec" | ||
"syscall" | ||
|
||
"github.com/elastic/elastic-agent/pkg/utils" | ||
) | ||
|
||
func enrollCmdExtras(cmd *exec.Cmd, ownership utils.FileOwner) error { | ||
cmd.SysProcAttr = &syscall.SysProcAttr{ | ||
Credential: &syscall.Credential{ | ||
Uid: uint32(ownership.UID), | ||
Gid: uint32(ownership.GID), | ||
}, | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
// or more contributor license agreements. Licensed under the Elastic License; | ||
// you may not use this file except in compliance with the Elastic License. | ||
|
||
//go:build windows | ||
|
||
package cmd | ||
|
||
import ( | ||
"os/exec" | ||
|
||
"github.com/elastic/elastic-agent/pkg/utils" | ||
) | ||
|
||
func enrollCmdExtras(cmd *exec.Cmd, ownership utils.FileOwner) error { | ||
// TODO: Add ability to call enroll as non-Administrator on Windows. | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.