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

Parse logins.bad #29

Closed
ifanchu opened this issue Jan 1, 2021 · 2 comments
Closed

Parse logins.bad #29

ifanchu opened this issue Jan 1, 2021 · 2 comments
Assignees

Comments

@ifanchu
Copy link
Contributor

ifanchu commented Jan 1, 2021

logins.bad 有兩種,一個在BBSHOME,一個在User下面
https://github.com/ptt/pttbbs/blob/master/include/common.h#L56
https://github.com/ptt/pttbbs/blob/master/common/bbs/passwd.c#L255

/logins.bad: 這個檔裡有每個 user的login attempt且包含成功與失敗。第一個字元若是"-"代表失敗。

 test03      [01/01/2021 10:11:45 Fri] ?@172.22.0.1
 test04      [01/01/2021 10:13:35 Fri] ?@172.22.0.1
 test05      [01/01/2021 10:13:45 Fri] ?@172.22.0.1
 SYSOP       [01/01/2021 10:13:53 Fri] ?@172.22.0.1
 test06      [01/01/2021 10:14:38 Fri] ?@172.22.0.1
 SYSOP       [01/01/2021 10:14:46 Fri] ?@172.22.0.1
-test01      [01/01/2021 10:15:16 Fri] ?@172.22.0.1
-test02      [01/01/2021 10:15:19 Fri] ?@172.22.0.1
-test03      [01/01/2021 10:15:22 Fri] ?@172.22.0.1
 test04      [01/01/2021 10:15:38 Fri] ?@172.22.0.1

home///logins.bad: 這個檔裡只有該user的 失敗 login attempt

╰─➤  cat home/T/test01/logins.bad
[01/01/2021 10:15:16 Fri] 172.22.0.1

目前我的想法是用同一個struct來parse這2種logins.bad

type LoginAttempt struct {
	Success        bool
	UserId         string
	LoginStartTime time.Time
	FromHost       string
}

For /logins.bad ,這個檔裡四個field都有,所以沒問題。
但在user/logins.bad,缺少 UserId ,所以parse出來的struct就沒有 UserId,需要caller assign

@ifanchu
Copy link
Contributor Author

ifanchu commented Jan 1, 2021

@PichuChen
Copy link
Member

差別應該在全站的不會刪掉,但是個人的可以自行刪掉這樣吧?

@ifanchu ifanchu closed this as completed Jan 1, 2021
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

2 participants