Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Warning] Wrong code comments #82

Open
HRXWEB opened this issue Sep 12, 2024 · 3 comments
Open

[Warning] Wrong code comments #82

HRXWEB opened this issue Sep 12, 2024 · 3 comments

Comments

@HRXWEB
Copy link

HRXWEB commented Sep 12, 2024

代码所示

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

@HRXWEB HRXWEB changed the title Wrong code comments [Warning] Wrong code comments Sep 12, 2024
@fishros
Copy link
Owner

fishros commented Sep 12, 2024

之所以给所有用户都加上,因为有时候ROS用户会使用sudo运行,但是环境变量没有ros导致失败就给加上了,可以考虑去掉root用户,加选项应该不用,大多数都是单用户+root,没必要为可能1%不到的用户让99%的用户多一步选择交互。

@HRXWEB
Copy link
Author

HRXWEB commented Sep 13, 2024

emmm那就是1181行的注释问题,优先 两字就让人感觉有普通用户就不会添加root用户

@elysia-best
Copy link
Contributor

emmm那就是1181行的注释问题,优先 两字就让人感觉有普通用户就不会添加root用户

的确,可以修改成合适的描述。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants