Kernel 0.93

This commit is contained in:
Rémy GIBERT 2019-06-06 17:45:40 +02:00
parent f414fe39ee
commit 49d81f333f
3 changed files with 132 additions and 130 deletions

Binary file not shown.

View File

@ -21,6 +21,7 @@ ZPBufPtr .BS 2
ZPRetryCnt .BS 1
ZPbValidUser .BS 1
ZPUID .BS 1
ZPhGetLine .BS 1
ZPGetLinePtr .BS 2
@ -75,7 +76,7 @@ L.SHELL .DA SHELL
CS.INIT clc
CS.INIT.RTS rts
*--------------------------------------
CS.RUN >LDYAI 32
CS.RUN >LDYAI 33 Enough for HASH
>SYSCALL getmem
bcs CS.INIT.RTS
@ -85,19 +86,21 @@ CS.RUN >LDYAI 32
>LDYA L.ETCISSUE
jsr CS.RUN.DUMPFILE
>LDYAI S.PW
>SYSCALL getmem
bcs CS.INIT.RTS
>STYA ZPPWPtr
stx ZPhPW
>PUSHWI 0 Dry Run, no output
* lda #0 ROOT user
>SYSCALL GetPWUID
bcc CS.RUN.AUTH
bcc CS.RUN.AUTH
*--------------------------------------
CS.RUN.NOAUTH >PUSHBI 0
>LDYA L.MSG.NOAUTH
>SYSCALL printf
bcs .9
jmp CS.RUN.NOAUTH
jsr CS.RUN.SetRootSession
bcs .9
jmp CS.RUN.EXEC
.9 rts
*--------------------------------------
CS.RUN.AUTH >LDYA L.LIBCRYPT
>SYSCALL LoadLib
@ -118,10 +121,11 @@ CS.RUN.AUTH >LDYA L.LIBCRYPT
jsr CS.RUN.GetLine
bcs .9
>PUSHW ZPPWPtr
>PUSHWI 0 Dry Run
>LDYA ZPGetLinePtr
>SYSCALL GetPWName
ror ZPbValidUser
sta ZPUID
>PUSHBI 0
>LDYA L.MSG.PASSWORD
@ -139,9 +143,14 @@ CS.RUN.AUTH >LDYA L.LIBCRYPT
bcs .9
jsr CS.RUN.CHECKPWD
bcc CS.RUN.LOGIN
bcs .8
>PUSHBI 0
jsr CS.RUN.SetUserSession
bcs .9
jmp CS.RUN.EXEC
.8 >PUSHBI 0
>LDYA L.MSG.BAD
>SYSCALL printf
bcs .9
@ -155,85 +164,6 @@ CS.RUN.AUTH >LDYA L.LIBCRYPT
sec
.9 rts
*--------------------------------------
CS.RUN.CHECKPWD rol ZPbValidUser
bcs CS.RUN.CHECK.9
>PUSHW ZPGetlinePtr
>PUSHW ZPGetlinePtr
>LIBCALL hLIBCRYPT,LIBCRYPT.MD5
lda ZPPWPtr
clc
adc #S.PW.PASSWD
tay
lda ZPPWPtr+1
adc /S.PW.PASSWD
>PUSHYA
>LDYA ZPGetlinePtr
>SYSCALL strcmp
CS.RUN.CHECK.9 rts
*--------------------------------------
CS.RUN.LOGIN jsr CS.RUN.SetUserSession
bcc CS.RUN.EXEC
CS.RUN.LOGIN.9 rts
*--------------------------------------
CS.RUN.NOAUTH >PUSHBI 0
>LDYA L.MSG.NOAUTH
>SYSCALL printf
bcs CS.RUN.CHECK.9
jsr CS.RUN.SetRootSession
bcs CS.RUN.LOGIN.9
CS.RUN.EXEC ldx #1
.1 lda S.Table.hSession-1,x
beq .2
inx
cpx #K.USR.MAX+1
bne .1
lda #E.OOH
* sec
rts
.2 stx ZPUsrID
txa
ldy #S.PS.hSID
sta (pPS),y
lda ZPhSID
ldx ZPUsrID
sta S.Table.hSession-1,x
ldy #S.PS.hStdIn
lda (pPS),y
sta S.Table.hFILE-1,x
>LDYA L.ETCMOTD
jsr CS.RUN.DumpFile
jsr CS.CLEANUP
>PUSHBI S.PS.F.HOLD
>LDYA L.SHELL
>SYSCALL ExecL
bcs .9
>SLEEP
ldx ZPUsrID
lda S.Table.hSession-1,x
stz S.Table.hSession-1,x
stz S.Table.hFILE-1,x
>SYSCALL freemem
sec
.9 rts
*--------------------------------------
CS.RUN.SetRootSession
>LDYA L.SESSION.ROOT
>STYA ZPStrPtr
@ -331,6 +261,84 @@ CS.RUN.SetUserSession
clc
.9 rts
*--------------------------------------
CS.RUN.CHECKPWD rol ZPbValidUser
bcs CS.RUN.CHECK.9
>LDYAI S.PW
>SYSCALL getmem
bcs CS.RUN.CHECK.9
>STYA ZPPWPtr
stx ZPhPW
>PUSHYA
lda ZPUID
>SYSCALL GetPWUID
bcs CS.RUN.CHECK.9
>PUSHW ZPGetlinePtr
>PUSHW ZPGetlinePtr
>LIBCALL hLIBCRYPT,LIBCRYPT.MD5
lda ZPPWPtr
clc
adc #S.PW.PASSWD
tay
lda ZPPWPtr+1
adc /S.PW.PASSWD
>PUSHYA
>LDYA ZPGetlinePtr
>SYSCALL strcmp
CS.RUN.CHECK.9 rts
*--------------------------------------
CS.RUN.EXEC ldx #1
.1 lda S.Table.hSession-1,x
beq .2
inx
cpx #K.USR.MAX+1
bne .1
lda #E.OOH
* sec
rts
.2 stx ZPUsrID
txa
ldy #S.PS.hSID
sta (pPS),y
lda ZPhSID
ldx ZPUsrID
sta S.Table.hSession-1,x
ldy #S.PS.hStdIn
lda (pPS),y
sta S.Table.hFILE-1,x
>LDYA L.ETCMOTD
jsr CS.RUN.DumpFile
jsr CS.CLEANUP
>PUSHBI S.PS.F.HOLD
>LDYA L.SHELL
>SYSCALL ExecL
bcs .9
>SLEEP
ldx ZPUsrID
lda S.Table.hSession-1,x
stz S.Table.hSession-1,x
stz S.Table.hFILE-1,x
>SYSCALL freemem
sec
.9 rts
*--------------------------------------
CS.RUN.AddStrLen
.1 inx
iny

View File

@ -14,51 +14,45 @@ X.PWD jmp (.1-SYS.GetPWUID,x)
* \0
*--------------------------------------
PWD.GetPWUID lda PWD.hDB
beq .9
beq PWD.GetPW.9
jsr K.GetmemPtr
>STYA ZPPtr3
.1 lda (ZPPtr3)
beq .99 EOF
beq PWD.GetPW.99 EOF
ldy #0
.2 lda (ZPPtr3),y
iny
cmp #':'
bne .2 skip USERNAME
jsr PWD.NextString skip USERNAME
.3 lda (ZPPtr3),y
iny
cmp #':'
bne .3 skip PASSWORD
jsr PWD.NextString skip PASSWORD
jsr PWD.GetByte get UID
cmp ZPPtr1+1
beq .8
beq PWD.GetPW.8
jsr PWD.NextLine
bra .1
.8 lda ZPPtr2+1
beq .80 Dry run, no output
PWD.GetPW.8 ldx ZPPtr2+1
beq .8 Dry run, no output
jmp PWD.Record2PW
.80 clc
.8 clc a = UID
rts
.9 lda #E.IPWDDB
PWD.GetPW.9 lda #E.IPWDDB
sec
rts
.99 lda #E.IUSR
PWD.GetPW.99 lda #E.IUSR
sec
rts
PWD.GetPW.RTS rts
*--------------------------------------
PWD.GetPWName lda PWD.hDB
beq .9
beq PWD.GetPW.9
jsr K.GetmemPtr
>STYA ZPPtr3
@ -68,10 +62,10 @@ PWD.GetPWName lda PWD.hDB
ldy #0
jsr MEM.TXTPTR.GetY
beq .99
beq PWD.GetPW.99
.1 lda (ZPPtr3)
beq .99
beq PWD.GetPW.99
ldy #$ff
@ -89,16 +83,15 @@ PWD.GetPWName lda PWD.hDB
cmp #':'
bne .3
ldx ZPPtr2+1
beq .8
jmp PWD.Record2PW
.9 lda #E.IPWDDB
sec
rts
.99 lda #E.IUSR
sec
PWD.GetPWName.RTS
rts
.8 iny
jsr PWD.NextString skip PASSWORD
iny
jmp PWD.GetByte get UID
*--------------------------------------
* ZPPtr2 : pPW (Input)
* ZPPtr3 : pDB
@ -111,7 +104,7 @@ PWD.PutPW >LDYA ZPPtr2
ldy #S.PW.UID
jsr MEM.TXTPTR.GetY
bne PWD.GetPWName.RTS Must be ROOT user
bne PWD.GetPW.RTS Must be ROOT user
jsr PWD.GetRecordLen
tay
@ -119,7 +112,7 @@ PWD.PutPW >LDYA ZPPtr2
>STYA PWD.DBSize
jsr K.getmem
bcs PWD.GetPWName.RTS
bcs PWD.GetPW.RTS
>STYA ZPPtr3
>STYA PWD.DBPtr
stx PWD.hDB
@ -211,15 +204,9 @@ PWD.GetUID >LDYA PWD.DBPtr
ldy #0
.2 lda (ZPPtr3),y
iny
cmp #':'
bne .2 skip name
jsr PWD.NextString skip name
.3 lda (ZPPtr3),y
iny
cmp #':'
bne .3 skip password
jsr PWD.NextString skip password
jsr PWD.GetByte
cmp .8+1
@ -309,6 +296,12 @@ PWD.FindRecord >LDYA PWD.DBPtr
sec
rts
*--------------------------------------
PWD.NextString lda (ZPPtr3),y
iny
cmp #':'
bne PWD.NextString
rts
*--------------------------------------
PWD.NextLine iny
lda (ZPPtr3),y
cmp #C.CR
@ -437,6 +430,7 @@ PWD.GetByte stz ZPPtr4
bra .1
.8 lda ZPPtr4
* clc
rts
*--------------------------------------
PWD.StoreRecord sec