Skip to content

Commit

Permalink
Merge pull request #2297 from aws-observability/root-user-linux
Browse files Browse the repository at this point in the history
[aoc-collector non-root user]: Removing code that changes user
  • Loading branch information
rapphil committed Sep 5, 2023
2 parents 787da80 + 5149a53 commit ddc5d47
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 337 deletions.
13 changes: 0 additions & 13 deletions cmd/awscollector/main_others.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,9 @@ import (
"log"

"go.opentelemetry.io/collector/otelcol"

"github.com/aws-observability/aws-otel-collector/pkg/extraconfig"
"github.com/aws-observability/aws-otel-collector/pkg/userutils"
)

func run(params otelcol.CollectorSettings, flagSet *flag.FlagSet) error {
// Try to switch user when the collector is running on a host.
// For container the user and group is determined by the deployed manifest.
if !extraconfig.IsRunningInContainer() {
// avoid running as 'root' user on Linux
_, err := userutils.ChangeUser()
if err != nil {
log.Printf("E! Failed to ChangeUser: %v ", err)
return err
}
}
return runInteractive(params, flagSet)
}

Expand Down
29 changes: 0 additions & 29 deletions pkg/userutils/set_uid_gid.go

This file was deleted.

24 changes: 0 additions & 24 deletions pkg/userutils/userutil_darwin.go

This file was deleted.

163 changes: 0 additions & 163 deletions pkg/userutils/userutil_linux.go

This file was deleted.

107 changes: 0 additions & 107 deletions pkg/userutils/userutil_test.go

This file was deleted.

3 changes: 2 additions & 1 deletion tools/packaging/linux/aws-otel-collector.conf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ start on (runlevel [345] and started network)
stop on (runlevel [!345] or stopping network)

normal exit 0

setuid aoc
setgid aoc
respawn

script
Expand Down
2 changes: 2 additions & 0 deletions tools/packaging/linux/aws-otel-collector.service
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ ExecStart=/opt/aws/aws-otel-collector/bin/aws-otel-collector $config
KillMode=process
Restart=on-failure
RestartSec=60s
User=aoc
Group=aoc

[Install]
WantedBy=multi-user.target

0 comments on commit ddc5d47

Please sign in to comment.