Skip to content

[Warning] Wrong code comments #82

@HRXWEB

Description

@HRXWEB

代码所示

install/tools/base.py

Lines 1181 to 1198 in 05b0bb0

优先获取有home目录的普通用户, 没有普通用户则返回root
"""
users = []
# 遍历 /etc/passwd 文件来获取用户名和UID
with open('/etc/passwd', 'r') as passwd_file:
for line in passwd_file:
user_info = line.split(':')
username = user_info[0]
home_dir = user_info[5]
uid = int(user_info[2])
# 过滤出有home目录且UID大于等于1000的普通用户
if home_dir.startswith('/home') and uid >= 1000:
users.append(username)
users.append('root')
return users

users列表总是会添加root用户。

没有细看更多逻辑,是不是应该加个选项选择需要修改哪些用户的shell rc

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions