Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions pkg/inject/inject.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,19 @@ func Inject(opts InjectOptions) (bool, error) {
}
log.Debugf("injection: payload delivered elapsed=%s", time.Since(start))

// prefer result error
if result.err != nil {
return result.wasExecuted, result.err
} else if err != nil {
}

// Exec EOF during binary injection is expected: the container entrypoint
// may exec the daemon (killing the docker exec process) before inject.sh
// prints its final response. Only surface exec errors when a command was
// actually executed through the script.
if err != nil && result.wasExecuted {
return result.wasExecuted, err
} else if result.wasExecuted || opts.ScriptParams.Command == "" {
}

if result.wasExecuted || opts.ScriptParams.Command == "" {
return result.wasExecuted, nil
}

Expand Down
23 changes: 16 additions & 7 deletions pkg/inject/inject.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ inject_binary() {
return 1
fi

if [ "$CHMOD_PATH" = "true" ]; then
$sh_c "chmod +x \"$temp_file\"" || {
>&2 echo "Error: Failed to make $temp_file executable"
$sh_c "rm -f \"$temp_file\"" 2>/dev/null || true
return 1
}
fi

if ! $sh_c "mv \"$temp_file\" \"$INSTALL_PATH\""; then
>&2 echo "Error: Failed to move binary to $INSTALL_PATH"
$sh_c "rm -f \"$temp_file\"" 2>/dev/null || true
Expand Down Expand Up @@ -97,6 +105,14 @@ download_binary() {
return 1
fi

if [ "$CHMOD_PATH" = "true" ]; then
$sh_c "chmod +x \"$temp_file\"" || {
>&2 echo "Error: Failed to make $temp_file executable"
$sh_c "rm -f \"$temp_file\"" 2>/dev/null || true
return 1
}
fi

if ! $sh_c "mv \"$temp_file\" \"$INSTALL_PATH\""; then
>&2 echo "Error: Failed to move downloaded binary to $INSTALL_PATH"
$sh_c "rm -f \"$temp_file\"" 2>/dev/null || true
Expand Down Expand Up @@ -147,13 +163,6 @@ install_agent() {
}
fi
fi

if [ "$CHMOD_PATH" = "true" ]; then
$sh_c "chmod +x \"$INSTALL_PATH\"" || {
>&2 echo "Error: Failed to make $INSTALL_PATH executable"
exit 1
}
fi
}

execute_command() {
Expand Down
Loading