diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2013-08-16 16:44:02 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2013-08-16 16:44:02 +0800 |
commit | b8de7cfeb9bd530df15e5bbc695fb543df79402c (patch) | |
tree | 86d60e8b590c8303d086fa1433f41e8fa08d9ba9 | |
parent | 1ed420a0f4400c8bd9791fad9aec8f6add8aab00 (diff) | |
download | pttbbs-b8de7cfeb9bd530df15e5bbc695fb543df79402c.tar pttbbs-b8de7cfeb9bd530df15e5bbc695fb543df79402c.tar.gz pttbbs-b8de7cfeb9bd530df15e5bbc695fb543df79402c.tar.bz2 pttbbs-b8de7cfeb9bd530df15e5bbc695fb543df79402c.tar.lz pttbbs-b8de7cfeb9bd530df15e5bbc695fb543df79402c.tar.xz pttbbs-b8de7cfeb9bd530df15e5bbc695fb543df79402c.tar.zst pttbbs-b8de7cfeb9bd530df15e5bbc695fb543df79402c.zip |
Display password input as '*' when setting and changing passwords.
Sometimes people are confused about what exactly they've set for password
(especially when their terminal does not beep -- and they used lots of
invalid characters). Printing '*' when set/confirm new password should
be helpful. Also, it's more easier to set password without others watching
your screen.
Note login & transaction auth are still using NOECHO to keep max security.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk@5857 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | pttbbs/include/common.h | 2 | ||||
-rw-r--r-- | pttbbs/include/vtuikit.h | 4 | ||||
-rw-r--r-- | pttbbs/mbbsd/register.c | 6 | ||||
-rw-r--r-- | pttbbs/mbbsd/stuff.c | 2 | ||||
-rw-r--r-- | pttbbs/mbbsd/user.c | 6 | ||||
-rw-r--r-- | pttbbs/mbbsd/vtuikit.c | 12 |
6 files changed, 24 insertions, 8 deletions
diff --git a/pttbbs/include/common.h b/pttbbs/include/common.h index acc40357..eaa5112b 100644 --- a/pttbbs/include/common.h +++ b/pttbbs/include/common.h @@ -25,6 +25,7 @@ #define FN_WATER "water" // 舊水桶 #define FN_BANNED "banned" // 新水桶 #define FN_BANNED_HISTORY "banned.history" // 新水桶之歷史記錄 +#define FN_BADPOST_HISTORY "badpost.history" // 劣文歷史記錄 #define FN_CANVOTE "can_vote" #define FN_VISABLE "visable" // 不知道是誰拼錯的,將錯就錯吧... #define FN_ALOHAED "alohaed" // 上站要通知我的名單 (編輯用) @@ -160,6 +161,7 @@ #define LCECHO 2 #define NUMECHO 4 #define GCARRY 8 // (from M3) do not empty input buffer. +#define PASSECHO 0x10 #define YEA 1 /* Booleans (Yep, for true and false) */ #define NA 0 diff --git a/pttbbs/include/vtuikit.h b/pttbbs/include/vtuikit.h index 7fd83822..096ba0ef 100644 --- a/pttbbs/include/vtuikit.h +++ b/pttbbs/include/vtuikit.h @@ -69,9 +69,11 @@ #define VGET_ASCII_ONLY (0x10) #define VGET_NO_NAV_HISTORY (0x20) // disable UP/DOWN #define VGET_NO_NAV_EDIT (0x40) // disable LEFT/RIGHT/HOME/END/DEL +#define VGET_PASSWORD (0x80) // show only '*' #define VGETSET_DUMB_TERM (VGET_NO_NAV_HISTORY | VGET_NO_NAV_EDIT) -#define VGETSET_PASSWORD (VGET_NOECHO | VGET_ASCII_ONLY | VGETSET_DUMB_TERM) +#define VGETSET_NOECHO (VGET_NOECHO | VGET_ASCII_ONLY | VGETSET_DUMB_TERM) +#define VGETSET_PASSWORD (VGET_PASSWORD | VGET_ASCII_ONLY | VGETSET_DUMB_TERM) // DATATYPE DEFINITION ------------------------------------------------- typedef void * VREFSCR; diff --git a/pttbbs/mbbsd/register.c b/pttbbs/mbbsd/register.c index 7be58a89..4df77233 100644 --- a/pttbbs/mbbsd/register.c +++ b/pttbbs/mbbsd/register.c @@ -622,17 +622,17 @@ new_register(void) } move(20, 0); clrtoeol(); outs(ANSI_COLOR(1;33) - "為避免被偷看,您的密碼並不會顯示在畫面上,直接輸入完後按 Enter 鍵即可。\n" + "為避免被偷看,您的密碼會顯示為 * ,直接輸入完後按 Enter 鍵即可。\n" "另外請注意密碼只有前八個字元有效,超過的將自動忽略。" ANSI_RESET); if ((getdata(18, 0, "請設定密碼:", passbuf, - sizeof(passbuf), NOECHO) < 3) || + sizeof(passbuf), PASSECHO) < 3) || !strcmp(passbuf, newuser.userid)) { outs("密碼太簡單,易遭入侵,至少要 4 個字,請重新輸入\n"); continue; } strlcpy(newuser.passwd, passbuf, PASSLEN); - getdata(19, 0, "請確認密碼:", passbuf, sizeof(passbuf), NOECHO); + getdata(19, 0, "請確認密碼:", passbuf, sizeof(passbuf), PASSECHO); if (strncmp(passbuf, newuser.passwd, PASSLEN)) { move(19, 0); outs("設定與確認時輸入的密碼不一致, 請重新輸入密碼.\n"); diff --git a/pttbbs/mbbsd/stuff.c b/pttbbs/mbbsd/stuff.c index 095e31e1..704d7e7c 100644 --- a/pttbbs/mbbsd/stuff.c +++ b/pttbbs/mbbsd/stuff.c @@ -385,6 +385,8 @@ getdata2vgetflag(int echo) else if (echo == NUMECHO) echo = VGET_DIGITS; else if (echo == NOECHO) + echo = VGETSET_NOECHO; + else if (echo == PASSECHO) echo = VGETSET_PASSWORD; else echo = VGET_DEFAULT; diff --git a/pttbbs/mbbsd/user.c b/pttbbs/mbbsd/user.c index 6563c126..f4b97a95 100644 --- a/pttbbs/mbbsd/user.c +++ b/pttbbs/mbbsd/user.c @@ -1016,14 +1016,14 @@ uinfo_query(const char *orig_uid, int adminmode, int unum) case '2': y = 19; if (!adminmode) { - if (!getdata(y++, 0, "請輸入原密碼:", buf, PASSLEN, NOECHO) || + if (!getdata(y++, 0, "請輸入原密碼:", buf, PASSLEN, PASSECHO) || !checkpasswd(x.passwd, buf)) { outs("\n\n您輸入的密碼不正確\n"); fail++; break; } } - if (!getdata(y++, 0, "請設定新密碼:", buf, PASSLEN, NOECHO)) { + if (!getdata(y++, 0, "請設定新密碼:", buf, PASSLEN, PASSECHO)) { outs("\n\n密碼設定取消, 繼續使用舊密碼\n"); fail++; break; @@ -1033,7 +1033,7 @@ uinfo_query(const char *orig_uid, int adminmode, int unum) move(y+1, 0); outs("請注意設定密碼只有前八個字元有效,超過的將自動忽略。"); - getdata(y++, 0, "請檢查新密碼:", buf, PASSLEN, NOECHO); + getdata(y++, 0, "請檢查新密碼:", buf, PASSLEN, PASSECHO); if (strncmp(buf, genbuf, PASSLEN)) { outs("\n\n新密碼確認失敗, 無法設定新密碼\n"); fail++; diff --git a/pttbbs/mbbsd/vtuikit.c b/pttbbs/mbbsd/vtuikit.c index 6487314a..2cf5d283 100644 --- a/pttbbs/mbbsd/vtuikit.c +++ b/pttbbs/mbbsd/vtuikit.c @@ -1228,7 +1228,17 @@ vgetstring(char *_buf, int len, int flags, const char *defstr, const VGET_CALLBA if (!(flags & VGET_TRANSPARENT)) outs(VCLR_INPUT_FIELD); // change color to prompt fields - vfill(len, 0, buf); + if (flags & VGET_PASSWORD) { + int i; + for (i = 0; i < rt.iend; i++) { + outc('*'); + } + for (; i < len; i++) { + outc(' '); + } + } else { + vfill(len, 0, buf); + } if (!(flags & VGET_TRANSPARENT)) outs(ANSI_RESET); |