Skip to content
This repository has been archived by the owner on Feb 11, 2022. It is now read-only.

主机信息中 userlist 会缺失部分 user #45

Open
aRe00t opened this issue May 16, 2018 · 4 comments
Open

主机信息中 userlist 会缺失部分 user #45

aRe00t opened this issue May 16, 2018 · 4 comments

Comments

@aRe00t
Copy link

aRe00t commented May 16, 2018

你好, 我新建用户后发现 userlist 中看不到新用户.
reload agent 过了一段时间后仍看不到, 但同时该主机的 crontab/listening/process 信息能正确更新.

我对比了另外一台机器的 /etc/passwd 和web界面中的 userlist, 发现 userlist 少了3个用户.

@yeahx
Copy link

yeahx commented May 16, 2018

nologin的用户不会被记录吧。

@aRe00t
Copy link
Author

aRe00t commented May 16, 2018

我对比时发现不会记录 nologin 用户, 但缺的几个用户都是 /bin/bash 的.

@cloudfstrife
Copy link

agent/collect/user_linux.go第17到20行

userList := strings.Split(string(dat), "\n")
if len(userList) < 2 {
	return
}
for _, info := range userList[0 : len(userList)-2] {
……
}

不太理解这个逻辑,这里为什么要在小于2行时,直接返回,也不取最后两行

@icxcoffee
Copy link
Contributor

nologin用户是不会被监控到的,将如下代码

for _, info := range userList[0 : len(userList)-2] {

改为

for _, info := range userList[0 : len(userList)-1] {

即可,否则会漏掉一个user用户

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

No branches or pull requests

4 participants