俺把smth1.2升到kbs2.0dev后,用户帐号出现问题,只有SYSOP帐号没问题,
其它帐号登录时,出现“错误的使用者代号...”提示,于是用 smth1.2
local_utl中的cnv_passwd.c做.PASSWDS转换,完成后,全部帐号一切正常。
cnv_passwd.c是放在smth1.2下编译的,
另把userec2中的#ifdef OS_64BIT部分去掉了; HAVE_USERMONEY在俺的小站
中没用到; 在userrec2中有“int unused[2]”,咋弄呢?
大牛们帮看看,这样转换是否存在问题? 谢谢。
/* This program converts .PASSWDS file from smth1.2 to kbs2.0 */
#include "bbs.h"
#include "stdio.h"
struct userec1 { /* Structure used to hold information in */
char userid[IDLEN + 2]; /* PASSFILE */
char flags; /*一些标志,戒网,版面排序之类的 */
unsigned char title; /*用户级别 */
time_t firstlogin;
char lasthost[16];
unsigned int numlogins;
unsigned int numposts;
#ifdef CONV_PASS
char passwd[OLDPASSLEN];
char unused_padding[2];
#endif
char username[NAMELEN];
unsigned int club_read_rights[MAXCLUB >> 5];
unsigned int club_write_rights[MAXCLUB >> 5];
unsigned char md5passwd[MD5PASSLEN];
unsigned userlevel;
time_t lastlogin;
time_t stay;
int signature;
unsigned int userdefine[2];
time_t notedate;
int noteline;
int notemode;
time_t exittime;
/*
* 生日数据转移到 userdata 结构中
*/
unsigned int usedspace; /* used space of user's mailbox, in bytes */
#ifdef HAVE_USERMONEY
int money;
int score;
char unused[20];
#endif
};
struct userec2 { /* Structure used to hold information in */
char userid[IDLEN + 2]; /* PASSFILE */
char flags; /*一些标志,戒网,版面排序之类的 */
unsigned char title; /*用户级别 */
time_t firstlogin;
char lasthost[IPLEN];
unsigned int numlogins;
unsigned int numposts;
#ifdef CONV_PASS
char passwd[OLDPASSLEN];
char unused_padding[2];
#endif
char username[NAMELEN];
unsigned int club_read_rights[MAXCLUB >> 5];
unsigned int club_write_rights[MAXCLUB >> 5];
unsigned char md5passwd[MD5PASSLEN];
unsigned int userlevel;
time_t lastlogin;
time_t stay;
int signature;
unsigned int userdefine[2];
time_t notedate;
int noteline;
int unused_atppp;
time_t exittime;
/*
* 生日数据转移到 userdata 结构中
*/
unsigned int usedspace; /* used space of user's mailbox, in bytes */
int unused[7];
};
int main(int argc , char* argv[])
{
FILE * fp,*fp2;
struct userec1 bh;
struct userec2 bhnew;
int i;
if(argc !=3 )
{
printf("usage: convert Old_PASSWDS_FILE New_PASSWDS_FILE\n");
exit(0);
}
if((fp=fopen(argv[2],"r"))!=NULL){
printf("NEW FILE exist!");
fclose(fp);
exit(0);
}
if((fp = fopen(argv[1],"r")) == NULL)
{
printf("open .PASSWORD file failed!");
exit(0);
}
if((fp2 = fopen(argv[2],"w")) == NULL)
{
printf("cant create New_PASSWDS_FILE file!");
exit(0);
}
while( fread(&bh,sizeof(struct userec1),1,fp) ){
memset(&bhnew,0,sizeof(struct userec2));
memcpy(&bhnew, &bh, sizeof(struct userec1));
bhnew.userdefine[1]=-1;
bhnew.notedate = bh.notedate;
bhnew.noteline = bh.noteline;
bhnew.unused_atppp = bh.notemode;
bhnew.exittime = bh.exittime;
bhnew.usedspace = bh.usedspace;
#ifdef HAVE_USERMONEY
bhnew.money = bh.money;
bhnew.score = bh.score;
memcpy(bhnew.unused, bh.unused, 20);
#endif
--
修改:linton FROM 202.193.15.*
FROM 202.193.15.*