From b6bbb6238653053f6f30211560166394bfcb7381 Mon Sep 17 00:00:00 2001 From: piaip Date: Thu, 6 Mar 2008 15:42:27 +0000 Subject: - upgrade script update git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3973 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- upgrade/Makefile | 4 +--- upgrade/r2014_angel.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++ upgrade/r2014convert.c | 63 ------------------------------------------------- upgrade/r3968_chicken.c | 6 ++++- 4 files changed, 69 insertions(+), 67 deletions(-) create mode 100644 upgrade/r2014_angel.c delete mode 100644 upgrade/r2014convert.c diff --git a/upgrade/Makefile b/upgrade/Makefile index d050eba1..98903405 100644 --- a/upgrade/Makefile +++ b/upgrade/Makefile @@ -18,9 +18,7 @@ LIBS+= $(SRCROOT)/src/libbbsutil/libbbsutil.a \ all: echo "Usually you won't build everything for upgrading, so we let you decide what to run." + echo "Please type make rDDDD_XXXX to build your upgrade program." $(SRCROOT)/include/var.h: $(SRCROOT)/mbbsd/var.c cd $(SRCROOT)/mbbsd; $(MAKE) $(SRCROOT)/include/var.h - -r2014convert: r2014convert.c - $(CCACHE) ${CC} ${CFLAGS} ${LDFLAGS} -o r2014convert r2014convert.c $(LIBS) diff --git a/upgrade/r2014_angel.c b/upgrade/r2014_angel.c new file mode 100644 index 00000000..14de742b --- /dev/null +++ b/upgrade/r2014_angel.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 { + time4_t t = (time4_t)time(NULL); + char* str = ctime4(&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 &= ~(0x400 | 0x800 | 0x3000); + if( u.userlevel & OLD_PERM_NOOUTMAIL ) + u.uflag2 |= REJ_OUTTAMAIL; + u.userlevel &= ~000001000000; + 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; +} diff --git a/upgrade/r2014convert.c b/upgrade/r2014convert.c deleted file mode 100644 index 14de742b..00000000 --- a/upgrade/r2014convert.c +++ /dev/null @@ -1,63 +0,0 @@ -#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 { - time4_t t = (time4_t)time(NULL); - char* str = ctime4(&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 &= ~(0x400 | 0x800 | 0x3000); - if( u.userlevel & OLD_PERM_NOOUTMAIL ) - u.uflag2 |= REJ_OUTTAMAIL; - u.userlevel &= ~000001000000; - 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; -} diff --git a/upgrade/r3968_chicken.c b/upgrade/r3968_chicken.c index 740f42fe..70d90def 100644 --- a/upgrade/r3968_chicken.c +++ b/upgrade/r3968_chicken.c @@ -73,14 +73,17 @@ int main() FILE *fp = fopen(FN_PASSWD, "rb"), *fp2 = NULL; char fn[PATHLEN]; old_userec_t u; + int i; if (!fp) { printf("cannot load password file. abort.\n"); return -1; } + i = 0; while (fread(&u, sizeof(u), 1, fp) > 0) { + i++; if (!u.userid[0]) continue; if (!u.mychicken.name[0]) @@ -102,7 +105,8 @@ int main() unlink(fn); } else - printf("Transferred chicken data OK: %s.\n", u.userid); + // printf("Transferred chicken data OK: %s.\n", u.userid); + ; fclose(fp2); fp2 = NULL; } fclose(fp); -- cgit v1.2.3