USERADD : checks for valid username chars

This commit is contained in:
burniouf 2023-12-19 10:20:45 +01:00
parent 27a14a992b
commit 3d0a9afe6d
1 changed files with 61 additions and 21 deletions

View File

@ -54,7 +54,6 @@ L.MSG.ROOTPWD2 .DA MSG.ROOTPWD2
L.MSG.MISMATCH .DA MSG.MISMATCH
L.MSG.CRLF .DA MSG.CRLF
L.MSG.BS .DA MSG.BS
*L.ROOT .DA ROOT
J.CS.RUN.CheckArg
.DA CS.RUN.CheckArg.C
.DA CS.RUN.CheckArg.D
@ -149,7 +148,9 @@ CS.RUN.ROOT ldy #0
>PUSHBI 0
>SYSCALL PrintF
bcs .9
jsr CS.RUN.GetStr
.90 bcs .9
>PUSHW ZPStrPtr
@ -160,13 +161,8 @@ CS.RUN.ROOT ldy #0
>SYSCALL StrCmp
bcs .99
* jsr CS.RUN.TEST
>PUSHW pData
>SYSCALL PutPW
* jsr CS.RUN.TEST
bcs .9
lda #0
@ -179,33 +175,30 @@ CS.RUN.ROOT ldy #0
sec
rts
*--------------------------------------
*CS.RUN.TEST php
* pha
* >PUSHW L.ROOT
* >PUSHWI 0
* >SYSCALL GetEnv
* phx
* >SYSCALL PutS
* pla
* >SYSCALL FreeMem
* pla
* plp
* rts
*--------------------------------------
CS.RUN.GetStr stz ZPStrLen
.1 >SYSCALL GetChar
bcs .9
cmp #C.SPACE
bcc .2
ldy ZPStrLen
cpy ZPStrMax
beq .1
sta (ZPStrPtr),y
bit ZPbStrSecret
bmi .10
jsr CS.RUN.IsValidChar
bcs .1
.10 sta (ZPStrPtr),y
iny
sty ZPStrLen
bit ZPbStrSecret
bmi .1
>SYSCALL PutChar
bra .1
@ -214,10 +207,13 @@ CS.RUN.GetStr stz ZPStrLen
cmp #C.CR
beq .8
cmp #C.BS
bne .1
ldy ZPStrLen
beq .1
dec ZPStrLen
bit ZPbStrSecret
bmi .1
@ -226,6 +222,7 @@ CS.RUN.GetStr stz ZPStrLen
>PUSHBI 0
>SYSCALL PrintF
bra .1
.8 ldy ZPStrLen
lda #0
sta (ZPStrPtr),y
@ -233,6 +230,7 @@ CS.RUN.GetStr stz ZPStrLen
>PUSHW L.MSG.CRLF
>PUSHBI 0
>SYSCALL PrintF
.9 rts
*--------------------------------------
CS.RUN.CheckArg inc ArgIndex
@ -252,6 +250,7 @@ CS.RUN.CheckArg inc ArgIndex
.2 cmp OptionList,x
beq .3
dex
bpl .2
@ -276,6 +275,8 @@ CS.RUN.CheckArg inc ArgIndex
adc /S.PW.DIR+11
sta ZPTmpPtr+1
stz ZPbStrSecret
ldy #0
.5 lda (ZPStrPtr),y
@ -283,6 +284,9 @@ CS.RUN.CheckArg inc ArgIndex
sta (ZPTmpPtr),y
beq .6
jsr CS.RUN.IsValidChar
bcs CS.RUN.CheckArg.9
iny
cpy #16
bne .5
@ -300,10 +304,11 @@ CS.RUN.CheckArg inc ArgIndex
>SYSCALL GetPWName
bcc .9
bra CS.RUN.CheckArg
jmp CS.RUN.CheckArg
.8 lda ArgUsername
beq CS.RUN.CheckArg.9
clc
rts
@ -320,6 +325,7 @@ CS.RUN.CheckArg.P
lda ArgIndex
>SYSCALL ArgV
bcs CS.RUN.CheckArg.9
>PUSHYA
>PUSHEA.G S.PW.PASSWD
>SYSCALL MD5
@ -330,6 +336,7 @@ CS.RUN.CheckArg.C
lda ArgIndex
>SYSCALL ArgV
bcs CS.RUN.CheckArg.9
ldx #S.PW.GECOS
bra CS.RUN.CheckArg.Next
*--------------------------------------
@ -338,6 +345,7 @@ CS.RUN.CheckArg.D
lda ArgIndex
>SYSCALL ArgV
bcs CS.RUN.CheckArg.9
ldx #S.PW.DIR
bra CS.RUN.CheckArg.Next
*--------------------------------------
@ -374,6 +382,34 @@ CS.RUN.CheckArg.Next
.8 jmp CS.RUN.CheckArg
*--------------------------------------
CS.RUN.IsValidChar
cmp #'z'+1
bcs .99
cmp #'a'
bcs .8
cmp #'Z'+1
bcs .99
cmp #'A'
bcs .8
cpy #0
bcs .99
cmp #'0'
bcc .9
cmp #'9'+1
rts
.9 sec
.99 rts
.8 clc
rts
*--------------------------------------
CS.RUN.MkDir >PUSHEA.G S.PW.DIR
>PUSHWI S.STAT.MODE.RO+S.STAT.MODE.RG+S.STAT.MODE.FU
>SYSCALL MKDir
@ -391,10 +427,14 @@ CS.DOEVENT sec
*--------------------------------------
CS.QUIT lda ZPhStr
beq .1
>SYSCALL FreeMem
.1 lda ZPhPW
beq .2
>SYSCALL FreeMem
.2 clc
rts
*--------------------------------------