Logic to check root incorrect in agent.sh running on Chinese version of Ubuntu (OD-2538)
juyss opened 4 months ago

系统为Ubuntu20.04,系统语言设置的中文。把agent作为系统服务运行时,执行 agent.sh脚本判断是否为root用户的时候,id 命令的输出是中文的“用户id=0”,而不是英文的 "uid=0",导致错误的认为当前用户不是root用户,实际上是root用户。
下面是AI的判断截图和修改方案 PixPin_2025-08-25_04-57-53.png PixPin_2025-08-25_05-05-13.png

  • juyss commented 4 months ago
    	checkIsRoot() {
    	    # 使用 'id -u' 命令直接获取 UID,这是最可靠的方式,不受系统语言影响
    	    if [ `id -u` != "0" ] ; then
    	        IS_ROOT=false
    	    else
    	        IS_ROOT=true
    	    fi
    	}
    
  • Robin Shen changed title 4 months ago
    Previous Value Current Value
    agent脚本agent.sh中判断是否为root用户的逻辑有问题
    Logic to check root incorrect in agent.sh running on Chinese version of Ubuntu
  • OneDev commented 4 months ago

    State changed as code fixing the issue is committed (afddedc3)

  • OneDev changed state to 'Closed' 4 months ago
    Previous Value Current Value
    Open
    Closed
  • OneDev commented 4 months ago

    State changed as build OD-6587 is successful

  • OneDev changed state to 'Released' 4 months ago
    Previous Value Current Value
    Closed
    Released
issue 1/1
Type
Bug
Priority
Normal
Assignee
Affected Versions
OneDev 12.0.4
Labels
No labels
Issue Votes (0)
Watchers (3)
Reference
OD-2538
Please wait...
Connection lost or session expired, reload to recover
Page is in error, reload to recover