Fix WORK_DIR override: config file was clobbering detect_mode

The settings screen wrote WORK_DIR="/usr/local/gniza/workdir" (root-mode
path) into gniza.conf. load_config then overrode the correct user-mode
path set by detect_mode, causing mktemp and rsync log redirects to fail
with Permission denied — crashing the bash script while rsync continued
as an orphan.

- Remove WORK_DIR from AppSettings model and settings screen
- Re-run detect_mode after config load to restore correct paths
- Removed stale WORK_DIR from user's gniza.conf

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
shuki
2026-03-06 21:14:14 +02:00
parent 58819abcd4
commit ae1563396c
3 changed files with 4 additions and 8 deletions

View File

@@ -56,8 +56,10 @@ load_config() {
RSYNC_EXTRA_OPTS="${RSYNC_EXTRA_OPTS:-}" RSYNC_EXTRA_OPTS="${RSYNC_EXTRA_OPTS:-}"
DISK_USAGE_THRESHOLD="${DISK_USAGE_THRESHOLD:-$DEFAULT_DISK_USAGE_THRESHOLD}" DISK_USAGE_THRESHOLD="${DISK_USAGE_THRESHOLD:-$DEFAULT_DISK_USAGE_THRESHOLD}"
# WORK_DIR can be overridden in config; re-export if changed # WORK_DIR from detect_mode takes precedence — ignore config value
export WORK_DIR # to prevent root-mode paths leaking into user-mode sessions.
# Re-run detect_mode to restore the correct value if config overrode it.
detect_mode
# --debug flag overrides config # --debug flag overrides config
[[ "${GNIZA4LINUX_DEBUG:-false}" == "true" ]] && LOG_LEVEL="debug" [[ "${GNIZA4LINUX_DEBUG:-false}" == "true" ]] && LOG_LEVEL="debug"

View File

@@ -206,7 +206,6 @@ class AppSettings:
ssh_retries: str = "3" ssh_retries: str = "3"
rsync_extra_opts: str = "" rsync_extra_opts: str = ""
disk_usage_threshold: str = "95" disk_usage_threshold: str = "95"
work_dir: str = "/usr/local/gniza/workdir"
web_port: str = "2323" web_port: str = "2323"
web_host: str = "0.0.0.0" web_host: str = "0.0.0.0"
web_api_key: str = "" web_api_key: str = ""
@@ -231,7 +230,6 @@ class AppSettings:
ssh_retries=data.get("SSH_RETRIES", "3"), ssh_retries=data.get("SSH_RETRIES", "3"),
rsync_extra_opts=data.get("RSYNC_EXTRA_OPTS", ""), rsync_extra_opts=data.get("RSYNC_EXTRA_OPTS", ""),
disk_usage_threshold=data.get("DISK_USAGE_THRESHOLD", "95"), disk_usage_threshold=data.get("DISK_USAGE_THRESHOLD", "95"),
work_dir=data.get("WORK_DIR", "/usr/local/gniza/workdir"),
web_port=data.get("WEB_PORT", "2323"), web_port=data.get("WEB_PORT", "2323"),
web_host=data.get("WEB_HOST", "0.0.0.0"), web_host=data.get("WEB_HOST", "0.0.0.0"),
web_api_key=data.get("WEB_API_KEY", ""), web_api_key=data.get("WEB_API_KEY", ""),
@@ -256,7 +254,6 @@ class AppSettings:
"SSH_RETRIES": self.ssh_retries, "SSH_RETRIES": self.ssh_retries,
"RSYNC_EXTRA_OPTS": self.rsync_extra_opts, "RSYNC_EXTRA_OPTS": self.rsync_extra_opts,
"DISK_USAGE_THRESHOLD": self.disk_usage_threshold, "DISK_USAGE_THRESHOLD": self.disk_usage_threshold,
"WORK_DIR": self.work_dir,
"WEB_PORT": self.web_port, "WEB_PORT": self.web_port,
"WEB_HOST": self.web_host, "WEB_HOST": self.web_host,
"WEB_API_KEY": self.web_api_key, "WEB_API_KEY": self.web_api_key,

View File

@@ -61,8 +61,6 @@ class SettingsScreen(Screen):
yield Input(value=settings.ssh_retries, id="set-sshretries") yield Input(value=settings.ssh_retries, id="set-sshretries")
yield Static("Extra rsync options:") yield Static("Extra rsync options:")
yield Input(value=settings.rsync_extra_opts, id="set-rsyncopts") yield Input(value=settings.rsync_extra_opts, id="set-rsyncopts")
yield Static("Work Directory:")
yield Input(value=settings.work_dir, placeholder="/usr/local/gniza/workdir", id="set-workdir")
yield Static("Web Dashboard", classes="section-label") yield Static("Web Dashboard", classes="section-label")
yield Static("Port:") yield Static("Port:")
yield Input(value=settings.web_port, id="set-web-port") yield Input(value=settings.web_port, id="set-web-port")
@@ -103,7 +101,6 @@ class SettingsScreen(Screen):
ssh_retries=self.query_one("#set-sshretries", Input).value.strip() or "3", ssh_retries=self.query_one("#set-sshretries", Input).value.strip() or "3",
rsync_extra_opts=self.query_one("#set-rsyncopts", Input).value.strip(), rsync_extra_opts=self.query_one("#set-rsyncopts", Input).value.strip(),
disk_usage_threshold=self.query_one("#set-diskthreshold", Input).value.strip() or "95", disk_usage_threshold=self.query_one("#set-diskthreshold", Input).value.strip() or "95",
work_dir=self.query_one("#set-workdir", Input).value.strip() or "/usr/local/gniza/workdir",
web_port=self.query_one("#set-web-port", Input).value.strip() or "2323", web_port=self.query_one("#set-web-port", Input).value.strip() or "2323",
web_host=self.query_one("#set-web-host", Input).value.strip() or "0.0.0.0", web_host=self.query_one("#set-web-host", Input).value.strip() or "0.0.0.0",
web_api_key=self.query_one("#set-web-key", Input).value, web_api_key=self.query_one("#set-web-key", Input).value,