summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2008-03-26 18:44:19 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2008-03-26 18:44:19 +0800
commit04863303ca59132c9f47cc018ec1345a449c2b0e (patch)
tree78afb4240aaafffd4f6f80b575f36dff36ef6fbe
parent2e97729c2196fa6ecbb4928734781c0e688219ab (diff)
downloadpttbbs-04863303ca59132c9f47cc018ec1345a449c2b0e.tar
pttbbs-04863303ca59132c9f47cc018ec1345a449c2b0e.tar.gz
pttbbs-04863303ca59132c9f47cc018ec1345a449c2b0e.tar.bz2
pttbbs-04863303ca59132c9f47cc018ec1345a449c2b0e.tar.lz
pttbbs-04863303ca59132c9f47cc018ec1345a449c2b0e.tar.xz
pttbbs-04863303ca59132c9f47cc018ec1345a449c2b0e.tar.zst
pttbbs-04863303ca59132c9f47cc018ec1345a449c2b0e.zip
- (internal) util update - sync with latest library
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4024 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--util/Makefile31
-rw-r--r--util/bbsmail.c2
-rw-r--r--util/passwdconverter.c146
-rw-r--r--util/permrpt.sh7
-rw-r--r--util/r2014convert.c63
-rw-r--r--util/xchatd.c7
6 files changed, 24 insertions, 232 deletions
diff --git a/util/Makefile b/util/Makefile
index 48fadad8..69d89732 100644
--- a/util/Makefile
+++ b/util/Makefile
@@ -9,13 +9,11 @@ BBSBASE= $(SRCROOT)/include/var.h
UTIL_OBJS= \
util_cache.o util_record.o util_passwd.o util_var.o \
- util_stuff.o util_osdep.o util_args.o util_file.o \
- util_crypt.o
+ util_stuff.o util_osdep.o
MBBSD_OBJS= \
cache record passwd var \
- stuff osdep args file \
- crypt calendar
+ stuff osdep
# 下面這些程式, 會被 compile 並且和 $(UTIL_OBJS) 聯結
CPROG_WITH_UTIL= \
@@ -28,7 +26,11 @@ CPROG_WITH_UTIL= \
outmail chkhbf merge_dir \
transman angel gamblegive wretch_man \
chesscountry tunepasswd buildir xchatd \
- uhash_loader
+ uhash_loader
+
+# 下面是 C++ 的程式
+CPP_WITH_UTIL= \
+
# 下面這些程式, 會直接被 compile
CPROG_WITHOUT_UTIL= \
@@ -36,7 +38,7 @@ CPROG_WITHOUT_UTIL= \
initbbs userlist merge_board bbsmail
# 下面這些程式會被 install
-PROGS= ${CPROG_WITH_UTIL} ${CPROG_WITHOUT_UTIL} \
+PROGS= ${CPROG_WITH_UTIL} ${CPROG_WITHOUT_UTIL} ${CPP_WITH_UTIL}\
shmctl \
BM_money.sh backpasswd.sh mailog.sh opendice.sh \
openticket.sh stock.sh topsong.sh weather.sh \
@@ -48,7 +50,7 @@ LIBS+= $(SRCROOT)/src/libbbsutil/libbbsutil.a \
$(SRCROOT)/src/libbbs/libbbs.a
-all: ${CPROG_WITH_UTIL} ${CPROG_WITHOUT_UTIL} ${PROGS}
+all: ${CPROG_WITH_UTIL} ${CPROG_WITHOUT_UTIL} ${CPP_WITH_UTIL} ${PROGS}
$(SRCROOT)/include/var.h: $(SRCROOT)/mbbsd/var.c
cd $(SRCROOT)/mbbsd; $(MAKE) $(SRCROOT)/include/var.h
@@ -58,6 +60,11 @@ ${fn}: ${BBSBASE} ${fn}.c ${UTIL_OBJS}
$(CCACHE) ${CC} ${CFLAGS} ${LDFLAGS} -o ${fn} ${UTIL_OBJS} ${fn}.c $(LIBS)
.endfor
+.for fn in ${CPP_WITH_UTIL}
+${fn}: ${BBSBASE} ${fn}.cc ${UTIL_OBJS}
+ $(CCACHE) g++ ${CFLAGS} ${LDFLAGS} -o ${fn} ${UTIL_OBJS} ${fn}.cc $(LIBS)
+.endfor
+
.for fn in ${MBBSD_OBJS}
util_${fn}.o: ${BBSBASE} $(SRCROOT)/mbbsd/${fn}.c
$(CCACHE) ${CC} ${CFLAGS} -D_BBS_UTIL_C_ -c -o $@ $(SRCROOT)/mbbsd/${fn}.c
@@ -83,7 +90,7 @@ install: $(PROGS)
.endif
clean:
- rm -f *.o $(CPROGS) $(CPROG_WITH_UTIL) $(CPROG_WITHOUT_UTIL)
+ rm -f *.o $(CPROGS) $(CPROG_WITH_UTIL) $(CPROG_WITHOUT_UTIL) $(CPP_WITH_UTIL)
installfiltermail:
@@ -112,11 +119,3 @@ installbbsctl: bbsctl
cleanpasswd: cleanpasswd.c ${UTIL_OBJS}
$(CCACHE) ${CC} ${CFLAGS} ${LDFLAGS} -o cleanpasswd ${UTIL_OBJS} cleanpasswd.c
-
-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/bbsmail.c b/util/bbsmail.c
index 96f5b512..fa14b493 100644
--- a/util/bbsmail.c
+++ b/util/bbsmail.c
@@ -82,7 +82,7 @@ int mail2bbs(char *userid)
if( strncmp(genbuf, "Subject: ", 9) == 0 ){
strlcpy(title, genbuf + 9, sizeof(title));
#ifdef USE_ICONV
- str_decode_M3(title);
+ str_decode_M3((unsigned char*)title);
#endif
continue;
}
diff --git a/util/passwdconverter.c b/util/passwdconverter.c
deleted file mode 100644
index 2361b787..00000000
--- a/util/passwdconverter.c
+++ /dev/null
@@ -1,146 +0,0 @@
-#include "bbs.h"
-
-/* userec_t before revision 2275 */
-typedef struct old_userec_t {
- char userid[IDLEN + 1];
- char realname[20];
- char nickname[24];
- char passwd[PASSLEN];
- unsigned char uflag;
- unsigned int userlevel;
- unsigned short numlogins;
- unsigned short numposts;
- time4_t firstlogin;
- time4_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;
- time4_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 = PASSWD_VERSION;
-
- strlcpy(new->userid, old->userid, IDLEN + 1);
- strlcpy(new->realname, old->realname, 20);
- strlcpy(new->nickname, old->nickname, 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;
- memcpy(new->mind, old->mind, 4);
- memset(new->pad0, 0, sizeof(new->pad0)); // ident is not used anymore
- 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;
-}
diff --git a/util/permrpt.sh b/util/permrpt.sh
new file mode 100644
index 00000000..c821d5b1
--- /dev/null
+++ b/util/permrpt.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+bin/bbsctl permreport > etc/permrpt.log
+if [ -s etc/permrpt.log ] ; then
+ bin/post Administor "特殊權限使用者名單 `date +'%Y%m%d'`" "[權限報告]" etc/permrpt.log
+fi
+/bin/rm -f etc/permrpt.log
diff --git a/util/r2014convert.c b/util/r2014convert.c
deleted file mode 100644
index 14de742b..00000000
--- a/util/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/util/xchatd.c b/util/xchatd.c
index 67e7cfb0..c9abac2e 100644
--- a/util/xchatd.c
+++ b/util/xchatd.c
@@ -182,11 +182,6 @@ usr_fpath(char *buf, char *userid, char *fname)
sprintf(buf, str_home_file, userid[0], userid, fname);
}
-/* ----------------------------------------------------- */
-/* chkpasswd for check passwd */
-/* ----------------------------------------------------- */
-char *crypt(const char*, const char*);
-
int
chkpasswd(const char *passwd, const char *test)
{
@@ -194,7 +189,7 @@ chkpasswd(const char *passwd, const char *test)
char pwbuf[PASSLEN];
strlcpy(pwbuf, test, PASSLEN);
- pw = crypt(pwbuf, passwd);
+ pw = fcrypt(pwbuf, passwd);
return (!strncmp(pw, passwd, PASSLEN));
}