diff options
author | victor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-10-23 20:16:16 +0800 |
---|---|---|
committer | victor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-10-23 20:16:16 +0800 |
commit | 69165fe96c9c6ed04697bc61d75196bf7454636d (patch) | |
tree | 73a4f43d41033ef1fdf6557b37916c3b7b723f40 | |
parent | 1c5a0fc6fa4328436c2737d7ebc6f84f875c5a10 (diff) | |
download | pttbbs-69165fe96c9c6ed04697bc61d75196bf7454636d.tar pttbbs-69165fe96c9c6ed04697bc61d75196bf7454636d.tar.gz pttbbs-69165fe96c9c6ed04697bc61d75196bf7454636d.tar.bz2 pttbbs-69165fe96c9c6ed04697bc61d75196bf7454636d.tar.lz pttbbs-69165fe96c9c6ed04697bc61d75196bf7454636d.tar.xz pttbbs-69165fe96c9c6ed04697bc61d75196bf7454636d.tar.zst pttbbs-69165fe96c9c6ed04697bc61d75196bf7454636d.zip |
WARNING
revise userec_t structure
(enlarge numpost, numlogins, and add column "version")
provide util/passwdconverter to help the convertion
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2273 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | include/proto.h | 1 | ||||
-rw-r--r-- | include/pttstruct.h | 13 | ||||
-rw-r--r-- | util/Makefile | 3 | ||||
-rw-r--r-- | util/passwdconverter.c | 146 |
4 files changed, 158 insertions, 5 deletions
diff --git a/include/proto.h b/include/proto.h index 68b39f86..8b1f1927 100644 --- a/include/proto.h +++ b/include/proto.h @@ -50,6 +50,7 @@ int inc_badsale(char *, int num); /* bbs */ int invalid_brdname(char *brd); +void chomp(char *src); int del_range(int ent, fileheader_t *fhdr, char *direct); int cmpfowner(fileheader_t *fhdr); int b_note_edit_bname(int bid); diff --git a/include/pttstruct.h b/include/pttstruct.h index c6bf8107..ddf78fe3 100644 --- a/include/pttstruct.h +++ b/include/pttstruct.h @@ -52,14 +52,18 @@ typedef struct chicken_t { #define REGLEN 38 /* Length of registration data */ typedef struct userec_t { + unsigned int version; /* version number of this sturcture, we + * use revision number of project to denote.*/ + char userid[IDLEN + 1]; char realname[20]; char username[24]; char passwd[PASSLEN]; - unsigned char uflag; + unsigned int uflag; + unsigned int uflag2; unsigned int userlevel; - unsigned short numlogins; - unsigned short numposts; + unsigned int numlogins; + unsigned int numposts; time_t firstlogin; time_t lastlogin; char lasthost[16]; @@ -91,7 +95,6 @@ typedef struct userec_t { int mobile; char mind[4]; char ident[11]; - unsigned int uflag2; unsigned char signature; unsigned char goodpost; /* 評價為好文章數 */ @@ -101,7 +104,7 @@ typedef struct userec_t { char myangel[IDLEN+1]; /* 我的小天使 */ unsigned short chess_elo_rating; /* 象棋等級分 */ unsigned int withme; - char pad[48]; + char pad[34]; } userec_t; /* these are flags in userec_t.uflag */ #define PAGER_FLAG 0x4 /* true if pager was OFF last session */ diff --git a/util/Makefile b/util/Makefile index a4ee5cc9..eb148ca9 100644 --- a/util/Makefile +++ b/util/Makefile @@ -106,3 +106,6 @@ r2014transfer: r2014convert $(CCACHE) ${CC} ${CFLAGS} ${LDFLAGS} -o r2014convert r2014convert.c ./r2014convert rm r2014convert + +passwdconverter: passwdconverter.c + $(CCACHE) $(CC) $(CFLAGS) $(LDFLAGS) $(UTIL_OBJS) -o passwdconverter passwdconverter.c diff --git a/util/passwdconverter.c b/util/passwdconverter.c new file mode 100644 index 00000000..74cf8700 --- /dev/null +++ b/util/passwdconverter.c @@ -0,0 +1,146 @@ +#include "bbs.h" + +/* userec_t before revision 2275 */ +typedef struct old_userec_t { + char userid[IDLEN + 1]; + char realname[20]; + char username[24]; + char passwd[PASSLEN]; + unsigned char uflag; + unsigned int userlevel; + unsigned short numlogins; + unsigned short numposts; + time_t firstlogin; + time_t lastlogin; + char lasthost[16]; + int money; + char remoteuser[3]; /* 靽 桀瘝典啁 */ + char proverb; + char email[50]; + char address[50]; + char justify[REGLEN + 1]; + unsigned char month; + unsigned char day; + unsigned char year; + unsigned char sex; + unsigned char state; + unsigned char pager; + unsigned char invisible; + unsigned int exmailbox; + chicken_t mychicken; + time_t lastsong; + unsigned int loginview; + unsigned char channel; /* (unused?) */ + unsigned short vl_count; /* ViolateLaw counter */ + unsigned short five_win; + unsigned short five_lose; + unsigned short five_tie; + unsigned short chc_win; + unsigned short chc_lose; + unsigned short chc_tie; + int mobile; + char mind[4]; + char ident[11]; + unsigned int uflag2; + unsigned char signature; + + unsigned char goodpost; /* 閰寧箏末蝡 */ + unsigned char badpost; /* 閰寧箏蝡 */ + unsigned char goodsale; /* 蝡嗆 憟賜閰 */ + unsigned char badsale; /* 蝡嗆 憯閰 */ + char myangel[IDLEN+1]; /* 撠憭拐蝙 */ + unsigned short chess_elo_rating; /* 鞊⊥蝑蝝 */ + unsigned int withme; + char pad[48]; +} old_userec_t; + +void transform(userec_t *new, old_userec_t *old) +{ + new->version = 2275; + + strlcpy(new->userid, old->userid, IDLEN + 1); + strlcpy(new->realname, old->realname, 20); + strlcpy(new->username, old->username, 24); + strlcpy(new->passwd, old->passwd, PASSLEN); + new->uflag = old->uflag; + new->userlevel = old->userlevel; + new->numlogins = old->numlogins; + new->numposts = old->numposts; + new->firstlogin = old->firstlogin; + new->lastlogin = old->lastlogin; + strlcpy(new->lasthost, old->lasthost, 16); + new->money = old->money; + strlcpy(new->remoteuser, old->remoteuser, 3); + new->proverb = old->proverb; + strlcpy(new->email, old->email, 50); + strlcpy(new->address, old->address, 50); + strlcpy(new->justify, old->justify, REGLEN + 1); + new->month = old->month; + new->day = old->day; + new->year = old->year; + new->sex = old->sex; + new->state = old->state; + new->pager = old->pager; + new->invisible = old->invisible; + new->exmailbox = old->exmailbox; + new->mychicken = old->mychicken; + new->lastsong = old->lastsong; + new->loginview = old->loginview; + new->channel = old->channel; + new->vl_count = old->vl_count; + new->five_win = old->five_win; + new->five_lose = old->five_lose; + new->five_tie = old->five_tie; + new->chc_win = old->chc_win; + new->chc_lose = old->chc_lose; + new->chc_tie = old->chc_tie; + new->mobile = old->mobile; + strlcpy(new->mind, old->mind, 4); + strlcpy(new->ident, old->ident, 11); + new->uflag2 = old->uflag2; + new->signature = old->signature; + + new->goodpost = old->goodpost; + new->badpost = old->badpost; + new->goodsale = old->goodsale; + new->badsale = old->badsale; + strlcpy(new->myangel, old->myangel, IDLEN+1); + new->chess_elo_rating = old->chess_elo_rating; + new->withme = old->withme; + memset(new->pad, 0, sizeof(new->pad)); +} + +int main(void) +{ + int fd, fdw; + userec_t new; + old_userec_t old; + + printf("You're going to convert your .PASSWDS\n"); + printf("The new file will be named .PASSWDS.trans.tmp\n"); + printf("old size of userec_t is %d, and the new one is %d\n", sizeof(old_userec_t), sizeof(userec_t)); +/* + printf("Press any key to continue\n"); + getchar(); +*/ + + if (chdir(BBSHOME) < 0) { + perror("chdir"); + exit(-1); + } + + if ((fd = open(FN_PASSWD, O_RDONLY)) < 0 || + (fdw = open(FN_PASSWD".trans.tmp", O_WRONLY | O_CREAT | O_TRUNC, 0600)) < 0 ) { + perror("open"); + exit(-1); + } + + while (read(fd, &old, sizeof(old)) > 0) { + transform(&new, &old); + write(fdw, &new, sizeof(new)); + } + + close(fd); + close(fdw); + return 0; +} |