Initial upload to Gitea
This commit is contained in:
1 parent
78193254ad
commit
8478998cae
1485 files changed
+461025
-42348
No files matched your search
@@ -1,4 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
# -----------------------------------------------------------------------------
|
||||
# ADPanel runtime preparation (system user, sudoers policy, privileged runner,
|
||||
# panel-directory ownership).
|
||||
#
|
||||
# TRUST BOUNDARY: on a deployed system this file lives in the panel directory,
|
||||
# which is chown'd to the unprivileged 'adpanel' service user (see the chown
|
||||
# at the bottom), so anyone who controls the panel process can rewrite it.
|
||||
# It must therefore ONLY ever be run deliberately by the operator as root
|
||||
# ("sudo bash start.sh"). Service units and all automated paths must NEVER
|
||||
# execute it: initialize.sh performs the same preparation inline via its
|
||||
# prepare_panel_runtime_as_root() function, and re-executing this file as
|
||||
# root from a unit or scheduled task would run attacker-controlled code.
|
||||
# -----------------------------------------------------------------------------
|
||||
set -euo pipefail
|
||||
|
||||
echo "Preparing ADPanel runtime..."
|
||||
@@ -20,6 +33,11 @@ if ! id -u adpanel &>/dev/null; then
|
||||
fi
|
||||
fi
|
||||
|
||||
if id -u adpanel &>/dev/null; then
|
||||
mkdir -p /home/adpanel
|
||||
chown -R adpanel:adpanel /home/adpanel 2>/dev/null || true
|
||||
fi
|
||||
|
||||
if [ -d /etc/nginx/snippets ]; then
|
||||
chgrp adpanel /etc/nginx/snippets 2>/dev/null || true
|
||||
chmod g+w /etc/nginx/snippets 2>/dev/null || true
|
||||
@@ -65,6 +83,18 @@ if [ -f "$SUDOERS_SRC" ]; then
|
||||
fi
|
||||
|
||||
PANEL_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
|
||||
# Deploy the root-owned privileged runner + job scripts before the panel dir
|
||||
# chown, so they land root:root. The restricted sudoers policy only ever
|
||||
# allows: sudo -n /usr/local/lib/adpanel/adpanel-priv <op> [args].
|
||||
if [ "$(id -u)" -eq 0 ] && [ -f "${PANEL_DIR}/privileged/install-privileged.sh" ]; then
|
||||
if bash "${PANEL_DIR}/privileged/install-privileged.sh" "${PANEL_DIR}"; then
|
||||
echo "[setup] Privileged runner and restricted sudoers policy installed."
|
||||
else
|
||||
echo "[WARN] Privileged runner installation failed; database tool installs will not work." >&2
|
||||
fi
|
||||
fi
|
||||
|
||||
chown -R adpanel:adpanel "$PANEL_DIR" 2>/dev/null || true
|
||||
|
||||
echo "ADPanel runtime preparation complete."
|
||||
Reference in new issue
Block a user