diff options
-rw-r--r-- | pttbbs/common/bbs/passwd.c | 18 | ||||
-rw-r--r-- | pttbbs/include/cmbbs.h | 1 |
2 files changed, 19 insertions, 0 deletions
diff --git a/pttbbs/common/bbs/passwd.c b/pttbbs/common/bbs/passwd.c index 0318bc83..acc2813e 100644 --- a/pttbbs/common/bbs/passwd.c +++ b/pttbbs/common/bbs/passwd.c @@ -185,6 +185,24 @@ passwd_apply(void *ctx, int (*fptr) (void *ctx, int, userec_t *)) return 0; } +int +passwd_fast_apply(void *ctx, int(*fptr)(void *ctx, int, userec_t *)) +{ + int i, fd; + userec_t user; + if ((fd = open(fn_passwd, O_RDONLY)) < 0) + exit(1); + for (i = 0; i < MAX_USERS; i++) { + memset(&user, 0, sizeof(user)); + if (read(fd, &user, sizeof(user)) != sizeof(user)) + return -1; + if ((*fptr) (ctx, i, &user) < 0) + return -1; + } + close(fd); + return 0; +} + // XXX NOTE: string in plain will be destroyed. int checkpasswd(const char *passwd, char *plain) diff --git a/pttbbs/include/cmbbs.h b/pttbbs/include/cmbbs.h index 5e6b8cbf..9d5bab43 100644 --- a/pttbbs/include/cmbbs.h +++ b/pttbbs/include/cmbbs.h @@ -106,6 +106,7 @@ int passwd_update(int num, userec_t *buf); int passwd_query (int num, userec_t *buf); int passwd_load_user(const char *userid, userec_t *buf); int passwd_apply (void *data, int (*fptr)(void *, int, userec_t *)); +int passwd_fast_apply(void *ctx, int(*fptr)(void *ctx, int, userec_t *)); int checkpasswd (const char *passwd, char *test); // test will be destroyed void logattempt (const char *uid, char type, time4_t now, const char *fromhost); char*genpasswd (char *pw); |