Skip to content

Commit 77bbf4c

Browse files
fix: remove --skip-file-capabilities flag
1 parent cc6f8df commit 77bbf4c

File tree

3 files changed

+8
-20
lines changed

3 files changed

+8
-20
lines changed

internal/pkg/agent/cmd/container.go

+3-12
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ const (
4545
defaultStateDirectory = "/usr/share/elastic-agent/state" // directory that will hold the state data
4646
agentBaseDirectory = "/usr/share/elastic-agent" // directory that holds all elastic-agent related files
4747

48-
skipFileCapabilitiesFlag = "skip-file-capabilities"
49-
5048
logsPathPerms = 0775
5149
)
5250

@@ -142,15 +140,13 @@ all the above actions will be skipped, because the Elastic Agent has already bee
142140
occurs on every start of the container set FLEET_FORCE to 1.
143141
`,
144142
Run: func(c *cobra.Command, args []string) {
145-
if err := logContainerCmd(c, streams); err != nil {
143+
if err := logContainerCmd(streams); err != nil {
146144
logError(streams, err)
147145
os.Exit(1)
148146
}
149147
},
150148
}
151149

152-
cmd.Flags().Bool(skipFileCapabilitiesFlag, false, "skip setting file capabilities")
153-
154150
return &cmd
155151
}
156152

@@ -162,13 +158,8 @@ func logInfo(streams *cli.IOStreams, a ...interface{}) {
162158
fmt.Fprintln(streams.Out, a...)
163159
}
164160

165-
func logContainerCmd(cmd *cobra.Command, streams *cli.IOStreams) error {
166-
skipFileCapabilities, err := cmd.Flags().GetBool(skipFileCapabilitiesFlag)
167-
if err != nil {
168-
return err
169-
}
170-
171-
shouldExit, err := initContainer(streams, skipFileCapabilities)
161+
func logContainerCmd(streams *cli.IOStreams) error {
162+
shouldExit, err := initContainer(streams)
172163
if err != nil {
173164
return err
174165
}

internal/pkg/agent/cmd/container_init_linux.go

+4-7
Original file line numberDiff line numberDiff line change
@@ -33,37 +33,34 @@ var (
3333
// - chown all agent-related paths if DAC_OVERRIDE capability is not in the Effective set
3434
// If new binary capabilities are set then the returned cmd will be not nil. Note that it is up to caller to invoke
3535
// the returned cmd and spawn an agent instance with all the capabilities.
36-
func initContainer(streams *cli.IOStreams, skipFileCapabilities bool) (shouldExit bool, err error) {
36+
func initContainer(streams *cli.IOStreams) (shouldExit bool, err error) {
3737
isRoot, err := utils.HasRoot()
3838
if err != nil {
3939
return true, err
4040
}
41-
if !skipFileCapabilities && !isRoot {
41+
if !isRoot {
4242
executable, err := os.Executable()
4343
if err != nil {
4444
return true, err
4545
}
4646

47-
logInfo(streams, "agent container initialisation - file capabilities")
47+
logInfo(streams, "agent container initialisation - checking file capabilities")
4848
updated, err := updateFileCapsFromBoundingSet(executable)
4949
if err != nil {
5050
return true, err
5151
}
5252

5353
if updated {
54+
logInfo(streams, "agent container initialisation - re-exec")
5455
// new capabilities were added thus we need to re-exec agent to pick them up
5556
args := []string{filepath.Base(executable)}
5657
if len(os.Args) > 1 {
5758
args = append(args, os.Args[1:]...)
5859
}
59-
// add skipFileCapabilitiesFlag flag to skip reapplying the file capabilities
60-
args = append(args, fmt.Sprintf("--%s", skipFileCapabilitiesFlag))
6160

6261
return true, unix.Exec(executable, args, os.Environ())
6362
}
64-
}
6563

66-
if !isRoot {
6764
// if we are not root, we need to raise the ambient capabilities
6865
logInfo(streams, "agent container initialisation - ambient capabilities")
6966
if err := raiseAmbientCapabilities(); err != nil {

internal/pkg/agent/cmd/container_init_other.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ import (
1010
"github.com/elastic/elastic-agent/internal/pkg/cli"
1111
)
1212

13-
func initContainer(streams *cli.IOStreams, skipFileCapabilities bool) (shouldExit bool, err error) {
13+
func initContainer(streams *cli.IOStreams) (shouldExit bool, err error) {
1414
return false, nil
1515
}

0 commit comments

Comments
 (0)