yulong-hids-archived icon indicating copy to clipboard operation
yulong-hids-archived copied to clipboard

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

Open aRe00t opened this issue 6 years ago • 4 comments

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

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

aRe00t avatar May 16 '18 04:05 aRe00t

nologin的用户不会被记录吧。

yeahx avatar May 16 '18 06:05 yeahx

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

aRe00t avatar May 16 '18 06:05 aRe00t

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行时,直接返回,也不取最后两行

cloudfstrife avatar Oct 31 '18 10:10 cloudfstrife

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

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

改为

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

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

icxcoffee avatar Nov 14 '18 08:11 icxcoffee