From 0d1688520003011abbcb9c37074f2c2dce88f72a Mon Sep 17 00:00:00 2001 From: scw Date: Mon, 24 May 2004 00:31:48 +0000 Subject: Merge from scw.angel. *NOTE* Before running this revision, please read PttCurrent board at telnet://ptt.cc or http://scwg.wiki.ptt.cc/-Angel git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2014 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- util/Makefile | 5 +++++ util/bbsmail.c | 2 +- util/r2014convert.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 util/r2014convert.c (limited to 'util') diff --git a/util/Makefile b/util/Makefile index 99ff62af..04c0d4cc 100644 --- a/util/Makefile +++ b/util/Makefile @@ -97,3 +97,8 @@ installbbsctl: bbsctl cleanpasswd: cleanpasswd.c ${UTIL_OBJS} ${CC} ${CFLAGS} ${LDFLAGS} -o cleanpasswd ${UTIL_OBJS} cleanpasswd.c + +r2014transfer: r2014convert + ${CC} ${CFLAGS} ${LDFLAGS} -o r2014convert r2014convert.c + ./r2014convert + rm r2014convert diff --git a/util/bbsmail.c b/util/bbsmail.c index 2ca997b8..24065ef1 100644 --- a/util/bbsmail.c +++ b/util/bbsmail.c @@ -93,7 +93,7 @@ int mail2bbs(char *userid) return -1;//EX_NOUSER; } - if( xuser.userlevel & PERM_NOOUTMAIL ) + if( xuser.uflag2 & REJ_OUTTAMAIL ) return -1; //不接受站外信 sprintf(filename, BBSHOME "/home/%c/%s", userid[0], userid); diff --git a/util/r2014convert.c b/util/r2014convert.c new file mode 100644 index 00000000..7609cee4 --- /dev/null +++ b/util/r2014convert.c @@ -0,0 +1,63 @@ +#include "bbs.h" + +int main(){ + int orig_fd, new_fd; + userec_t u; + int count = 0; + + orig_fd = open(BBSHOME "/.AngelTrans", O_WRONLY | O_CREAT | O_EXCL, 0600); + if (orig_fd == -1) { + if (errno == EEXIST) { + char c; + printf("It seems your .PASSWD file has been transfered, " + "do it any way?[y/N] "); + fflush(stdout); + scanf(" %c", &c); + if (c != 'y' && c != 'Y') + return 0; + } else { + perror("opening " BBSHOME "/.AngelTrans for marking"); + return 0; + } + } else { + time_t t = time(NULL); + char* str = ctime(&t); + write(orig_fd, str, strlen(str)); + } + + orig_fd = open(BBSHOME "/.PASSWDS", O_RDONLY); + if( orig_fd < 0 ){ + perror("opening " BBSHOME "/.PASSWDS for reading"); + return 1; + } + printf("Reading from " BBSHOME "/.PASSWDS\n"); + + new_fd = open(BBSHOME "/PASSWDS.NEW", O_WRONLY | O_CREAT | O_TRUNC, 0600); + if( new_fd < 0 ){ + perror("opening " BBSHOME "/PASSWDS.NEW for writing"); + return 1; + } + printf("Writing to " BBSHOME "/PASSWDS.NEW\n"); + + while(read(orig_fd, &u, sizeof(userec_t)) == sizeof(userec_t)){ + // clear 0x400, 0x800, and 0x3000 + u.uflag2 &= ~(REJ_OUTTAMAIL | REJ_QUESTION | ANGEL_MASK); + if( u.userlevel & OLD_PERM_NOOUTMAIL ) + u.uflag2 |= REJ_OUTTAMAIL; + u.userlevel &= ~PERM_ANGEL; + bzero(u.myangel, IDLEN + 1); + write(new_fd, &u, sizeof(userec_t)); + ++count; + } + + close(orig_fd); + close(new_fd); + printf("Done, totally %d accounts translated\n", count); + + printf("Moving files....\n"); + system("mv -i " BBSHOME "/.PASSWDS " BBSHOME "/.PASSWDS.old"); + system("mv -i " BBSHOME "/PASSWDS.NEW " BBSHOME "/.PASSWDS"); + printf("Done, old password file is now at " BBSHOME "/.PASSWDS.old\n"); + + return 0; +} -- cgit v1.2.3