67dac0168f
Co-authored-by: Cursor <cursoragent@cursor.com>
1.3 KiB
1.3 KiB
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_directoryfrontend/src/utils/fileMode.ts— 提示文案含「浏览」
迁移 / 重启
- 需
supervisorctl restart nexus部署后端
验证方式
- 服务器 SSH 用户为非 root,
files_elevation为auto_sudo(默认) - 目标机已安装
docs/deploy/nexus-files-sudoers.example(含 bash) - 打开
#/files?server_id=8,应列出/www/wwwroot内容
运维说明(不要关掉 sudo)
| 策略 | 适用 |
|---|---|
auto_sudo(推荐) |
先普通 ls,失败再 sudo |
off |
仅当 SSH 已是 root 或目录对当前用户可读 |
always_sudo |
所有命令先 sudo;sudoers 未配全时反而更易失败 |
若 always_sudo 且 sudo 未配好:在「服务器」编辑里改回 自动提权 (auto_sudo),并安装 sudoers 示例。