Skip to content

[Bug] 脚本有 root 检测 bug 导致无限循环 #60

@MoonMao42

Description

@MoonMao42

OpenClaw Version | OpenClaw 版本

hermes v0.14

Plugin Version | 插件版本

0.3.4

Operating System | 操作系统

debian12

System Specification | 系统配置

4c4g

Describe the bug | 问题描述

su - $USERNAME$USERNAME 已经是 root 时,等于 su - root,执行后仍然是 root。 脚本被复制到临时文件后再次执行,再次命中 id -u == 0 的分支,无限循环。

第 36-38 行

USERNAME=$(whoami) # root 执行 → USERNAME="root"
USER_HOME=$(eval echo ~$USERNAME) # → "/root"

第 68-91 行

if [ "$(id -u)" -eq 0 ]; then
echo "[memory-tencentdb] Running as root, switching to $USERNAME for installation..."
# ...
su - $USERNAME -c "bash $TEMP_SCRIPT" </dev/null # su - root → 还是 root!
# ...
fi

To Reproduce | 复现步骤

  1. 以 root 身份登录服务器
  2. 执行:
    bash git clone https://github.com/Tencent/TencentDB-Agent-Memory.git cd TencentDB-Agent-Memory bash scripts/install_hermes_memory_tencentdb.sh
  3. 观察输出:同一行 "[memory-tencentdb] Running as root, switching to root for installation..." 被无限打印

Expected behavior | 预期行为

su - admin -c "bash install_hermes_memory_tencentdb.sh"
降级普通用户权限
或者增强报错显示:
以 root 执行,没指定目标用户→ 提示:
[ERROR] Running as root but no target user specified.
Set TARGET_USER= or run as the target user

Error Logs / Screenshots | 报错日志/截图

No response

Additional context | 补充信息

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions