Fix SELinux compatibility in host agent installer
Replace mv with install command to ensure correct SELinux context. The mv command preserves the user_tmp_t label from /tmp, which prevents systemd from executing the binary on SELinux systems. The install command creates a new file with the correct label for /usr/local/bin. Added automatic restorecon call for SELinux systems to ensure policy compliance. Related to #688
This commit is contained in:
parent
f6570e18b7
commit
e5dfca6c88
1 changed files with 12 additions and 2 deletions
|
|
@ -386,8 +386,18 @@ else
|
||||||
log_info "Checksum not available (server doesn't provide it yet)"
|
log_info "Checksum not available (server doesn't provide it yet)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo mv "$TEMP_BINARY" "$AGENT_PATH"
|
# Use install command instead of mv to ensure correct SELinux context
|
||||||
sudo chmod +x "$AGENT_PATH"
|
# The install command creates a new file with the correct label for the target directory
|
||||||
|
sudo install -m 0755 "$TEMP_BINARY" "$AGENT_PATH"
|
||||||
|
rm -f "$TEMP_BINARY"
|
||||||
|
|
||||||
|
# On SELinux systems, explicitly restore context to ensure policy compliance
|
||||||
|
if command -v selinuxenabled &> /dev/null && selinuxenabled 2>/dev/null; then
|
||||||
|
if command -v restorecon &> /dev/null; then
|
||||||
|
sudo restorecon -F "$AGENT_PATH" 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
log_success "Agent binary installed to $AGENT_PATH"
|
log_success "Agent binary installed to $AGENT_PATH"
|
||||||
|
|
||||||
# Build reusable agent command strings
|
# Build reusable agent command strings
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue