Kernel 0.93

This commit is contained in:
Rémy GIBERT 2019-04-12 16:41:05 +01:00
parent ba003e8f20
commit da36e67682
5 changed files with 266 additions and 54 deletions

View File

@ -89,6 +89,10 @@ CS.RUN >LDYAI S.PW
.1 .1
>PUSHBI 0
>LDYA L.MSG.USAGE
>SYSCALL printf
.8 lda #0 .8 lda #0
sec sec
rts rts
@ -242,7 +246,7 @@ LIBCRYPT .AZ "libcrypt"
hLIBCRYPT .BS 1 hLIBCRYPT .BS 1
*-------------------------------------- *--------------------------------------
MSG.USAGE .AS "Usage : USERADD username\r\n" MSG.USAGE .AS "Usage : USERADD username\r\n"
.AS " -c : Comment\r\n" .AS " -c : Comment (GECOS)\r\n"
.AS " -d : Home Directory\r\n" .AS " -d : Home Directory\r\n"
.AS " -p : Password\r\n" .AS " -p : Password\r\n"
.AS " -s : Shell\r\n" .AS " -s : Shell\r\n"

View File

@ -627,7 +627,7 @@ S.PW.PASSWD .EQ 17 32+1
S.PW.UID .EQ 50 S.PW.UID .EQ 50
S.PW.GID .EQ 51 S.PW.GID .EQ 51
S.PW.GECOS .EQ 52 64+1 S.PW.GECOS .EQ 52 64+1
S.PW.DIR .EQ 115 64+1 S.PW.DIR .EQ 117 64+1
S.PW.SHELL .EQ 182 64+1 S.PW.SHELL .EQ 182 64+1
* *
S.PW .EQ 247 S.PW .EQ 247

View File

@ -39,6 +39,7 @@ CS.START cld
.DA CS.DOEVENT .DA CS.DOEVENT
.DA CS.QUIT .DA CS.QUIT
L.MSG.NOPASSWD .DA MSG.NOPASSWD L.MSG.NOPASSWD .DA MSG.NOPASSWD
L.LIBCRYPT .DA LIBCRYPT
L.MSG.LOGIN .DA MSG.LOGIN L.MSG.LOGIN .DA MSG.LOGIN
L.MSG.PASSWORD .DA MSG.PASSWORD L.MSG.PASSWORD .DA MSG.PASSWORD
L.MSG.ECHOCRLF .DA MSG.ECHOCRLF L.MSG.ECHOCRLF .DA MSG.ECHOCRLF
@ -55,15 +56,28 @@ CS.INIT clc
CS.RUN >PUSHEA.G PW CS.RUN >PUSHEA.G PW
lda #0 lda #0
>SYSCALL GetPWUID >SYSCALL GetPWUID
bcc .10 bcc CS.RUN.AUTH
>PUSHBI 0 >PUSHBI 0
>LDYA L.MSG.NOPASSWD >LDYA L.MSG.NOPASSWD
>SYSCALL printf >SYSCALL printf
bcs .9 bcs CS.RUN.9
bra .8
.10 >STZ.G INPUT.PrevCR jsr CS.RUN.SETENV
bcs CS.RUN.9
>PUSHBI S.PS.F.HOLD+S.PS.F.DUPENV
>LDYA L.SHELL
>SYSCALL ExecL
CS.RUN.9 rts
*--------------------------------------
CS.RUN.AUTH >LDYA L.LIBCRYPT
>SYSCALL LoadLib
bcs CS.RUN.9
sta hLIBCRYPT
>STZ.G INPUT.PrevCR
>PUSHBI 0 >PUSHBI 0
>LDYA L.MSG.LOGIN >LDYA L.MSG.LOGIN
@ -100,7 +114,7 @@ CS.RUN >PUSHEA.G PW
>SYSCALL printf >SYSCALL printf
bcs .9 bcs .9
.8 jsr CS.RUN.SETENV jsr CS.RUN.SETENV
bcs .9 bcs .9
>PUSHBI S.PS.F.HOLD+S.PS.F.DUPENV >PUSHBI S.PS.F.HOLD+S.PS.F.DUPENV
@ -126,7 +140,12 @@ CS.DOEVENT
sec sec
rts rts
*-------------------------------------- *--------------------------------------
CS.QUIT clc CS.QUIT lda hLIBCRYPT
beq .8
>SYSCALL UnloadLib
.8 clc
rts rts
*-------------------------------------- *--------------------------------------
* PRIVATE * PRIVATE
@ -219,6 +238,9 @@ INPUT.LINEIN ldy #INPUT.Status
rts rts
*-------------------------------------- *--------------------------------------
CS.END CS.END
*--------------------------------------
LIBCRYPT .AZ "libcrypt"
hLIBCRYPT .BS 1
MSG.NOPASSWD .AS "\r\n\r\nA2osX-Login:No ETC/PASSWD file present, Logged as ROOT.\r\n" MSG.NOPASSWD .AS "\r\n\r\nA2osX-Login:No ETC/PASSWD file present, Logged as ROOT.\r\n"
.AZ "Consider adding ROOT password with USERADD command.\r\n\r\n" .AZ "Consider adding ROOT password with USERADD command.\r\n\r\n"
MSG.LOGIN .AZ "\r\nlogin:" MSG.LOGIN .AZ "\r\nlogin:"

View File

@ -49,8 +49,7 @@ K.PutPW.1 sta SETREADAUX
bne PWD.Store bne PWD.Store
.9 rts .9 rts
*-------------------------------------- *--------------------------------------
PWD.Store >DEBUG PWD.Store lda PWD.DBPtr
lda PWD.DBPtr
sta A1L sta A1L
clc clc
adc PWD.DBSize adc PWD.DBSize

View File

@ -13,15 +13,99 @@ X.PWD jmp (.1-SYS.GetPWUID,x)
* ....\CR * ....\CR
* \0 * \0
*-------------------------------------- *--------------------------------------
PWD.GetPWUID PWD.GetPWUID lda PWD.hDB
*--------------------------------------
PWD.GetPWName
lda PWD.hDB
beq .9 beq .9
jsr K.GetmemPtr
>STYA ZPPtr3
.1 lda (ZPPtr3)
beq .99
ldy #0
.2 lda (ZPPtr3),y
iny
cmp #':'
bne .2
.3 lda (ZPPtr3),y
iny
cmp #':'
bne .3
jsr PWD.GetByte
cmp ZPPtr1+1
beq .8
.4 iny
lda (ZPPtr3),y
cmp #C.CR
bne .4
tya
sec
adc ZPPtr3
sta ZPPtr3
bcc .1
inc ZPPtr3+1
bra .1
.8 jmp PWD.Record2PM
.9 lda #E.IPWDDB .9 lda #E.IPWDDB
sec sec
rts rts
.99 lda #E.IUSR
sec
rts
*--------------------------------------
PWD.GetPWName lda PWD.hDB
beq .9
jsr K.GetmemPtr
>STYA ZPPtr3
.1 lda (ZPPtr3)
beq .99
ldy #$ff
.2 iny
lda (ZPPtr1),y
beq .4
cmp (ZPPtr3),y
beq .2
.3 iny
lda (ZPPtr3),y
cmp #C.CR
bne .3
tya
sec
adc ZPPtr3
sta ZPPtr3
bcc .1
inc ZPPtr3+1
bra .1
.4 lda (ZPPtr3),y
cmp #':'
bne .3
jmp PWD.Record2PM
.9 lda #E.IPWDDB
sec
rts
.99 lda #E.IUSR
sec
rts
*-------------------------------------- *--------------------------------------
PWD.PutPW >LDYA ZPPtr2 PWD.PutPW >LDYA ZPPtr2
>STYA TXTPTR >STYA TXTPTR
@ -41,8 +125,7 @@ PWD.PutPW >LDYA ZPPtr2
sec sec
rts rts
*-------------------------------------- *--------------------------------------
PWD.InitDB PWD.InitDB jsr PWD.GetRecordLen
jsr PWD.GetRecordLen
>STYA PWD.DBSize >STYA PWD.DBSize
jsr K.getmem jsr K.getmem
@ -57,7 +140,117 @@ PWD.InitDB
clc clc
.9 rts .9 rts
*-------------------------------------- *--------------------------------------
PWD.FindByID PWD.Record2PM ldy #0
ldx #0 NAME
.1 lda (ZPPtr3),y
iny
cmp #':'
beq .2
jsr MEM.PutCharPtr2
inx
bra .1
.2 lda #0
jsr MEM.PutCharPtr2
inx
cpx #S.PW.PASSWD
bne .2
.3 lda (ZPPtr3),y
iny
cmp #':'
beq .4
jsr MEM.PutCharPtr2
inx
bra .3
.4 lda #0
jsr MEM.PutCharPtr2
inx
cpx #S.PW.UID
bne .4
jsr PWD.GetByte UID
jsr MEM.PutCharPtr2
jsr PWD.GetByte GID
jsr MEM.PutCharPtr2
ldx #S.PW.GECOS
.5 lda (ZPPtr3),y
iny
cmp #':'
beq .6
jsr MEM.PutCharPtr2
inx
bra .5
.6 lda #0
jsr MEM.PutCharPtr2
inx
cpx #S.PW.DIR
bne .6
.7 lda (ZPPtr3),y
iny
cmp #':'
beq .8
jsr MEM.PutCharPtr2
inx
bra .7
.8 lda #0
jsr MEM.PutCharPtr2
inx
cpx #S.PW.SHELL
bne .8
.9 lda (ZPPtr3),y
iny
cmp #C.CR
beq .10
jsr MEM.PutCharPtr2
inx
bra .9
.10 lda #0
jsr MEM.PutCharPtr2
clc
rts
*--------------------------------------
PWD.GetByte stz .8+1
.1 lda (ZPPtr3),y
iny
cmp #':'
beq .8
and #$f
pha
lda .8+1
asl
asl
clc
adc .8+1
asl
sta .8+1
pla
clc
adc .8+1
sta .8+1
bra .1
.8 lda #$ff
rts
*-------------------------------------- *--------------------------------------
PWD.StoreRecord sec PWD.StoreRecord sec
.HS 90 BCC .HS 90 BCC
@ -68,20 +261,14 @@ PWD.GetRecordLen
ldy #S.PW.NAME-1 ldy #S.PW.NAME-1
.1 iny jsr PWD.StoreString
jsr MEM.TXTPTR.GetY
jsr PWD.StoreChar
bne .1
lda #':' lda #':'
jsr PWD.StoreChar jsr PWD.StoreChar
ldy #S.PW.PASSWD-1 ldy #S.PW.PASSWD-1
.2 iny jsr PWD.StoreString
jsr MEM.TXTPTR.GetY
jsr PWD.StoreChar
bne .2
lda #':' lda #':'
jsr PWD.StoreChar jsr PWD.StoreChar
@ -103,30 +290,21 @@ PWD.GetRecordLen
* iny S.PW.GECOS * iny S.PW.GECOS
.3 iny jsr PWD.StoreString
jsr MEM.TXTPTR.GetY
jsr PWD.StoreChar
bne .3
lda #':' lda #':'
jsr PWD.StoreChar jsr PWD.StoreChar
ldy #S.PW.DIR-1 ldy #S.PW.DIR-1
.4 iny jsr PWD.StoreString
jsr MEM.TXTPTR.GetY
jsr PWD.StoreChar
bne .4
lda #':' lda #':'
jsr PWD.StoreChar jsr PWD.StoreChar
ldy #S.PW.SHELL-1 ldy #S.PW.SHELL-1
.5 iny jsr PWD.StoreString
jsr MEM.TXTPTR.GetY
jsr PWD.StoreChar
bne .5
lda #C.CR lda #C.CR
jsr PWD.StoreChar jsr PWD.StoreChar
@ -137,10 +315,20 @@ PWD.GetRecordLen
rts rts
*-------------------------------------- *--------------------------------------
PWD.StoreByte stz .2+1 PWD.StoreString iny
jsr MEM.TXTPTR.GetY
beq .8
jsr PWD.StoreChar
bra PWD.StoreString
.8 rts
*--------------------------------------
PWD.StoreByte php
phx
stz .2+1
stz .3+1 stz .3+1
phx
ldx #8 ldx #8
sed sed
@ -161,6 +349,7 @@ PWD.StoreByte stz .2+1
cld cld
plx plx
plp
lda .3+1 lda .3+1
beq .4 beq .4
@ -168,37 +357,35 @@ PWD.StoreByte stz .2+1
jsr PWD.StoreChar30 jsr PWD.StoreChar30
.4 lda .2+1 .4 lda .2+1
pha beq PWD.StoreChar30
php
lsr lsr
lsr lsr
lsr lsr
lsr lsr
plp
and #$0f plp corrupt Z
beq .5 beq .5
jsr PWD.StoreChar30 jsr PWD.StoreChar30
.5 pla .5 lda .2+1
and #$0f and #$0f
.8 jsr PWD.StoreChar30
clc
rts
*-------------------------------------- *--------------------------------------
PWD.StoreChar30 ora #$30 PWD.StoreChar30 ora #$30
PWD.StoreChar inx PWD.StoreChar inx
pha
bcc .9 Dry run no store bcc .9 Dry run, no store
sta (ZPPtr3) sta (ZPPtr3)
inc ZPPtr3 inc ZPPtr3
bne .9 bne .9
inc ZPPtr3+1 inc ZPPtr3+1
.9 pla .9 rts
rts
*-------------------------------------- *--------------------------------------
MAN MAN
SAVE USR/SRC/SYS/KERNEL.S.PWDX SAVE USR/SRC/SYS/KERNEL.S.PWDX