原来smth1.2中userec的数据结构userec1 ,现在的KBS svn的userec数据结构为userec2。
使用smth1.2中的local_utl下的cnv_passwd转换,文件修改如下:
转化之后打印输出:
sizeof(struct userec1):444
sizeof(struct userec2):444
# HAVE_USERMONEY defined
# CONV_PASS defined
# OS_64BIT not defined
发现新旧文件md5sum一样。启动kbs,输入任何用户都是错误的用户。是不是还是没有转换好?
KBS中的OS_64BIT定义了吗?
修改后的cnv_passwd:
/* add userdefine1 to userec */
#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;
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];
#ifndef OS_64BIT
unsigned int userlevel;
#endif
time_t lastlogin;
time_t stay;
#ifdef OS_64BIT /* align 8 bytes... */
unsigned int userlevel;
#endif
int signature;
unsigned int userdefine[2];
time_t notedate;
int noteline;
int unused_atppp;
time_t exittime;
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 .BOARDS file failed!");
exit(0);
}
if ((fp2 = fopen(argv[2], "w")) == NULL) {
printf("cant create newboards file!");
exit(0);
}
printf("sizeof(struct userec1):%d\n",sizeof(struct userec1));
printf("sizeof(struct userec2):%d\n",sizeof(struct userec2));
#ifdef HAVE_USERMONEY
printf("# HAVE_USERMONEY defined\n");
#else
printf("# HAVE_USERMONEY not defined\n");
#endif
#ifdef CONV_PASS
printf("# CONV_PASS defined\n");
#else
printf("# CONV_PASS not defined\n");
#endif
#ifdef OS_64BIT
printf("# OS_64BIT defined\n");
#else
printf("# OS_64BIT not defined\n");
#endif
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;
fwrite(&bhnew, sizeof(struct userec2), 1, fp2);
}
fclose(fp2);
fclose(fp);
return 0;
}
--
FROM 61.167.60.*