summaryrefslogtreecommitdiffstats
path: root/mbbsd/mbbsd.c
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2009-06-06 22:24:50 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2009-06-06 22:24:50 +0800
commit2cf681116231eb085a985917ae19188f06dc041e (patch)
tree43a55cb156587c9451d27ea3aaaa1a0ad9e51a5c /mbbsd/mbbsd.c
parent9c4e5e52c6b9de0ff0873fd76a3d187a19fb45da (diff)
downloadpttbbs-2cf681116231eb085a985917ae19188f06dc041e.tar
pttbbs-2cf681116231eb085a985917ae19188f06dc041e.tar.gz
pttbbs-2cf681116231eb085a985917ae19188f06dc041e.tar.bz2
pttbbs-2cf681116231eb085a985917ae19188f06dc041e.tar.lz
pttbbs-2cf681116231eb085a985917ae19188f06dc041e.tar.xz
pttbbs-2cf681116231eb085a985917ae19188f06dc041e.tar.zst
pttbbs-2cf681116231eb085a985917ae19188f06dc041e.zip
- refine and prepare for login daemon:
* change str_guest and str_new to macro definition names * make passwd utilites (check, verify, ...) available in util_passwd * make logattemtp() use assigned time and host. git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4498 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/mbbsd.c')
-rw-r--r--mbbsd/mbbsd.c51
1 files changed, 13 insertions, 38 deletions
diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c
index d3dfe234..c5bc0e83 100644
--- a/mbbsd/mbbsd.c
+++ b/mbbsd/mbbsd.c
@@ -657,35 +657,6 @@ multi_user_check(void)
}
}
-/* bad login */
-static char * const str_badlogin = "logins.bad";
-
-static void
-logattempt(const char *uid, char type)
-{
- char fname[40];
- int fd, len;
- char genbuf[200];
-
- snprintf(genbuf, sizeof(genbuf), "%c%-12s[%s] ?@%s\n", type, uid,
- Cdate(&login_start_time), fromhost);
- len = strlen(genbuf);
- if ((fd = open(str_badlogin, O_WRONLY | O_CREAT | O_APPEND, 0644)) > 0) {
- write(fd, genbuf, len);
- close(fd);
- }
- if (type == '-') {
- snprintf(genbuf, sizeof(genbuf),
- "[%s] %s\n", Cdate(&login_start_time), fromhost);
- len = strlen(genbuf);
- sethomefile(fname, uid, str_badlogin);
- if ((fd = open(fname, O_WRONLY | O_CREAT | O_APPEND, 0644)) > 0) {
- write(fd, genbuf, len);
- close(fd);
- }
- }
-}
-
void mkuserdir(const char *userid)
{
char genbuf[PATHLEN];
@@ -759,17 +730,21 @@ login_query(void)
uid[IDLEN] = 0;
#endif
- if (strcasecmp(uid, str_new) == 0) {
-#ifdef LOGINASNEW
+#ifdef STR_REGNEW
+ if (strcasecmp(uid, STR_REGNEW) == 0) {
+# ifdef LOGINASNEW
new_register();
mkuserdir(cuser.userid);
reginit_fav();
break;
-#else
- outs("本系統目前無法以 new 註冊, 請用 guest 進入\n");
+# else // !LOGINASNEW
+ outs("本系統目前無法以 " STR_REGNEW " 註冊, 請用 guest 進入\n");
continue;
-#endif
- } else if (!is_validuserid(uid)) {
+# endif // !LOGINASNEW
+ } else
+#endif // STR_REGNEW
+
+ if (!is_validuserid(uid)) {
outs(err_uid);
@@ -804,13 +779,13 @@ login_query(void)
!checkpasswd(cuser.passwd, passbuf) ){
if(is_validuserid(cuser.userid))
- logattempt(cuser.userid , '-');
+ logattempt(cuser.userid , '-', login_start_time, fromhost);
sleep(1);
outs(ERR_PASSWD);
} else {
- logattempt(cuser.userid, ' ');
+ logattempt(cuser.userid, ' ', login_start_time, fromhost);
outs("密碼正確! 開始登入系統...");
move(22, 0); refresh();
clrtoeol();
@@ -1079,7 +1054,7 @@ inline static void welcome_msg(void)
inline static void check_bad_login(void)
{
char genbuf[200];
- setuserfile(genbuf, str_badlogin);
+ setuserfile(genbuf, FN_BADLOGIN);
if (more(genbuf, NA) != -1) {
move(b_lines - 3, 0);
outs("通常並沒有辦法知道該ip是誰所有, "