Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Guard host-agent installs on noexec filesystems (Related to #718)

rcourtmana3d88ed7fec1
diff --git a/frontend-modern/public/install-host-agent.sh b/frontend-modern/public/install-host-agent.sh
index 75cfbbb561..05212d3c06 100755
--- a/frontend-modern/public/install-host-agent.sh
+++ b/frontend-modern/public/install-host-agent.sh
@@ -453,6 +453,7 @@ if command -v selinuxenabled &> /dev/null && selinuxenabled 2>/dev/null; then
fi
log_success "Agent binary installed to $AGENT_PATH"
+validate_agent_binary_executable "$AGENT_PATH"
# Build reusable agent command strings
AGENT_CMD="$AGENT_PATH --url $PULSE_URL"
@@ -466,6 +467,38 @@ fi
MANUAL_START_CMD="$AGENT_CMD"
MANUAL_START_WRAPPED="nohup $MANUAL_START_CMD >$LINUX_LOG_FILE 2>&1 &"
+validate_agent_binary_executable() {
+ local path="$1"
+ local mount_opts=""
+
+ if command -v findmnt >/dev/null 2>&1; then
+ mount_opts=$(findmnt -no OPTIONS --target "$path" 2>/dev/null || true)
+ if echo "$mount_opts" | grep -Eq '(^|,)noexec(,|$)'; then
+ log_error "Install target $path is on a filesystem mounted noexec (options: $mount_opts)"
+ echo ""
+ log_info "Enable exec on that dataset or choose an exec-capable path, then rerun the installer."
+ exit 1
+ fi
+ fi
+
+ if command -v file >/dev/null 2>&1; then
+ local file_type=""
+ file_type=$(file -b "$path" 2>/dev/null || true)
+ if [[ -n "$file_type" ]] && ! echo "$file_type" | grep -qiE 'ELF|Mach-O|PE32'; then
+ log_error "Downloaded file at $path is not a recognizable executable (detected: $file_type)"
+ exit 1
+ fi
+ fi
+
+ if ! "$path" --version >/dev/null 2>&1; then
+ log_error "Installed agent at $path failed to execute; check for noexec mounts or download issues."
+ if [[ -n "$mount_opts" ]]; then
+ log_info "Filesystem options: $mount_opts"
+ fi
+ exit 1
+ fi
+}
+
write_truenas_env_file() {
sudo install -d -m 0700 "$TRUENAS_STATE_DIR" "$TRUENAS_LOG_DIR"
local tmp_env
diff --git a/scripts/install-host-agent.sh b/scripts/install-host-agent.sh
index 75cfbbb561..05212d3c06 100755
--- a/scripts/install-host-agent.sh
+++ b/scripts/install-host-agent.sh
@@ -453,6 +453,7 @@ if command -v selinuxenabled &> /dev/null && selinuxenabled 2>/dev/null; then
fi
log_success "Agent binary installed to $AGENT_PATH"
+validate_agent_binary_executable "$AGENT_PATH"
# Build reusable agent command strings
AGENT_CMD="$AGENT_PATH --url $PULSE_URL"
@@ -466,6 +467,38 @@ fi
MANUAL_START_CMD="$AGENT_CMD"
MANUAL_START_WRAPPED="nohup $MANUAL_START_CMD >$LINUX_LOG_FILE 2>&1 &"
+validate_agent_binary_executable() {
+ local path="$1"
+ local mount_opts=""
+
+ if command -v findmnt >/dev/null 2>&1; then
+ mount_opts=$(findmnt -no OPTIONS --target "$path" 2>/dev/null || true)
+ if echo "$mount_opts" | grep -Eq '(^|,)noexec(,|$)'; then
+ log_error "Install target $path is on a filesystem mounted noexec (options: $mount_opts)"
+ echo ""
+ log_info "Enable exec on that dataset or choose an exec-capable path, then rerun the installer."
+ exit 1
+ fi
+ fi
+
+ if command -v file >/dev/null 2>&1; then
+ local file_type=""
+ file_type=$(file -b "$path" 2>/dev/null || true)
+ if [[ -n "$file_type" ]] && ! echo "$file_type" | grep -qiE 'ELF|Mach-O|PE32'; then
+ log_error "Downloaded file at $path is not a recognizable executable (detected: $file_type)"
+ exit 1
+ fi
+ fi
+
+ if ! "$path" --version >/dev/null 2>&1; then
+ log_error "Installed agent at $path failed to execute; check for noexec mounts or download issues."
+ if [[ -n "$mount_opts" ]]; then
+ log_info "Filesystem options: $mount_opts"
+ fi
+ exit 1
+ fi
+}
+
write_truenas_env_file() {
sudo install -d -m 0700 "$TRUENAS_STATE_DIR" "$TRUENAS_LOG_DIR"
local tmp_env