A2osX/SYS/KERNEL.S.PWDX.txt

534 lines
8.1 KiB
Plaintext
Raw Normal View History

2019-04-09 15:47:33 +00:00
NEW
AUTO 3,1
*--------------------------------------
X.PWD jmp (.1-SYS.GetPWUID,x)
.1 .DA PWD.GetPWUID
.DA PWD.GetPWName
.DA PWD.PutPW
*--------------------------------------
2019-04-26 15:07:22 +00:00
* ZPPtr1 : UID / pName (Input)
* ZPPtr2 : pPW (Output)
2019-04-11 15:59:57 +00:00
* ZPPtr3 : pDB
* USERNAME:PASSWORD:UID:GID:GECOS:HOME:SHELL\CR
* ....\CR
* \0
2019-04-09 15:47:33 +00:00
*--------------------------------------
2019-04-12 15:41:05 +00:00
PWD.GetPWUID lda PWD.hDB
2019-06-06 15:45:40 +00:00
beq PWD.GetPW.9
2019-04-12 15:41:05 +00:00
jsr K.GetmemPtr
>STYA ZPPtr3
.1 lda (ZPPtr3)
2019-06-06 15:45:40 +00:00
beq PWD.GetPW.99 EOF
2019-04-12 15:41:05 +00:00
ldy #0
2019-06-06 15:45:40 +00:00
jsr PWD.NextString skip USERNAME
2019-04-12 15:41:05 +00:00
2019-06-06 15:45:40 +00:00
jsr PWD.NextString skip PASSWORD
2019-04-12 15:41:05 +00:00
2019-04-25 15:33:56 +00:00
jsr PWD.GetByte get UID
2019-04-12 15:41:05 +00:00
cmp ZPPtr1+1
2019-06-06 15:45:40 +00:00
beq PWD.GetPW.8
2019-04-12 15:41:05 +00:00
2019-04-25 15:33:56 +00:00
jsr PWD.NextLine
2019-04-12 15:41:05 +00:00
bra .1
2019-06-06 15:45:40 +00:00
PWD.GetPW.8 ldx ZPPtr2+1
beq .8 Dry run, no output
2019-06-06 06:37:30 +00:00
jmp PWD.Record2PW
2019-06-06 15:45:40 +00:00
.8 clc a = UID
2019-06-06 06:37:30 +00:00
rts
2019-04-12 15:41:05 +00:00
2019-06-06 15:45:40 +00:00
PWD.GetPW.9 lda #E.IPWDDB
2019-04-12 15:41:05 +00:00
sec
rts
2019-06-06 15:45:40 +00:00
PWD.GetPW.99 lda #E.IUSR
2019-04-12 15:41:05 +00:00
sec
2019-06-06 15:45:40 +00:00
PWD.GetPW.RTS rts
2019-04-09 15:47:33 +00:00
*--------------------------------------
2019-04-12 15:41:05 +00:00
PWD.GetPWName lda PWD.hDB
2019-06-06 15:45:40 +00:00
beq PWD.GetPW.9
2019-04-09 15:47:33 +00:00
2019-04-12 15:41:05 +00:00
jsr K.GetmemPtr
>STYA ZPPtr3
2019-04-15 05:40:13 +00:00
>LDYA ZPPtr1
>STYA TXTPTR
2019-04-12 15:41:05 +00:00
2019-04-15 05:40:13 +00:00
ldy #0
jsr MEM.TXTPTR.GetY
2019-06-06 15:45:40 +00:00
beq PWD.GetPW.99
2019-04-29 05:59:01 +00:00
2019-04-15 05:40:13 +00:00
.1 lda (ZPPtr3)
2019-06-06 15:45:40 +00:00
beq PWD.GetPW.99
2019-04-15 05:40:13 +00:00
2019-04-12 15:41:05 +00:00
ldy #$ff
.2 iny
2019-04-15 05:40:13 +00:00
jsr MEM.TXTPTR.GetY
2019-04-12 15:41:05 +00:00
beq .4
cmp (ZPPtr3),y
beq .2
2019-04-25 15:33:56 +00:00
.3 jsr PWD.NextLine
2019-04-12 15:41:05 +00:00
bra .1
.4 lda (ZPPtr3),y
cmp #':'
bne .3
2019-06-06 15:45:40 +00:00
ldx ZPPtr2+1
beq .8
2019-04-12 15:41:05 +00:00
2019-06-06 15:45:40 +00:00
jmp PWD.Record2PW
2019-04-12 15:41:05 +00:00
2019-06-06 15:45:40 +00:00
.8 iny
jsr PWD.NextString skip PASSWORD
jmp PWD.GetByte get UID
2019-04-09 15:47:33 +00:00
*--------------------------------------
2019-04-26 15:07:22 +00:00
* ZPPtr2 : pPW (Input)
* ZPPtr3 : pDB
*--------------------------------------
2019-04-11 15:59:57 +00:00
PWD.PutPW >LDYA ZPPtr2
>STYA TXTPTR
lda PWD.hDB
bne .1
ldy #S.PW.UID
jsr MEM.TXTPTR.GetY
2019-06-06 15:45:40 +00:00
bne PWD.GetPW.RTS Must be ROOT user
2019-04-11 15:59:57 +00:00
2019-04-25 15:33:56 +00:00
jsr PWD.GetRecordLen
tay
lda #0
>STYA PWD.DBSize
jsr K.getmem
2019-06-06 15:45:40 +00:00
bcs PWD.GetPW.RTS
2019-04-25 15:33:56 +00:00
>STYA ZPPtr3
>STYA PWD.DBPtr
stx PWD.hDB
2019-04-29 15:47:17 +00:00
jmp .8
2019-04-11 15:59:57 +00:00
2019-04-23 15:47:40 +00:00
.1 jsr K.GetmemPtr
>STYA PWD.DBPtr
2019-04-19 05:42:43 +00:00
2019-04-29 05:59:01 +00:00
ldy #S.PW.PASSWD
jsr MEM.TXTPTR.GetY
bne .12
2019-04-29 15:47:17 +00:00
jsr PWD.DeleteRecord
bcc .80
rts
2019-04-29 05:59:01 +00:00
.12 jsr PWD.DeleteRecord
2019-04-25 15:33:56 +00:00
bcc .11 user exits..
2019-04-26 15:07:22 +00:00
jsr PWD.GetUID new user, get UID
bcs .99
ldy #S.PW.UID
sta CLRWRITEAUX
sta (TXTPTR),y
sta SETWRITEAUX
2019-04-25 15:33:56 +00:00
.11 jsr PWD.GetRecordLen
2019-04-23 15:47:40 +00:00
2019-04-19 05:42:43 +00:00
clc
adc PWD.DBSize
2019-04-23 15:47:40 +00:00
sta PWD.DBSize
bcc .2
inc PWD.DBSize+1
2019-04-19 05:42:43 +00:00
2019-04-23 15:47:40 +00:00
.2 >LDYA PWD.DBPtr
>STYA ZPPtr4
>LDYA PWD.DBSize
2019-04-19 05:42:43 +00:00
2019-04-23 15:47:40 +00:00
jsr K.Getmem
bcs .99
>STYA ZPPtr3
>STYA PWD.DBPtr
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
2019-04-24 15:34:11 +00:00
.5 lda PWD.hDB
stx PWD.hDB
jsr K.Freemem
2019-04-25 15:33:56 +00:00
.8 jsr PWD.StoreRecord
2019-04-23 15:47:40 +00:00
2019-04-29 15:47:17 +00:00
.80 inc PWD.bDirty
2019-04-23 15:47:40 +00:00
clc
2019-04-25 15:33:56 +00:00
.99 rts
2019-04-23 15:47:40 +00:00
2019-04-11 15:59:57 +00:00
.9 lda #E.IPWDDB
sec
2019-04-25 15:33:56 +00:00
rts
2019-04-11 15:59:57 +00:00
*--------------------------------------
2019-04-25 15:33:56 +00:00
* ZPPtr2 = pPW
*--------------------------------------
2019-04-26 15:07:22 +00:00
PWD.GetUID >LDYA PWD.DBPtr
2019-04-11 15:59:57 +00:00
>STYA ZPPtr3
2019-04-26 15:07:22 +00:00
stz .8+1
.1 lda (ZPPtr3)
beq .8 End of DB
ldy #0
2019-06-06 15:45:40 +00:00
jsr PWD.NextString skip name
2019-04-26 15:07:22 +00:00
2019-06-06 15:45:40 +00:00
jsr PWD.NextString skip password
2019-04-26 15:07:22 +00:00
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
2019-04-25 15:33:56 +00:00
clc
rts
2019-04-26 15:07:22 +00:00
.9 lda #E.IUSR
sec
rts
2019-04-19 05:42:43 +00:00
*--------------------------------------
PWD.DeleteRecord
2019-04-23 15:47:40 +00:00
jsr PWD.FindRecord
bcs .9
.1 iny
lda (ZPPtr3),y
cmp #C.CR
bne .1
2019-04-30 16:08:47 +00:00
sty .3+1
2019-04-23 15:47:40 +00:00
tya
sec
adc ZPPtr3
sta ZPPtr4
lda ZPPtr3+1
adc #0
sta ZPPtr4+1
ldy #$ff
.2 iny
lda (ZPPtr4),y
sta (ZPPtr3),y
bne .2
lda PWD.DBSize
sec
2019-04-30 16:08:47 +00:00
.3 sbc #$ff SELF MODIFIED
2019-04-23 15:47:40 +00:00
sta PWD.DBSize
2019-04-30 16:08:47 +00:00
bcs .8
2019-04-23 15:47:40 +00:00
dec PWD.DBSize+1
2019-04-30 16:08:47 +00:00
.8 clc
2019-04-23 15:47:40 +00:00
.9 rts
*--------------------------------------
PWD.FindRecord >LDYA PWD.DBPtr
2019-04-19 05:42:43 +00:00
>STYA ZPPtr3
2019-04-23 15:47:40 +00:00
>LDYA ZPPtr2
2019-04-19 05:42:43 +00:00
>STYA TXTPTR
.2 lda (ZPPtr3)
beq .9 End of DB
ldy #$ff
.3 iny
2019-04-23 15:47:40 +00:00
jsr MEM.TXTPTR.GetY
beq .4
2019-04-19 05:42:43 +00:00
cmp (ZPPtr3),y
2019-04-23 15:47:40 +00:00
beq .3
2019-04-25 15:33:56 +00:00
.5 jsr PWD.NextLine
bra .2
2019-04-29 15:47:17 +00:00
.4 lda (ZPPtr3),y
cmp #':'
bne .5
2019-04-25 15:33:56 +00:00
2019-04-29 15:47:17 +00:00
clc
2019-04-25 15:33:56 +00:00
rts
2019-04-29 05:59:01 +00:00
.9 lda #E.IUSR
sec
2019-04-25 15:33:56 +00:00
rts
*--------------------------------------
2019-06-06 15:45:40 +00:00
PWD.NextString lda (ZPPtr3),y
iny
cmp #':'
bne PWD.NextString
rts
*--------------------------------------
2019-04-25 15:33:56 +00:00
PWD.NextLine iny
2019-04-23 15:47:40 +00:00
lda (ZPPtr3),y
cmp #C.CR
2019-04-25 15:33:56 +00:00
bne PWD.NextLine
2019-04-19 05:42:43 +00:00
2019-04-23 15:47:40 +00:00
tya
sec
adc ZPPtr3
sta ZPPtr3
2019-04-25 15:33:56 +00:00
bcc .8
2019-04-23 15:47:40 +00:00
inc ZPPtr3+1
2019-04-25 15:33:56 +00:00
.8 rts
2019-04-19 05:42:43 +00:00
*--------------------------------------
2019-04-23 15:47:40 +00:00
PWD.Record2PW sta CLRWRITEAUX
2019-04-15 05:40:13 +00:00
ldy #0
2019-04-12 15:41:05 +00:00
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
2019-04-15 05:40:13 +00:00
sta SETWRITEAUX
2019-04-12 15:41:05 +00:00
clc
rts
*--------------------------------------
2019-04-26 15:07:22 +00:00
PWD.GetByte stz ZPPtr4
2019-04-12 15:41:05 +00:00
.1 lda (ZPPtr3),y
iny
cmp #':'
beq .8
and #$f
pha
2019-04-26 15:07:22 +00:00
lda ZPPtr4
2019-04-12 15:41:05 +00:00
asl
asl
clc
2019-04-26 15:07:22 +00:00
adc ZPPtr4
2019-04-12 15:41:05 +00:00
asl
2019-04-26 15:07:22 +00:00
sta ZPPtr4
2019-04-12 15:41:05 +00:00
pla
clc
2019-04-26 15:07:22 +00:00
adc ZPPtr4
sta ZPPtr4
2019-04-12 15:41:05 +00:00
bra .1
2019-04-26 15:07:22 +00:00
.8 lda ZPPtr4
2019-06-11 05:52:24 +00:00
clc
2019-04-12 15:41:05 +00:00
rts
2019-04-09 15:47:33 +00:00
*--------------------------------------
2019-04-11 15:59:57 +00:00
PWD.StoreRecord sec
.HS 90 BCC
*--------------------------------------
PWD.GetRecordLen
clc
ldx #0
ldy #S.PW.NAME-1
2019-04-12 15:41:05 +00:00
jsr PWD.StoreString
2019-04-11 15:59:57 +00:00
lda #':'
jsr PWD.StoreChar
ldy #S.PW.PASSWD-1
2019-04-12 15:41:05 +00:00
jsr PWD.StoreString
2019-04-11 15:59:57 +00:00
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
2019-04-12 15:41:05 +00:00
jsr PWD.StoreString
2019-04-11 15:59:57 +00:00
lda #':'
jsr PWD.StoreChar
ldy #S.PW.DIR-1
2019-04-12 15:41:05 +00:00
jsr PWD.StoreString
2019-04-11 15:59:57 +00:00
lda #':'
jsr PWD.StoreChar
ldy #S.PW.SHELL-1
2019-04-12 15:41:05 +00:00
jsr PWD.StoreString
2019-04-11 15:59:57 +00:00
lda #C.CR
jsr PWD.StoreChar
txa
2019-06-24 15:32:22 +00:00
PWD.GetRecordLen.RTS
2019-04-11 15:59:57 +00:00
rts
*--------------------------------------
2019-04-12 15:41:05 +00:00
PWD.StoreString iny
jsr MEM.TXTPTR.GetY
2019-06-24 15:32:22 +00:00
beq PWD.GetRecordLen.RTS
2019-04-12 15:41:05 +00:00
jsr PWD.StoreChar
bra PWD.StoreString
*--------------------------------------
PWD.StoreByte php
2019-04-11 15:59:57 +00:00
phx
2019-04-12 15:41:05 +00:00
2019-07-10 15:39:02 +00:00
jsr MATH.A2STR10NP
2019-04-11 15:59:57 +00:00
plx
2019-04-12 15:41:05 +00:00
plp
2019-04-11 15:59:57 +00:00
2019-06-24 15:32:22 +00:00
ldy #0
2019-04-12 15:41:05 +00:00
2019-07-03 15:25:07 +00:00
.1 lda A2osX.NumStrBuf,y
2019-06-24 15:32:22 +00:00
beq PWD.GetRecordLen.RTS
2019-04-11 15:59:57 +00:00
2019-06-24 15:32:22 +00:00
iny
2019-04-11 15:59:57 +00:00
2019-06-24 15:32:22 +00:00
jsr PWD.StoreChar
bra .1
2019-04-11 15:59:57 +00:00
*--------------------------------------
PWD.StoreChar inx
2019-04-12 15:41:05 +00:00
bcc .9 Dry run, no store
2019-04-11 15:59:57 +00:00
sta (ZPPtr3)
inc ZPPtr3
bne .9
inc ZPPtr3+1
2019-04-12 15:41:05 +00:00
.9 rts
2019-04-11 15:59:57 +00:00
*--------------------------------------
2019-04-09 15:47:33 +00:00
MAN
SAVE USR/SRC/SYS/KERNEL.S.PWDX
LOAD USR/SRC/SYS/KERNEL.S
ASM