From da36e67682573db32e62232c160f4d59c04c7335 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20GIBERT?= Date: Fri, 12 Apr 2019 16:41:05 +0100 Subject: [PATCH] Kernel 0.93 --- BIN/USERADD.S.txt | 6 +- INC/A2osX.I.txt | 2 +- SBIN/LOGIN.S.txt | 36 ++++-- SYS/KERNEL.S.PWD.txt | 3 +- SYS/KERNEL.S.PWDX.txt | 273 +++++++++++++++++++++++++++++++++++------- 5 files changed, 266 insertions(+), 54 deletions(-) diff --git a/BIN/USERADD.S.txt b/BIN/USERADD.S.txt index 5bd9b2be..a26ac520 100644 --- a/BIN/USERADD.S.txt +++ b/BIN/USERADD.S.txt @@ -89,6 +89,10 @@ CS.RUN >LDYAI S.PW .1 + >PUSHBI 0 + >LDYA L.MSG.USAGE + >SYSCALL printf + .8 lda #0 sec rts @@ -242,7 +246,7 @@ LIBCRYPT .AZ "libcrypt" hLIBCRYPT .BS 1 *-------------------------------------- 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 " -p : Password\r\n" .AS " -s : Shell\r\n" diff --git a/INC/A2osX.I.txt b/INC/A2osX.I.txt index d60831c9..9dc3c0f9 100644 --- a/INC/A2osX.I.txt +++ b/INC/A2osX.I.txt @@ -627,7 +627,7 @@ S.PW.PASSWD .EQ 17 32+1 S.PW.UID .EQ 50 S.PW.GID .EQ 51 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 .EQ 247 diff --git a/SBIN/LOGIN.S.txt b/SBIN/LOGIN.S.txt index 7124485e..f32daf49 100644 --- a/SBIN/LOGIN.S.txt +++ b/SBIN/LOGIN.S.txt @@ -39,6 +39,7 @@ CS.START cld .DA CS.DOEVENT .DA CS.QUIT L.MSG.NOPASSWD .DA MSG.NOPASSWD +L.LIBCRYPT .DA LIBCRYPT L.MSG.LOGIN .DA MSG.LOGIN L.MSG.PASSWORD .DA MSG.PASSWORD L.MSG.ECHOCRLF .DA MSG.ECHOCRLF @@ -55,15 +56,28 @@ CS.INIT clc CS.RUN >PUSHEA.G PW lda #0 >SYSCALL GetPWUID - bcc .10 + bcc CS.RUN.AUTH >PUSHBI 0 >LDYA L.MSG.NOPASSWD >SYSCALL printf - bcs .9 - bra .8 + bcs CS.RUN.9 -.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 >LDYA L.MSG.LOGIN @@ -99,8 +113,8 @@ CS.RUN >PUSHEA.G PW >LDYA L.MSG.ECHOCRLF >SYSCALL printf bcs .9 - -.8 jsr CS.RUN.SETENV + + jsr CS.RUN.SETENV bcs .9 >PUSHBI S.PS.F.HOLD+S.PS.F.DUPENV @@ -126,7 +140,12 @@ CS.DOEVENT sec rts *-------------------------------------- -CS.QUIT clc +CS.QUIT lda hLIBCRYPT + beq .8 + + >SYSCALL UnloadLib + +.8 clc rts *-------------------------------------- * PRIVATE @@ -219,6 +238,9 @@ INPUT.LINEIN ldy #INPUT.Status rts *-------------------------------------- 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" .AZ "Consider adding ROOT password with USERADD command.\r\n\r\n" MSG.LOGIN .AZ "\r\nlogin:" diff --git a/SYS/KERNEL.S.PWD.txt b/SYS/KERNEL.S.PWD.txt index 51baff4e..1c9cf329 100644 --- a/SYS/KERNEL.S.PWD.txt +++ b/SYS/KERNEL.S.PWD.txt @@ -49,8 +49,7 @@ K.PutPW.1 sta SETREADAUX bne PWD.Store .9 rts *-------------------------------------- -PWD.Store >DEBUG - lda PWD.DBPtr +PWD.Store lda PWD.DBPtr sta A1L clc adc PWD.DBSize diff --git a/SYS/KERNEL.S.PWDX.txt b/SYS/KERNEL.S.PWDX.txt index 58d1d456..df871c9d 100644 --- a/SYS/KERNEL.S.PWDX.txt +++ b/SYS/KERNEL.S.PWDX.txt @@ -13,15 +13,99 @@ X.PWD jmp (.1-SYS.GetPWUID,x) * ....\CR * \0 *-------------------------------------- -PWD.GetPWUID -*-------------------------------------- -PWD.GetPWName - lda PWD.hDB +PWD.GetPWUID lda PWD.hDB 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 + sec + 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 + rts + +.99 lda #E.IUSR + sec + rts *-------------------------------------- PWD.PutPW >LDYA ZPPtr2 >STYA TXTPTR @@ -41,8 +125,7 @@ PWD.PutPW >LDYA ZPPtr2 sec rts *-------------------------------------- -PWD.InitDB - jsr PWD.GetRecordLen +PWD.InitDB jsr PWD.GetRecordLen >STYA PWD.DBSize jsr K.getmem @@ -57,7 +140,117 @@ PWD.InitDB clc .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 .HS 90 BCC @@ -68,21 +261,15 @@ PWD.GetRecordLen ldy #S.PW.NAME-1 -.1 iny - jsr MEM.TXTPTR.GetY - jsr PWD.StoreChar - bne .1 + jsr PWD.StoreString lda #':' jsr PWD.StoreChar ldy #S.PW.PASSWD-1 -.2 iny - jsr MEM.TXTPTR.GetY - jsr PWD.StoreChar - bne .2 - + jsr PWD.StoreString + lda #':' jsr PWD.StoreChar @@ -103,30 +290,21 @@ PWD.GetRecordLen * iny S.PW.GECOS -.3 iny - jsr MEM.TXTPTR.GetY - jsr PWD.StoreChar - bne .3 + jsr PWD.StoreString lda #':' jsr PWD.StoreChar ldy #S.PW.DIR-1 -.4 iny - jsr MEM.TXTPTR.GetY - jsr PWD.StoreChar - bne .4 + jsr PWD.StoreString lda #':' jsr PWD.StoreChar ldy #S.PW.SHELL-1 -.5 iny - jsr MEM.TXTPTR.GetY - jsr PWD.StoreChar - bne .5 + jsr PWD.StoreString lda #C.CR jsr PWD.StoreChar @@ -137,14 +315,24 @@ PWD.GetRecordLen 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 - phx ldx #8 sed - + .1 asl pha .2 lda #$ff Self Modified @@ -161,6 +349,7 @@ PWD.StoreByte stz .2+1 cld plx + plp lda .3+1 beq .4 @@ -168,37 +357,35 @@ PWD.StoreByte stz .2+1 jsr PWD.StoreChar30 .4 lda .2+1 - pha + beq PWD.StoreChar30 + + php lsr lsr lsr lsr + plp + + and #$0f plp corrupt Z beq .5 jsr PWD.StoreChar30 -.5 pla +.5 lda .2+1 and #$0f - -.8 jsr PWD.StoreChar30 - - clc - rts *-------------------------------------- PWD.StoreChar30 ora #$30 PWD.StoreChar inx - pha - bcc .9 Dry run no store + bcc .9 Dry run, no store sta (ZPPtr3) inc ZPPtr3 bne .9 inc ZPPtr3+1 -.9 pla - rts +.9 rts *-------------------------------------- MAN SAVE USR/SRC/SYS/KERNEL.S.PWDX