Kernel 0.93

This commit is contained in:
Rémy GIBERT 2019-04-16 16:54:56 +01:00
parent d93db0b7ce
commit 2232b123ed
8 changed files with 282 additions and 143 deletions

View File

@ -18,10 +18,8 @@ CL.Quit >LDA.G CL.hCLBuf
.9 rts
*--------------------------------------
CL.PrintPrompt >LDYA L.ENV.PS1
>SYSCALL GetEnv
bcs .1
CL.PrintPrompt >LDYA L.PS1
>SYSCALL ExpandStr
bcs .9

View File

@ -78,13 +78,7 @@ CMD.CD lda (ZPArgVBufPtr)
CMD.CD.0 >LDYA ZPArgVBufPtr
bra CMD.CD.YA
CMD.CD.HOME >LDYA L.ENV.HOME
>SYSCALL GetEnv
bcc CMD.CD.YA
>LDYA L.ENV.ROOT
>SYSCALL GetEnv
bcs CMD.PWD
CMD.CD.HOME >LDYA L.HOME
CMD.CD.YA >SYSCALL realpath
bcs CMD.POPD.RTS

View File

@ -115,11 +115,6 @@ L.MSG.BATCHERR .DA MSG.BATCHERR
L.MSG.ERROR .DA MSG.ERROR
L.MSG.PRINTENV .DA MSG.PRINTENV
L.MSG.PID .DA MSG.PID
L.ENV.ROOT .DA ENV.ROOT
L.ENV.PATH .DA ENV.PATH
L.ENV.PWD .DA ENV.PWD
L.ENV.PS1 .DA ENV.PS1
L.ENV.HOME .DA ENV.HOME
L.FMT.DATE .DA FMT.DATE
L.FMT.TIME .DA FMT.TIME
L.FMT.GETKEY .DA FMT.GETKEY
@ -189,7 +184,9 @@ J.EXP.OP.MATH .DA M32.Add
.DA M32.Div
.DA M32.Mod
L.EXP.OP.LOGIC .DA EXP.OP.LOGIC
L.HOME .DA HOME
L.HOME.PROFILE .DA HOME.PROFILE
L.PS1 .DA PS1
L.M32.Printf .DA M32.Printf
L.ERR.Codes .DA ERR.Codes
L.ERR.Messages .DA ERR.Messages
@ -589,12 +586,9 @@ FMT.DATE .AZ "%A (%w), %B %d %Y"
FMT.TIME .AZ "%H:%M:%S (%I:%M:%S%p)"
FMT.GETKEY .AZ "%d"
*--------------------------------------
ENV.ROOT .AZ "ROOT"
ENV.PATH .AZ "PATH"
ENV.PWD .AZ "PWD"
ENV.PS1 .AZ "PS1"
ENV.HOME .AZ "HOME"
HOME .AZ "${HOME}"
HOME.PROFILE .AZ "${HOME}PROFILE"
PS1 .AZ "${PS1}"
.HS 00 To Make It ArgV
*--------------------------------------
CMD .AZ ".."

View File

@ -50,12 +50,10 @@ CS.RUN >LDYA L.MSG0
ldx #1
stx USRID
>DEBUG
.1 lda USR.Table.hPW-1,x
.1 lda S.Table.hPW-1,x
beq .7
lda USR.Table.hFile-1,x
lda S.Table.hFile-1,x
tax
jsr CS.RUN.GETIO
@ -63,21 +61,21 @@ CS.RUN >LDYA L.MSG0
>PUSHYA
ldx USRID
lda USR.Table.hPW-1,x
lda S.Table.hPW-1,x
>SYSCALL GetMemPtr
>STYA ZPPWPtr
lda ZPPWPtr
clc
adc #S.USR.NAME
adc #S.SESSION.NAME
tay
lda ZPPWPtr+1
adc /S.USR.NAME
adc /S.SESSION.NAME
>PUSHYA
>PUSHB (ZPPWPtr)
ldy #S.USR.UID
ldy #S.SESSION.UID
>PUSHB (ZPPWPtr),y
>PUSHB USRID
@ -122,7 +120,7 @@ CS.QUIT clc
rts
*--------------------------------------
CS.END
MSG0 .AZ "Usr UID Privileges Name Dev"
MSG0 .AZ "SID UID Privileges Name Dev"
MSG1 .AZ "%3d %3d %b %16s %16s\r\n"
*--------------------------------------
.DUMMY

View File

@ -635,14 +635,13 @@ S.PW.SHELL .EQ 182 64+1
*
S.PW .EQ 247
*--------------------------------------
S.USR.PRIV .EQ 0
S.USR.UID .EQ 1
S.USR.GID .EQ 2
S.USR.PASSWD .EQ 3
S.USR.NAME .EQ 20
*S.USR.GECOS .EQ 0
*S.USR.DIR .EQ 0
*S.USR.SHELL .EQ 0
S.SESSION.PRIV .EQ 0
S.SESSION.UID .EQ 1
S.SESSION.GID .EQ 2
S.SESSION.NAME .EQ 3
*S.SESSION.GECOS .EQ 0
*S.SESSION.DIR .EQ 0
*S.SESSION.SHELL .EQ 0
*
*--------------------------------------
MAN

View File

@ -8,6 +8,7 @@ NEW
.INB INC/MACROS.I
.INB INC/A2OSX.I
.INB INC/KERNEL.I
.INB INC/MLI.I
.INB INC/LIBCRYPT.I
*--------------------------------------
.DUMMY
@ -15,7 +16,7 @@ NEW
ZS.START
ZPUsrID .BS 1
ZPUsrPtr .BS 2
ZPSessionPtr .BS 2
ZPShellPtr .BS 2
ZPRetryCnt .BS 1
ZPbValidUser .BS 1
@ -25,11 +26,14 @@ ZPGetLinePtr .BS 2
ZPbGetLineSecret .BS 1
ZPGetLineLen .BS 1
ZPGetLineMax .BS 1
ZPhSID .BS 1
ZPhFile .BS 1
ZPStrPtr .BS 2
ZS.END
.ED
*--------------------------------------
INPUT.BUF.SIZE .EQ 16
*--------------------------------------
* File Header (16 Bytes)
*--------------------------------------
CS.START cld
@ -57,34 +61,38 @@ L.MSG.PASSWORD .DA MSG.PASSWORD
L.MSG.BAD .DA MSG.BAD
L.MSG.CRLF .DA MSG.CRLF
L.MSG.BS .DA MSG.BS
L.USR.ROOT .DA USR.ROOT
L.SESSION.ROOT .DA SESSION.ROOT
L.ETCISSUE .DA ETCISSUE
L.ETCMOTD .DA ETCMOTD
L.SHELL .DA SHELL
.DA 0
*--------------------------------------
CS.INIT clc
rts
CS.INIT.RTS rts
*--------------------------------------
CS.RUN >PUSHW pData PW
CS.RUN >LDYAI 256
>SYSCALL getmem
bcs CS.INIT.RTS
>STYA ZPGetLinePtr
stx ZPhGetLine
>LDYA L.ETCISSUE
jsr CS.RUN.DUMPFILE
>PUSHW pData PW
lda #0
>SYSCALL GetPWUID
bcc CS.RUN.AUTH
jmp CS.RUN.NOAUTH
CS.RUN.9 rts
*--------------------------------------
CS.RUN.AUTH >LDYA L.LIBCRYPT
>SYSCALL LoadLib
bcs CS.RUN.9
bcs CS.INIT.RTS
sta hLIBCRYPT
>LDYAI 256
>SYSCALL getmem
bcs CS.RUN.9
>STYA ZPGetLinePtr
stx ZPhGetLine
lda #3
sta ZPRetryCnt
@ -118,7 +126,7 @@ CS.RUN.AUTH >LDYA L.LIBCRYPT
>SYSCALL printf
bcs .9
jsr CS.RUN.CHECK
jsr CS.RUN.CHECKPWD
bcc CS.RUN.LOGIN
>PUSHBI 0
@ -133,7 +141,7 @@ CS.RUN.AUTH >LDYA L.LIBCRYPT
* sec
.9 rts
*--------------------------------------
CS.RUN.CHECK rol ZPbValidUser
CS.RUN.CHECKPWD rol ZPbValidUser
bcs CS.RUN.CHECK.9
>PUSHW ZPGetlinePtr
@ -146,46 +154,55 @@ CS.RUN.CHECK rol ZPbValidUser
CS.RUN.CHECK.9 rts
*--------------------------------------
CS.RUN.LOGIN jsr CS.RUN.SetUserSession
bcc CS.RUN.EXEC
CS.RUN.LOGIN.9 rts
*--------------------------------------
CS.RUN.NOAUTH >PUSHBI 0
>LDYA L.MSG.NOAUTH
>SYSCALL printf
bcs CS.RUN.CHECK.9
>LDYA L.USR.ROOT
CS.RUN.LOGIN jsr CS.RUN.SETUSER
bcs .9
>PUSHBI S.PS.F.HOLD
lda ZPUsrPtr
clc
adc #S.USR.NAME
sta ZPUsrPtr
lda ZPUsrPtr+1
adc /S.USR.NAME
sta ZPUsrPtr+1
ldx #3 Skip NAME,GECOS,DIR
.1 ldy #$ff
jsr CS.RUN.SetRootSession
bcs CS.RUN.LOGIN.9
.2 iny
lda (ZPUsrPtr),y
bne .2
tya
sec
adc ZPUsrPtr
sta ZPUsrPtr
bcc .3
inc ZPUsrPtr+1
.3 dex
CS.RUN.EXEC ldx #1
.1 lda S.Table.hPW-1,x
beq .2
inx
cpx #K.USR.MAX+1
bne .1
>LDYA ZPUsrPtr
lda #E.OOH
* sec
rts
.2 stx ZPUsrID
txa
ldy #S.PS.hSID
sta (pPS),y
txa
ldx ZPUsrID
sta S.Table.hPW-1,x
ldy #S.PS.hStdIn
lda (pPS),y
sta S.Table.hFILE-1,x
>LDYA L.ETCMOTD
jsr CS.RUN.DumpFile
>PUSHBI S.PS.F.HOLD
>LDYA L.SHELL
>SYSCALL ExecL
bcs .9
>SLEEP
ldx ZPUsrID
lda S.Table.hPW-1,x
stz S.Table.hPW-1,x
@ -194,65 +211,128 @@ CS.RUN.LOGIN jsr CS.RUN.SETUSER
.9 rts
*--------------------------------------
CS.RUN.SETUSER >STYA ZPUsrPtr
ldx #1
.1 lda S.Table.hPW-1,x
bne .7
stx ZPUsrID
txa
ldy #S.PS.hSID
sta (pPS),y
>LDYAI USR.ROOT.Size
CS.RUN.SetRootSession
>LDYA L.SESSION.ROOT
>STYA ZPUsrPtr
>LDYAI SESSION.ROOT.Size
>SYSCALL getmem
bcs .9
>STYA ZPSessionPtr
>STYA pSession
stx ZPhSID
txa
ldx ZPUsrID
sta S.Table.hPW-1,x
ldy #S.PS.hStdIn
lda (pPS),y
sta S.Table.hFILE-1,x
ldy #USR.ROOT.Size-1
ldy #SESSION.ROOT.Size-1
.2 lda (ZPUsrPtr),y
sta (ZPSessionPtr),y
sta (pSession),y
dey
bpl .2
clc
rts
.7 inx
cpx #K.USR.MAX+1
bne .1
* sec
.9 rts
* clc
.9 rts
*--------------------------------------
CS.DOEVENT
CS.RUN.SetUserSession
ldx #S.SESSION.NAME PRIV+UID+GID
ldy #S.PW.NAME-1
.1 inx
iny
lda (pData),y
bne .1 NAME len
inx
ldy #S.PW.GECOS-1
.2 inx
iny
lda (pData),y
bne .2 GECOS len
inx
ldy #S.PW.DIR-1
.3 inx
iny
lda (pData),y
bne .3 DIR len
inx
ldy #S.PW.SHELL-1
.4 inx
iny
lda (pData),y
bne .4 SHELL len
txa
tay
lda #0
>SYSCALL getmem
bcs .9
>STYA pSession
>STYA ZPStrPtr
stx ZPhSID
* clc
ldy #S.PW.GID
lda (pData),y
tax
bne .5
sec
rts
.5 ldy #S.PW.UID
lda (pData),y
bne .6
sec
.6 lda #0
ror
jsr CS.RUN.AddByte PRIV
lda (pData),y
jsr CS.RUN.AddByte UID
txa
jsr CS.RUN.AddByte GID
ldy #S.PW.NAME
jsr CS.RUN.AddStr
ldy #S.PW.GECOS
jsr CS.RUN.AddStr
ldy #S.PW.DIR
jsr CS.RUN.AddStr
ldy #S.PW.SHELL
jsr CS.RUN.AddStr
lda #0
jsr CS.RUN.AddByte
clc
.9 rts
*--------------------------------------
CS.QUIT lda ZPhGetLine
beq .1
>SYSCALL freemem
.1 lda hLIBCRYPT
beq .8
>SYSCALL UnloadLib
.8 clc
CS.RUN.AddStr lda (pData),y
jsr CS.RUN.AddByte
iny
tax
bne CS.RUN.AddStr
rts
*--------------------------------------
CS.RUN.AddByte sta (ZPStrPtr)
inc ZPStrPtr
bne .8
inc ZPStrPtr+1
.8 rts
*--------------------------------------
CS.RUN.GetLine sta ZPGetLineMax
ror ZPbGetLineSecret
stz ZPGetLineLen
@ -306,6 +386,84 @@ CS.RUN.GetLine sta ZPGetLineMax
.9 rts
*--------------------------------------
CS.RUN.DumpFile pha
>PUSHWI 0 Aux type
>PUSHBI S.FI.T.TXT
>PUSHBI O.RDONLY+O.TEXT
pla
>SYSCALL FOpen
bcs .9
stx ZPhFile
.1 >PUSHWI 256
>PUSHW ZPGetLinePtr
lda ZPhFile
>SYSCALL fgets
bcs .8
>LDYA ZPGetLinePtr
>SYSCALL ExpandStr
bcc .2
php
pha
jsr .8
pla
plp
rts
.2 phx
>STYA ZPStrPtr
ldy #$ff
.3 iny
lda (ZPStrPtr),y
bne .3
lda #C.CR
sta (ZPStrPtr),y
iny
lda #C.LF
sta (ZPStrPtr),y
iny
lda #0
sta (ZPStrPtr),y
>PUSHBI 0
>LDYA ZPStrPtr
>SYSCALL printf
pla
>SYSCALL freemem
bra .1
.8 lda ZPhFile
>SYSCALL fclose
.9 rts
*--------------------------------------
CS.DOEVENT
sec
rts
*--------------------------------------
CS.QUIT lda ZPhGetLine
beq .1
>SYSCALL freemem
.1 lda hLIBCRYPT
beq .8
>SYSCALL UnloadLib
.8 clc
rts
*--------------------------------------
CS.END
*--------------------------------------
LIBCRYPT .AZ "libcrypt"
@ -317,17 +475,18 @@ MSG.LOGIN .AZ "\r\nlogin:"
MSG.PASSWORD .AZ "\r\npassword:"
MSG.BAD .AZ "Bad user or password\r\n"
MSG.BS .DA #C.BS,#C.SPACE,#C.BS,#0
.HS 00
ETCISSUE .AZ "${ROOT}ETC/ISSUE"
ETCMOTD .AZ "${ROOT}ETC/MOTD"
SHELL .AZ "${SHELL}"
*--------------------------------------
USR.ROOT .DA #P.SYSADMIN
SESSION.ROOT .DA #P.SYSADMIN
.DA #0 UID
.DA #0 GID
.BS 17 PASSWD
.AZ "ROOT" NAME
.AZ "Root User" GECOS
.AZ "${ROOT}ROOT/" DIR
.AZ "${ROOT}BIN/SH" SHELL
USR.ROOT.Size .EQ *-USR.ROOT
SESSION.ROOT.Size .EQ *-SESSION.ROOT
*--------------------------------------
.DUMMY
.OR 0

View File

@ -532,7 +532,7 @@ ENV.SysVarsJmp .DA ENV.SysVarsArgs
.DA ENV.SysVarsPID
.DA ENV.SysVarsCPID
*--------------------------------------
ENV.StrVars >PSTR "USERNAME"
ENV.StrVars >PSTR "LOGNAME"
>PSTR "GECOS"
>PSTR "HOME"
>PSTR "SHELL"
@ -554,20 +554,18 @@ ENV.StrVarsPWD ldy #S.PS.hPREFIX
jsr K.GetMemPtr
jmp ENV.AddYAToBuf
*--------------------------------------
ENV.StrVarsUID ldy #S.USR.UID
ENV.StrVarsUID ldy #S.SESSION.UID
.HS 2C
ENV.StrVarsGID ldy #S.USR.GID
ENV.StrVarsGID ldy #S.SESSION.GID
lda (pSession),y
bra ENV.SysVarsNum
ENV.StrVarsSession
>DEBUG
lda pSession
clc
adc #S.USR.NAME
adc #S.SESSION.NAME
sta ZPPtr3
lda pSession+1
adc /S.USR.NAME
adc /S.SESSION.NAME
sta ZPPtr3+1
.1 dex

View File

@ -1107,7 +1107,6 @@ PwdMgrInit >LDYAI MSG.PWD
PwdMgr.ROOT .DA #P.SYSADMIN
.DA #0 UID
.DA #0 GID
.BS 17 PASSWD
.AZ "ROOT" NAME
.AZ "Root User" GECOS
.AZ "${ROOT}ROOT/" DIR