Kernel 0.93

This commit is contained in:
Rémy GIBERT 2019-04-11 16:59:57 +01:00
parent 4ce904d060
commit 76e20b8b72
6 changed files with 331 additions and 21 deletions

View File

@ -50,6 +50,7 @@ L.LIBCRYPT .DA LIBCRYPT
L.MSG.USAGE .DA MSG.USAGE
L.MSG.ROOTPWD1 .DA MSG.ROOTPWD1
L.MSG.ROOTPWD2 .DA MSG.ROOTPWD2
L.MSG.MISMATCH .DA MSG.MISMATCH
L.MSG.BS .DA MSG.BS
.DA 0
*--------------------------------------
@ -96,7 +97,15 @@ CS.RUN >LDYAI S.PW
sec
.99 rts
*--------------------------------------
CS.RUN.ROOT sec
CS.RUN.ROOT ldy #0
.1 lda ROOT.PW,y
sta (pData),y PW
iny
cpy #S.PW
bne .1
sec
ror ZPbStrSecret
lda #127
sta ZPStrMax
@ -104,22 +113,47 @@ CS.RUN.ROOT sec
>PUSHBI 0
>LDYA L.MSG.ROOTPWD1
>SYSCALL printf
bcs .9
bcs .90
jsr CS.RUN.GetStr
bcs .9
bcs .90
>PUSHEA.G PW+S.PW.PASSWD
>PUSHW ZPStrPtr
>LIBCALL hLIBCRYPT,LIBCRYPT.MD5
>PUSHBI 0
>LDYA L.MSG.ROOTPWD2
>SYSCALL printf
bcs .9
jsr CS.RUN.GetStr
.90 bcs .9
>PUSHW ZPStrPtr
>PUSHW ZPStrPtr
>LIBCALL hLIBCRYPT,LIBCRYPT.MD5
>PUSHW ZPStrPtr
>LEA.G PW+S.PW.PASSWD
>SYSCALL puts
>SYSCALL strcmp
bcs .99
>LDYA pData
>SYSCALL putpw
bcs .9
lda #0
sec
.9 rts
.99 >PUSHBI 0
>LDYA L.MSG.MISMATCH
>SYSCALL printf
lda #E.SYN
sec
rts
*--------------------------------------
CS.RUN.GetStr stz ZPStrLen
@ -204,20 +238,38 @@ CS.END
*--------------------------------------
* Initialized DATA
*--------------------------------------
MSG.USAGE .AZ "Usage : USERADD username\r\n"
MSG.ROOTPWD1 .AZ "\r\nPlease enter ROOT password : "
MSG.ROOTPWD2 .AZ "\r\nPlease retype ROOT password : "
MSG.BS .DA #C.BS,#C.SPACE,#C.BS,#0
*--------------------------------------
LIBCRYPT .AZ "libcrypt"
hLIBCRYPT .BS 1
*--------------------------------------
MSG.USAGE .AS "Usage : USERADD username\r\n"
.AS " -c : Comment\r\n"
.AS " -d : Home Directory\r\n"
.AS " -p : Password\r\n"
.AS " -s : Shell\r\n"
MSG.CRLF .AZ "\r\n"
MSG.ROOTPWD1 .AZ "\r\nPlease enter ROOT password : "
MSG.ROOTPWD2 .AZ "\r\nPlease retype ROOT password : "
MSG.MISMATCH .AZ "\r\nPasswords mismatch...\r\n"
MSG.BS .DA #C.BS,#C.SPACE,#C.BS,#0
*--------------------------------------
ROOT.PW .AS "ROOT"
.BS 17-4
.BS 33 PASSWD
.DA #0 UID
.DA #0 GID
.AS "Root User"
.BS 65-9
.AS "${ROOT}ROOT/"
.BS 65-12
.AS "${ROOT}BIN/SH"
.BS 65-13
*--------------------------------------
* Per Process DATA segment
*--------------------------------------
.DUMMY
.OR 0
DS.START
PW .DA S.PW
PW .BS S.PW
DS.END
.ED
*--------------------------------------

View File

@ -1076,8 +1076,8 @@ PwdMgrInit >LDYAI MSG.PWD
>LDYAI ETCPASSWD
>SYSCALL LoadStkObj
bcs .9
sta PWD.hDB
stx PWD.hDB
>STYA PWD.DBSize
.9 rts
*--------------------------------------
* Modified CHARGET/CHARGOT for ROM CALL
@ -1162,7 +1162,7 @@ I.ENV.PATH .AZ "PATH=${ROOT}SBIN/:${ROOT}BIN/"
I.ENV.LIB .AZ "LIB=${ROOT}LIB/"
I.ENV.DRV .AZ "DRV=${ROOT}DRV/"
CTRLR.SHELL .AZ "${ROOT}BIN/SH"
ETCPASSWD .AZ "${ROOT}ETC/PASSWD"
ETCPASSWD .AZ "${ROOT}ETC/PASSWD"
ETCINIT.CMDLINE .AZ "${ROOT}ETC/INIT"
*--------------------------------------
MLIOPEN00 .DA #3

View File

@ -539,6 +539,8 @@ MEM.Kernel.JMP jmp (SYS.Kernel.JMP,x)
*\--------------------------------------
K.LoadStkObj >SYSCALL LoadFile
bcs .99
sty .81+1
sta .82+1
stx .8+1 Save MAIN hMem
iny
@ -576,7 +578,10 @@ K.LoadStkObj >SYSCALL LoadFile
.8 lda #$ff SELF MODIFIED
jsr K.FreeMem release MAIN memory
.80 lda #$ff Returns AUX hMem
.80 ldx #$ff Returns AUX hMem
.81 ldy #$ff and file len in Y,A
.82 lda #$ff
* clc
rts
.9 pha
@ -722,6 +727,11 @@ MEM.SetDataByte.1
inc ZPSListDataPtr+1
.8 rts
*--------------------------------------
MEM.TXTPTR.GetY sta CLRREADAUX
lda (TXTPTR),y
sta SETREADAUX
rts
*--------------------------------------
MEM.TXTPTR.GetNext
sta CLRREADAUX
lda (TXTPTR)

View File

@ -34,7 +34,7 @@ K.GetPWName jsr MEM.SPtr1PPtr2
* `>SYSCALL putpw`
* ## RETURN VALUE
*\--------------------------------------
K.PutPW >STYA ZPPtr1
K.PutPW >STYA ZPPtr2
K.PutPW.1 sta SETREADAUX
sta SETWRITEAUX
@ -43,9 +43,79 @@ K.PutPW.1 sta SETREADAUX
sta CLRREADAUX
sta CLRWRITEAUX
bcs .9
lda PWD.bDirty
bne PWD.Store
.9 rts
*--------------------------------------
PWD.Store >LDYA PWD.DBSize
jsr K.getmem
bcs .9
stx .8+1
>STYA A4L Save Destination Address in MAIN
pha
* clc
adc PWD.DBSize
sta A2L
pla
adc PWD.DBSize+1
sta A2L+1
lda PWD.hDB
jsr K.getmemptr
>STYA A1L Save AUX base Ptr
clc Aux To Main
jsr AuxMove
>PUSHWI 0 Aux type
>PUSHBI S.FI.T.TXT
>PUSHBI O.WRONLY+O.CREATE
>LDYAI PWD.FILE
>SYSCALL FOpen
bcc .1
pha
jsr .8
pla
sec
.9 rts
.1 sta .7+1
>PUSHW PWD.DBSize
lda .8+1
jsr K.getmemptr
>PUSHYA
lda .7+1
>SYSCALL FWrite
bcs .2
jsr .7
stz PWD.bDirty
rts
.2 pha
jsr .7
pla
sec
rts
.7 lda #$ff
>SYSCALL fclose
.8 lda #$ff
jsr K.freemem
* clc
rts
*--------------------------------------
PWD.bDirty .BS 1
PWD.hDB .BS 1
PWD.DBSize .BS 2
PWD.FILE .AZ "${ROOT}ETC/PASSWD"
*--------------------------------------
MAN
SAVE USR/SRC/SYS/KERNEL.S.PWD

View File

@ -6,21 +6,199 @@ X.PWD jmp (.1-SYS.GetPWUID,x)
.DA PWD.GetPWName
.DA PWD.PutPW
*--------------------------------------
* USERNAME:PASSWORD:UID:GID:GECOS:HOME:SHELL
* ZPPtr1 : UID / pName
* ZPPtr2 : pPW
* ZPPtr3 : pDB
* USERNAME:PASSWORD:UID:GID:GECOS:HOME:SHELL\CR
* ....\CR
* \0
*--------------------------------------
PWD.GetPWUID
*--------------------------------------
PWD.GetPWName
*--------------------------------------
PWD.PutPW lda PWD.hDB
PWD.GetPWName
lda PWD.hDB
beq .9
.9 lda #E.IPWDDB
sec
rts
*--------------------------------------
PWD.PutPW >LDYA ZPPtr2
>STYA TXTPTR
lda PWD.hDB
bne .1
ldy #S.PW.UID
jsr MEM.TXTPTR.GetY
bne .9 Must be ROOT user
jmp PWD.InitDB
.1
.9 lda #E.IPWDDB
sec
rts
*--------------------------------------
PWD.InitDB
jsr PWD.GetRecordLen
>STYA PWD.DBSize
jsr K.getmem
bcs .9
>STYA ZPPtr3
stx PWD.hDB
jsr PWD.StoreRecord
inc PWD.bDirty
clc
.9 rts
*--------------------------------------
PWD.FindByID
*--------------------------------------
PWD.StoreRecord sec
.HS 90 BCC
*--------------------------------------
PWD.GetRecordLen
clc
ldx #0
ldy #S.PW.NAME-1
.1 iny
jsr MEM.TXTPTR.GetY
jsr PWD.StoreChar
bne .1
lda #':'
jsr PWD.StoreChar
ldy #S.PW.PASSWD-1
.2 iny
jsr MEM.TXTPTR.GetY
jsr PWD.StoreChar
bne .2
lda #':'
jsr PWD.StoreChar
ldy #S.PW.UID
jsr MEM.TXTPTR.GetY
jsr PWD.StoreByte
lda #':'
jsr PWD.StoreChar
iny S.PW.UID
jsr MEM.TXTPTR.GetY
jsr PWD.StoreByte
lda #':'
jsr PWD.StoreChar
* iny S.PW.GECOS
.3 iny
jsr MEM.TXTPTR.GetY
jsr PWD.StoreChar
bne .3
lda #':'
jsr PWD.StoreChar
ldy #S.PW.DIR-1
.4 iny
jsr MEM.TXTPTR.GetY
jsr PWD.StoreChar
bne .4
lda #':'
jsr PWD.StoreChar
ldy #S.PW.SHELL-1
.5 iny
jsr MEM.TXTPTR.GetY
jsr PWD.StoreChar
bne .5
lda #C.CR
jsr PWD.StoreChar
txa
tay
lda #0
rts
*--------------------------------------
PWD.StoreByte stz .2+1
stz .3+1
phx
ldx #8
sed
.1 asl
pha
.2 lda #$ff Self Modified
adc .2+1
sta .2+1
.3 lda #$ff Self Modified
adc .3+1
sta .3+1
pla
dex
bne .1
cld
plx
lda .3+1
beq .4
jsr PWD.StoreChar30
.4 lda .2+1
pha
lsr
lsr
lsr
lsr
beq .5
jsr PWD.StoreChar30
.5 pla
and #$0f
.8 jsr PWD.StoreChar30
clc
rts
*--------------------------------------
PWD.StoreChar30 ora #$30
PWD.StoreChar inx
pha
bcc .9 Dry run no store
sta (ZPPtr3)
inc ZPPtr3
bne .9
inc ZPPtr3+1
.9 pla
rts
*--------------------------------------
MAN
SAVE USR/SRC/SYS/KERNEL.S.PWDX
LOAD USR/SRC/SYS/KERNEL.S

View File

@ -55,7 +55,6 @@ A2osX.D2 .PH $D000
.INB USR/SRC/SYS/KERNEL.S.TIME
.INB USR/SRC/SYS/KERNEL.S.BIN
.INB USR/SRC/SYS/KERNEL.S.PS
.INB USR/SRC/SYS/KERNEL.S.PWD
.INB USR/SRC/SYS/KERNEL.S.ARG
.INB USR/SRC/SYS/KERNEL.S.ENV
.INB USR/SRC/SYS/KERNEL.S.MATH
@ -69,6 +68,7 @@ A2osX.E0 .PH $E000
.INB USR/SRC/SYS/KERNEL.S.PFT
.INB USR/SRC/SYS/KERNEL.S.IO
********* TMP ***** go to A2osX.D2
.INB USR/SRC/SYS/KERNEL.S.PWD
.LIST ON
DevMgr.FreeMem .EQ *
.LIST OFF