Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert the 2006 version .PASSWD to the latest version: 波若波罗密! #4

Closed
huan opened this issue Jan 5, 2021 · 6 comments
Closed
Labels
help wanted Extra attention is needed

Comments

@huan
Copy link
Member

huan commented Jan 5, 2021

The latest backup of the .PASSWD file only contains no more than 180 bbs users who have permanent life, which is really sad for the 斧头帮🪓 ... (we have lost almost all our members!)

So we need a 波若波罗密 via 月光宝盒!

Current <200 users .PASSWDS

bbs@bbs.zixia.net:~$ ls -l .PASSWDS
-rwxr-xr-x 1 bbs bbs 22400000 Jan  5 09:48 .PASSWDS

The Hope: a .PASSWDS file from 2006

bbs@bbs.zixia.net:~/bak.20210105/src/kbs_bbs/contrib/convert$ ls -la
total 42912
drwxr-xr-x  3 bbs bbs     4096 Jan  5 09:28 .
drwxr-xr-x 11 bbs bbs     4096 Dec 29 16:00 ..
-rwxr-xr-x  1 bbs bbs 12951300 Apr 27  2006 .PASSWDS.NEW
-rwxr-xr-x  1 bbs bbs 30600000 Apr 27  2006 .PASSWDS.OLD
drwxr-xr-x  2 bbs bbs     4096 Dec 29 16:00 CVS
-rwxr-xr-x  1 bbs bbs     3040 Aug  7  2005 calc_effsize.c
-rwxr-xr-x  1 bbs bbs      626 Aug  7  2005 ch_brdflag.c
-rwxr-xr-x  1 bbs bbs     3773 Aug  7  2005 change_tmpl.c
-rwxr-xr-x  1 bbs bbs     2287 Aug  7  2005 cnv_bh.c
-rwxr-xr-x  1 bbs bbs     2775 Aug  7  2005 cnv_bh2.c
-rwxr-xr-x  1 bbs bbs     9703 Aug  7  2005 cnv_brddir.c
-rwxr-xr-x  1 bbs bbs     1065 Aug  7  2005 cnv_brdflag.c
-rwxr-xr-x  1 bbs bbs     3170 Aug  7  2005 cnv_passwd.c
-rwxr-xr-x  1 bbs bbs     1780 Aug  7  2005 cnv_register.c
-rwxr-xr-x  1 bbs bbs     6875 Apr 27  2006 convclub
-rwxr-xr-x  1 bbs bbs     3047 Apr 23  2006 convclub.c
-rwxr-xr-x  1 bbs bbs     4305 Aug  7  2005 convpass356.c
-rwxr-xr-x  1 bbs bbs    15228 Aug  7  2005 g2b_table
-rwxr-xr-x  1 bbs bbs   271808 Aug  7  2005 gen_table.c
-rwxr-xr-x  1 bbs bbs     1197 Aug  7  2005 recalc_signum.c
-rwxr-xr-x  1 bbs bbs      896 Aug  7  2005 refriend.c
-rwxr-xr-x  1 bbs bbs     9074 Aug  7  2005 strip_fh.c

What We Have

It seems there's a very high probability that the old/new .PASSWDS file is converted by the following source code: https://github.com/zixia/bbs.zixia.net/blob/main/kbs_bbs/contrib/convert/cnv_passwd.c, to be confirmed.

Todo

Find the right struct & maxuser for the backup file from 2006, and then convert it to match our latest version of code!

@huan huan added the help wanted Extra attention is needed label Jan 5, 2021
@huan
Copy link
Member Author

huan commented Jan 20, 2021

Update Jan 20, 2021

1. All files together

$ ls -l /bbs/tmp/convert/
-rwxr-xr-x 1 bbs bbs 12951300 Jan 18 19:10 PASSWDS.2005.new
-rwxr-xr-x 1 bbs bbs 30600000 Jan 18 19:10 PASSWDS.2005.old
-rwxr-xr-x 1 bbs bbs 22400000 Jan 18 18:19 PASSWDS.2020
-rw-r--r-- 1 bbs bbs     1618 Jan 18 19:03 zixia2020.c

Latest file & code

  • The PASSWDS.2020 is the latest password file, with the current userec structure. (but we only left less than 200 users...)
  • The zixia2020.c can read PASSWDS.2020 with the right structure, which is the latest version of the source code.

Old (2006) files

PASSWDS.2005.new & PASSWDS.2005.old are founded from the original backup files, can be located at /bbs/bak.20210105/src/kbs_bbs/contrib/convert/, which is original located at /bbs/src/kbs_bbs/contrib/convert/.

Some source code (utils) can be found in the same directory but I'm not sure which one is the right one. (I had tried the cnv_passwd.c & cnvclub.c

Progress

The right userec structure for the PASSWDS.2016 need to be found.

@realkcn
Copy link

realkcn commented Jan 20, 2021

PASSWDS.2005.old是可以使用的用户数据库。问题在于这个备份文件userec结构只有204字节,但当前的结构有320字节。
目前看到的差距:

  1. 备份文件看起来是32位系统编译的,time_t的大小只有32位。
  2. MAXCLUB可能从128调整到了512.
    需要继续对齐其他字段确定字段的位置

@realkcn
Copy link

realkcn commented Jan 21, 2021

大部分用户的home mail目录应该已经被删除了。需要修复的时候建立,内容肯定没了

@huan
Copy link
Member Author

huan commented Jan 21, 2021

备份文件看起来是32位系统编译的,time_t的大小只有32位。

这可能就是我怎么都搞不定的主要原因了。。。能通过 time_t 的数据看出是否 64 位架构编译,上帝威武!

@huan
Copy link
Member Author

huan commented Jan 21, 2021

Update 6:07 pm, Jan 21, 2021

43,171 zixia bbs users restored from 2006!

image

K core V5! Orz

bbs@bbs:~$ ps axf
  PID TTY      STAT   TIME COMMAND
    1 ?        Ss     0:00 /bin/sh -c /entrypoint.sh
    6 ?        S      0:00 s6-svscan -t0 /var/run/s6/services
   32 ?        S      0:00  \_ s6-supervise s6-fdholderd
  227 ?        S      0:00  \_ s6-supervise kbs
  233 ?        Ss     0:00  |   \_ bash ./run
  241 ?        S      0:00  |       \_ sleep 3600
  228 ?        S      0:00  \_ s6-supervise apache
  232 ?        Ss     0:00  |   \_ bash ./run
  344 ?        S      0:00  |       \_ sleep 60
  229 ?        S      0:00  \_ s6-supervise sshd
  231 ?        Ss     0:00      \_ /usr/sbin/sshd -D -e -p 2222
  255 ?        Ss     0:00          \_ sshd: bbs [priv]               
  257 ?        S      0:00          |   \_ sshd: bbs@pts/0                
  258 pts/0    Ss     0:00          |       \_ -bash
  347 pts/0    R+     0:00          |           \_ ps axf
  281 ?        Ss     0:00          \_ sshd: bbs [priv]               
  283 ?        S      0:00          |   \_ sshd: bbs@pts/1                
  286 pts/1    Ss+    0:00          |       \_ -bash
  345 ?        Ss     0:00          \_ sshd: unknown [priv]           
  346 ?        S      0:00              \_ sshd: unknown [net]            
  198 ?        Ss     0:00 /kbs/bin/miscd timed 
  202 ?        S      0:00  \_ /kbs/bin/miscd killd 
  203 ?        S      0:00      \_ /kbs/bin/miscd userd 
  209 ?        S      0:00          \_ /kbs/bin/miscd flushd
  206 ?        S      0:00 /kbs/bin/bbslogd
  210 ?        S      0:00 /kbs/bin/bbsd -p 23
  263 ?        Ss     0:00  \_ bbsd:zixia sd -p 23
  276 ?        Ss     0:00  \_ bbsd:KCN bbsd -p 23
  323 ?        Ss     0:00  \_ /kbs/bin/bbsd -p 23
  211 ?        Ss     0:00 /kbs/bin/sshbbsd -p 22

@realkcn
Copy link

realkcn commented Jan 21, 2021

备份文件的结构如下,已经恢复完毕:

#define IDLEN 12
#define IPLEN 16
#define NAMELEN 40
#define MAXCLUB 128
#define MD5PASSLEN      16
#pragma pack (4)

#define time_t unsigned int

struct userec {                 /* 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;
    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 */
    char unused[28];
};

@realkcn realkcn closed this as completed Jan 21, 2021
@huan huan added this to the 2021 Reload milestone Jan 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants