Files
Nexus/docs/changelog/2026-06-01-files-browse-sudo-fallback.md
2026-07-08 22:31:31 +08:00

34 lines
1.3 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 2026-06-01 文件浏览目录 sudo 提权回退
## 日期
2026-06-01
## 变更摘要
`POST /api/sync/browse` 与写文件/chmod 一致,在 `files_elevation=auto_sudo`(默认)且 `ls` 遇 Permission denied 时自动 `sudo -n bash -c`
## 动机
- 非 root SSH 用户无法直接 `ls /www/wwwroot`,前端表现为「暂无文件」
- 浏览此前仅用 `exec_ssh_command`,**从未走 sudo**;与「去掉 sudo」无关,应**启用**提权而非关闭
## 涉及文件
- `server/api/sync_v2.py``browse_directory`
- `frontend/src/utils/fileMode.ts` — 提示文案含「浏览」
## 迁移 / 重启
-`supervisorctl restart nexus` 部署后端
## 验证方式
1. 服务器 SSH 用户为非 root`files_elevation``auto_sudo`(默认)
2. 目标机已安装 `docs/deploy/nexus-files-sudoers.example`(含 bash
3. 打开 `#/files?server_id=8`,应列出 `/www/wwwroot` 内容
## 运维说明(不要关掉 sudo
| 策略 | 适用 |
|------|------|
| `auto_sudo`(推荐) | 先普通 `ls`,失败再 sudo |
| `off` | 仅当 SSH 已是 root 或目录对当前用户可读 |
| `always_sudo` | 所有命令先 sudo;sudoers 未配全时反而更易失败 |
`always_sudo` 且 sudo 未配好:在「服务器」编辑里改回 **自动提权 (auto_sudo)**,并安装 sudoers 示例。