Kernel 0.94

This commit is contained in:
Rémy GIBERT 2020-07-08 17:26:23 +02:00
parent 9f04a028d4
commit da4f7c05e3
8 changed files with 353 additions and 194 deletions

Binary file not shown.

View File

@ -160,7 +160,7 @@ CS.RUN.ROOT ldy #0
>SYSCALL strcmp
bcs .99
>LDYA pData
>PUSHW pData
>SYSCALL putpw
bcs .9

View File

@ -5,16 +5,18 @@ NEW
.OR $2000
.TF bin/who
*--------------------------------------
.INB INC/MACROS.I
.INB INC/MLI.I
.INB INC/A2OSX.I
.INB INC/KERNEL.I
.INB inc/macros.i
.INB inc/io.i
.INB inc/mli.i
.INB inc/a2osx.i
.INB inc/kernel.i
*--------------------------------------
.DUMMY
.OR ZPBIN
ZS.START
SessionID .BS 1
ZPSessionPtr .BS 2
ZPCODE .BS 9
ZS.END .ED
*--------------------------------------
* File Header (16 Bytes)
@ -43,45 +45,51 @@ L.MSG1 .DA MSG1
CS.INIT clc
rts
*--------------------------------------
CS.RUN >LDYA L.MSG0
CS.RUN ldy #8
.10 lda ZPCODE.START,y
sta ZPCODE,y
dey
bpl .10
>LDYA L.MSG0
>SYSCALL PutS
ldx #1
stx SessionID
.1 lda S.Table.hSession-1,x
.1 lda S.Table.hSID-1,x
beq .7
>SYSCALL GetMemPtr
>STYA ZPSessionPtr
jsr CS.RUN.GetSession
>PUSHW L.MSG1 format
>PUSHB SessionID 1 byte SID
ldx SessionID
lda S.Table.hSession-1,x
lda S.Table.hSID-1,x
>PUSHA 1 byte hSession
>PUSHB (ZPSessionPtr) 1 byte PRIVILEGE
>PUSHB (pData) 1 byte PRIVILEGE
ldy #S.SESSION.UID
>PUSHB (ZPSessionPtr),y 1 byte UID
>PUSHB (pData),y 1 byte UID
iny #S.SESSION.UID
>PUSHB (ZPSessionPtr),y 1 byte GID
>PUSHB (pData),y 1 byte GID
lda ZPSessionPtr
lda pData
clc
adc #S.SESSION.NAME
tay
lda ZPSessionPtr+1
lda pData+1
adc /S.SESSION.NAME
>PUSHYA 2 bytes NAME
ldx SessionID
lda S.Table.hFile-1,x
tax
jsr CS.RUN.GETIO
jsr CS.RUN.GetDevName
>PUSHYA 2 bytes DEV
>PUSHBI 9 total = 9 ... bytes
@ -98,7 +106,28 @@ CS.RUN >LDYA L.MSG0
sec we do not want to stay in memory
.9 rts
*--------------------------------------
CS.RUN.GETIO lda OF.Table.hPath-1,x
CS.RUN.GetSession
>SYSCALL GetStkObjPtr
>STYA ZPSessionPtr
ldy #0
.1 jsr ZPCODE
sta (pData),y
iny
cpy #S.SESSION.NAME
bne .1
.2 jsr ZPCODE
sta (pData),y
iny
tax
bne .2
rts
*--------------------------------------
CS.RUN.GetDevName
lda OF.Table.hPath-1,x
bne .1
lda OF.Table.hFD-1,x
@ -125,15 +154,21 @@ CS.QUIT clc
rts
*--------------------------------------
CS.END
ZPCODE.START sta SETREADAUX
lda (ZPSessionPtr),y
sta CLRREADAUX
rts
MSG0 .AZ "SID hSD Privilege UID GID Name Dev"
MSG1 .AZ "%3d $%0h %b %3d %3d %16s %s\r\n"
*--------------------------------------
.DUMMY
.OR 0
DS.START
BUF .BS 240
DS.END
.ED
*--------------------------------------
MAN
SAVE USR/SRC/BIN/WHO.S
SAVE usr/src/bin/who.s
ASM

View File

@ -138,6 +138,7 @@ E.DATALEN .EQ $6C Data Length Mismatch
E.IPWDDB .EQ $68 Invalid PWD database
E.IUSR .EQ $67 Invalid User
E.DUPUSR .EQ $66 Duplicate User
*--------------------------------------
* A2osX.SYSCALL Constants
*--------------------------------------

View File

@ -20,7 +20,6 @@ ZPRetryCnt .BS 1
ZPbValidUser .BS 1
ZPUID .BS 1
ZPhGetLine .BS 1
ZPGetLinePtr .BS 2
ZPbGetLineSecret .BS 1
ZPbEsc .BS 1
@ -34,7 +33,6 @@ ZPNewSession .BS 1
ZPOldSession .BS 1
ZPhFile .BS 1
ZPStrPtr .BS 2
ZS.END
.ED
*--------------------------------------
@ -72,15 +70,9 @@ L.SHELL .DA SHELL
CS.INIT clc
CS.INIT.RTS rts
*--------------------------------------
CS.RUN >LDYAI 33 Enough for HASH
>SYSCALL GetMem
bcs CS.INIT.RTS
>STYA ZPGetLinePtr
stx ZPhGetLine
>LDYA L.ETCISSUE
CS.RUN >LDYA L.ETCISSUE
jsr CS.RUN.DUMPFILE
bcs CS.INIT.RTS
lda #0
>PUSHA ROOT user
@ -91,89 +83,9 @@ CS.RUN >LDYAI 33 Enough for HASH
*--------------------------------------
>LDYA L.MSG.NOAUTH
jsr CS.RUN.StrOut
bcs .9
ldy #S.PS.hSession
lda (pPS),y
tax
lda S.Table.hSID-1,x
sta ZPNewSID
jmp CS.RUN.EXEC
.9 rts
bcs CS.INIT.RTS
*--------------------------------------
CS.RUN.AUTH lda #3
sta ZPRetryCnt
.1 >LDYA L.MSG.LOGIN
jsr CS.RUN.StrOut
bcs .9
lda #16
clc
jsr CS.RUN.GetLine
bcs .9
>LDYA L.MSG.PASSWORD
jsr CS.RUN.StrOut
bcs .9
lda #32
sec
jsr CS.RUN.GetLine
bcs .9
>LDYA L.MSG.CRLF
jsr CS.RUN.StrOut
bcs .9
bra *
jmp CS.RUN.EXEC
.8 >LDYA L.MSG.BAD
>SYSCALL PutS
bcs .9
dec ZPRetryCnt
beq .99
jmp .1
.99 lda #E.IUSR
sec
.9 rts
*--------------------------------------
CS.RUN.EXEC ldx #1
*.1 lda S.Table.hSID-1,x
* beq .2
* inx
* cpx #K.USR.MAX+1
* bne .1
* lda #E.OOH
** sec
* rts
.2
* stx ZPNewSession
* ldy #S.PS.hSession
* lda (pPS),y
* sta ZPOldSession
* txa
* sta (pPS),y
* lda ZPNewSID
* sta S.Table.hSID-1,x
* ldy #S.PS.hStdIn
* lda (pPS),y
* sta S.Table.hFILE-1,x
>LDYA L.ETCMOTD
CS.RUN.EXECPS >LDYA L.ETCMOTD
jsr CS.RUN.DumpFile
jsr CS.CLEANUP
@ -183,29 +95,114 @@ CS.RUN.EXEC ldx #1
bcs .9
>SLEEP
.9 rts
*--------------------------------------
CS.RUN.AUTH lda #3
sta ZPRetryCnt
.1 >LDYA L.MSG.LOGIN
jsr CS.RUN.StrOut
bcs .9
>LEA.G USername
ldx #16
clc
jsr CS.RUN.GetLine
bcs .9
>LDYA L.MSG.PASSWORD
jsr CS.RUN.StrOut
bcs .9
>LDYA pData >LEA.G Password
ldx #32
sec
jsr CS.RUN.GetLine
bcs .9
>LDYA L.MSG.CRLF
jsr CS.RUN.StrOut
bcs .9
* lda ZPOldSID
* beq .8
>PUSHW pData >PUSHEA.G Password
>PUSHW pData >PUSHEA.G Password
* >SYSCALL CloseSession
>SYSCALL MD5
* stz ZPOldSID
jmp CS.RUN.EXEC
>LDYA L.MSG.BAD
>SYSCALL PutS
bcs .9
dec ZPRetryCnt
bne .1
lda #E.IUSR
sec
.9 rts
*--------------------------------------
CS.RUN.EXEC >PUSHEA.G Username
>PUSHW pData >PUSHEA.G Password
>SYSCALL OpenSession
bcs .9
sta ZPNewSID
ldx #1
.1 lda S.Table.hSID-1,x
beq .2
inx
cpx #K.USR.MAX+1
bne .1
lda #E.OOH
* sec
rts
.2 stx ZPNewSession
ldy #S.PS.hSession
lda (pPS),y
sta ZPOldSession
*.8 ldx ZPNewSession
* lda S.Table.hSID-1,x
* stz S.Table.hSID-1,x
* stz S.Table.hFILE-1,x
* >SYSCALL FreeMem
txa
sta (pPS),y
lda ZPNewSID
sta S.Table.hSID-1,x
ldy #S.PS.hStdIn
lda (pPS),y
sta S.Table.hFILE-1,x
jsr CS.RUN.EXECPS
* ldy #S.PS.hSession
* lda ZPOldSession
* sta (pPS),y
lda ZPNewSID
>SYSCALL CloseSession
stz ZPNewSID
.8 ldx ZPNewSession
lda S.Table.hSID-1,x
stz S.Table.hSID-1,x
stz S.Table.hFILE-1,x
>SYSCALL FreeMem
ldy #S.PS.hSession
lda ZPOldSession
sta (pPS),y
sec
.9 rts
*--------------------------------------
CS.RUN.GetLine sta ZPGetLineMax
CS.RUN.GetLine >STYA ZPGetLinePtr
stx ZPGetLineMax
ror ZPbGetLineSecret
stz ZPGetLineLen
stz ZPbEsc
@ -326,12 +323,7 @@ CS.DOEVENT
rts
*--------------------------------------
CS.QUIT
CS.CLEANUP lda ZPhGetLine
beq .8
stz ZPhGetLine
>SYSCALL FreeMem
CS.CLEANUP
.8 clc
rts
*--------------------------------------
@ -350,7 +342,9 @@ SHELL .AZ "${SHELL}"
*--------------------------------------
.DUMMY
.OR 0
DS.START
DS.START
Password .BS 33
Username .BS 17
DS.END .ED
*--------------------------------------
MAN

View File

@ -1274,6 +1274,6 @@ SmartPort.OFS .HS 010305
SmartPort.SIG .HS 200003
*--------------------------------------
MAN
SAVE USR/SRC/SYS/KERNEL.S.INIT
LOAD USR/SRC/SYS/KERNEL.S
SAVE usr/src/sys/kernel.s.init
LOAD usr/src/sys/kernel.s
ASM

View File

@ -60,7 +60,7 @@ K.GetGRName >PULLW FORPNT
* ## RETURN VALUE
*\--------------------------------------
K.PutPW >PULLW TXTPTR
jsr K.SYSCALL.JMPX
bcc K.FlushEtcPasswd
rts
@ -152,14 +152,12 @@ K.CloseSession >PULLA
*--------------------------------------
PWD.ETCPASSWD .AZ "${ROOT}etc/passwd"
PWD.hUsrDB .BS 1
PWD.UsrDBPtr .BS 2
PWD.UsrDBSize .BS 2
PWD.ETCGROUP .AZ "${ROOT}etc/group"
PWD.hGrpDB .BS 1
PWD.GrpDBPtr .BS 2
PWD.GrpDBSize .BS 2
*--------------------------------------
MAN
SAVE USR/SRC/SYS/KERNEL.S.PWD
LOAD USR/SRC/SYS/KERNEL.S
SAVE usr/src/sys/kernel.s.pwd
LOAD usr/src/sys/kernel.s
ASM

View File

@ -81,7 +81,7 @@ PWDX.GetPWName lda PWD.hUsrDB
jsr PWD.NextString skip PASSWORD
jmp PWD.GetByte get UID
*--------------------------------------
* FORPNT : pPW (Output)
* TXTPTR : pPW (Input)
* ZPPtr3 : pDB
*--------------------------------------
PWDX.PutPW lda PWD.hUsrDB
@ -98,26 +98,35 @@ PWDX.PutPW lda PWD.hUsrDB
jsr K.getmem
bcs PWD.GetPW.RTS
>STYA ZPPtr3
>STYA PWD.UsrDBPtr
stx PWD.hUsrDB
jmp .8
>STYA ZPPtr3
stx PWD.hUsrDB
lda #0
sta (ZPPtr3)
jsr PWD.AppendRecord
clc
rts
*--------------------------------------
.1 jsr K.GetmemPtr
>STYA PWD.UsrDBPtr
>STYA ZPPtr3
ldy #S.PW.PASSWD
jsr SHARED.TXTPTR.GetY
bne .12
jsr PWD.DeleteRecord
bcc .80
jmp PWD.DeleteRecord
*--------------------------------------
.12 jsr PWD.FindRecord
bcs .11
lda #E.DUPUSR user already exits.
sec
rts
.12 jsr PWD.DeleteRecord
bcc .11 user exits..
jsr PWD.GetUID new user, get UID
*--------------------------------------
.11 jsr PWD.GetUID new user, get UID
bcs .99
ldy #S.PW.UID
@ -125,48 +134,33 @@ PWDX.PutPW lda PWD.hUsrDB
sta (TXTPTR),y
sta SETWRITEAUX
.11 jsr PWD.GetRecordLen
jsr PWD.GetRecordLen
clc
adc PWD.UsrDBSize
sta PWD.UsrDBSize
bcc .2
inc PWD.UsrDBSize+1
.2 >LDYA PWD.UsrDBPtr
>STYA ZPPtr4
>LDYA PWD.UsrDBSize
jsr K.Getmem
sta MEM.NewSize
lda #0
adc PWD.UsrDBSize+1
sta PWD.UsrDBSize+1
sta MEM.NewSize+1
lda PWD.hUsrDB
jsr K.Realloc.I
bcs .99
>STYA ZPPtr3
>STYA PWD.UsrDBPtr
ldy #0
.3 lda (ZPPtr4),y
sta (ZPPtr3),y
beq .4
iny
bne .3
inc ZPPtr4
inc ZPPtr3
bra .3
.4 tya
clc
adc ZPPtr3
sta ZPPtr3
bcc .5
inc ZPPtr3+1
.5 lda PWD.hUsrDB
stx PWD.hUsrDB
jsr K.Freemem
.8 jsr PWD.StoreRecord
.80 clc
.99 rts
jsr PWD.AppendRecord
clc
rts
.9 lda #E.IPWDDB
sec
rts
.99 rts
*--------------------------------------
PWDX.GetGRGID
@ -184,11 +178,11 @@ PWDX.OpenSession
beq .1
lda TXTPTR+1
bne .9
bne .3
.1 >LDYAI PWDX.ROOT.Size
jsr K.GetMem
bcs .99
bcs .9
>STYA ZPPtr1
@ -202,9 +196,45 @@ PWDX.OpenSession
txa
clc
rts
.3 jsr PWD.FindRecord
bcs .9
tya Y = Name length +1
* clc
adc ZPPtr3
sta ZPPtr4
.9 sec
.99 rts
lda ZPPtr3+1
adc #0
sta ZPPtr4+1
ldy #31
.5 jsr SHARED.FORPNT.getY
cmp (ZPPtr4),y Check MD5
bne .9
dey
bpl .5
>LDYAI 256 TODO: compute S.SESSION size
jsr K.Getmem
bcs .9
>STYA ZPPtr2
stx .8+1
jsr PWD.Record2Session
.8 lda #$ff SELF MODIFIED
clc
rts
sec
.9 rts
*--------------------------------------
PWDX.CloseSession
sec
@ -212,25 +242,34 @@ PWDX.CloseSession
*--------------------------------------
* PRIVATE
*--------------------------------------
PWD.GetUID >LDYA PWD.UsrDBPtr
PWD.GetUID lda PWD.hUsrDB
jsr K.GetmemPtr
>STYA ZPPtr3
stz .8+1
.1 lda (ZPPtr3)
beq .8 End of DB
ldy #0
jsr PWD.NextString skip name
jsr PWD.NextString skip password
jsr PWD.GetByte
cmp .8+1
bcc .4
sta .8+1
.4 jsr PWD.NextLine
bra .1
.8 lda #$ff SELF MODIFIED
inc
beq .9
clc
rts
.9 lda #E.IUSR
sec
rts
@ -238,10 +277,12 @@ PWD.GetUID >LDYA PWD.UsrDBPtr
PWD.DeleteRecord
jsr PWD.FindRecord
bcs .9
.1 iny
lda (ZPPtr3),y
cmp #C.CR
bne .1
sty .3+1
tya
sec
@ -250,7 +291,9 @@ PWD.DeleteRecord
lda ZPPtr3+1
adc #0
sta ZPPtr4+1
ldy #$ff
.2 iny
lda (ZPPtr4),y
sta (ZPPtr3),y
@ -261,31 +304,42 @@ PWD.DeleteRecord
.3 sbc #$ff SELF MODIFIED
sta PWD.UsrDBSize
bcs .8
dec PWD.UsrDBSize+1
.8 clc
.9 rts
*--------------------------------------
PWD.FindRecord >LDYA PWD.UsrDBPtr
PWD.FindRecord lda PWD.hUsrDB
jsr K.GetmemPtr
>STYA ZPPtr3
.2 lda (ZPPtr3)
beq .9 End of DB
ldy #$ff
.3 iny
jsr SHARED.TXTPTR.GetY
beq .4
cmp (ZPPtr3),y
beq .3
.5 jsr PWD.NextLine
bra .2
.4 lda (ZPPtr3),y
cmp #':'
bne .5
iny skip ":"
clc
rts
.9 lda #E.IUSR
sec
rts
@ -308,6 +362,70 @@ PWD.NextLine iny
inc ZPPtr3+1
.8 rts
*--------------------------------------
* USERNAME:PASSWORD:UID:GID:GECOS:HOME:SHELL\CR
*--------------------------------------
PWD.Record2Session
ldy #0
jsr PWD.NextString skip USERNAME
jsr PWD.NextString skip PASSWORD
jsr PWD.GetByte get UID
sta ZPPtr1
jsr PWD.GetByte get GID
sta ZPPtr1+1
lda #0
ldx ZPPtr1
bne .1
ora #S.SESSION.P.ROOT
.1 ldx ZPPtr1+1
bne .2
ora #S.SESSION.P.SYSADMIN
.2 jsr SHARED.PutCharPtr2
lda ZPPtr1
jsr SHARED.PutCharPtr2 UID
lda ZPPtr1+1
jsr SHARED.PutCharPtr2 GID
phy
ldy #$ff
.3 iny
lda (ZPPtr3),y
cmp #':'
beq .4
jsr SHARED.PutCharPtr2
bra .3
.4 lda #0
jsr SHARED.PutCharPtr2
ply
.5 lda (ZPPtr3),y
cmp #C.CR
beq .8
cmp #':'
bne .6
lda #0
.6 jsr SHARED.PutCharPtr2
iny
bra .5
.8 lda #0
jmp SHARED.PutCharPtr2
*--------------------------------------
PWD.Record2PW ldy #0
ldx #0 NAME
@ -387,31 +505,44 @@ PWD.Record2PW ldy #0
clc
rts
*--------------------------------------
PWD.GetByte stz ZPPtr4
PWD.GetByte stz .8+1
.1 lda (ZPPtr3),y
iny
cmp #':'
beq .8
and #$f
pha
lda ZPPtr4
lda .8+1
asl
asl
clc
adc ZPPtr4
adc .8+1
asl
sta ZPPtr4
sta .8+1
pla
clc
adc ZPPtr4
sta ZPPtr4
adc .8+1
sta .8+1
bra .1
.8 lda ZPPtr4
.8 lda #$ff SELF MODIFIED
clc
rts
*--------------------------------------
PWD.StoreRecord sec
PWD.AppendRecord
.1 lda (ZPPtr3)
beq .8
inc ZPPtr3
bne .1
inc ZPPtr3+1
bra .1
.8 sec
.HS 90 BCC
*--------------------------------------
PWD.GetRecordLen