Kernel 0.93

This commit is contained in:
Rémy GIBERT 2019-04-15 16:29:07 +01:00
parent e27211b92e
commit d93db0b7ce
13 changed files with 218 additions and 63 deletions

View File

@ -113,7 +113,7 @@ CS.RUN.DUMP phx
lda (ZPPSPtr),y lda (ZPPSPtr),y
>PUSHA Parent PID >PUSHA Parent PID
ldy #S.PS.hUsr ldy #S.PS.hSID
lda (ZPPSPtr),y lda (ZPPSPtr),y
>PUSHA >PUSHA

0
BIN/SU.S.txt Normal file
View File

0
BIN/SUDO.S.txt Normal file
View File

0
BIN/USERMOD.S.txt Normal file
View File

View File

@ -57,9 +57,9 @@ CS.RUN >LDYA L.MSG0
lda USR.Table.hFile-1,x lda USR.Table.hFile-1,x
tax tax
lda OF.Table.hPath-1,x
>SYSCALL GetMemPtr jsr CS.RUN.GETIO
>PUSHYA >PUSHYA
ldx USRID ldx USRID
@ -69,16 +69,20 @@ CS.RUN >LDYA L.MSG0
lda ZPPWPtr lda ZPPWPtr
clc clc
adc #19 adc #S.USR.NAME
tay tay
lda ZPPWPtr+1 lda ZPPWPtr+1
adc #0 adc /S.USR.NAME
>PUSHYA >PUSHYA
>PUSHB (ZPPWPtr)
ldy #S.USR.UID
>PUSHB (ZPPWPtr),y
>PUSHB USRID >PUSHB USRID
>PUSHBI 5 >PUSHBI 7
>LDYA L.MSG1 >LDYA L.MSG1
>SYSCALL printf >SYSCALL printf
@ -91,6 +95,26 @@ CS.RUN >LDYA L.MSG0
sec we do not want to stay in memory sec we do not want to stay in memory
.9 rts .9 rts
*-------------------------------------- *--------------------------------------
CS.RUN.GETIO lda OF.Table.hPath-1,x
bne .1
lda OF.Table.hFD-1,x
tax
lda Dev.Table-1,x
clc
adc #S.FD.DEV
tay
lda Dev.Table,x
adc /S.FD.DEV
rts
.1 >SYSCALL GetMemPtr
rts
*--------------------------------------
CS.EVENT sec CS.EVENT sec
rts rts
*-------------------------------------- *--------------------------------------
@ -98,8 +122,8 @@ CS.QUIT clc
rts rts
*-------------------------------------- *--------------------------------------
CS.END CS.END
MSG0 .AZ "Usr Name Dev" MSG0 .AZ "Usr UID Privileges Name Dev"
MSG1 .AZ "%3d %16s %16s\r\n" MSG1 .AZ "%3d %3d %b %16s %16s\r\n"
*-------------------------------------- *--------------------------------------
.DUMMY .DUMMY
.OR 0 .OR 0

View File

@ -29,7 +29,7 @@ ZPLIB .EQ $40 32 bytes
CORE.PSIndex .EQ $D0 CORE.PSIndex .EQ $D0
CORE.PSCount .EQ $D1 CORE.PSCount .EQ $D1
pUser .EQ $D2 pSession .EQ $D2
pEvent .EQ $D4 pEvent .EQ $D4
pPs .EQ $D6 pPs .EQ $D6
*-------------------------------------- *--------------------------------------
@ -147,6 +147,8 @@ SEEK.SET .EQ $00
SEEK.CUR .EQ $02 SEEK.CUR .EQ $02
SEEK.END .EQ $04 SEEK.END .EQ $04
*-------------------------------------- *--------------------------------------
P.SYSADMIN .EQ %10000000
*--------------------------------------
* A2osX.SYSCALL Functions Indexes * A2osX.SYSCALL Functions Indexes
*-------------------------------------- *--------------------------------------
SYS.GetMemStat .EQ $00 SYS.GetMemStat .EQ $00
@ -514,7 +516,7 @@ S.PS.RC .EQ 13
S.PS.ARGC .EQ 14 S.PS.ARGC .EQ 14
S.PS.hARGV .EQ 15 S.PS.hARGV .EQ 15
S.PS.hUsr .EQ 16 S.PS.hSID .EQ 16
S.PS.A .EQ 17 S.PS.A .EQ 17
S.PS.X .EQ 18 S.PS.X .EQ 18
@ -633,5 +635,15 @@ S.PW.SHELL .EQ 182 64+1
* *
S.PW .EQ 247 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
*
*--------------------------------------
MAN MAN
SAVE INC/A2OSX.I SAVE INC/A2OSX.I

View File

@ -21,8 +21,8 @@ PS.Table.Stats .EQ $13E0 K.PS.MAX
OF.Table.hPath .EQ $1400 K.OF.MAX OF.Table.hPath .EQ $1400 K.OF.MAX
OF.Table.hFD .EQ $1420 K.OF.MAX OF.Table.hFD .EQ $1420 K.OF.MAX
*-------------------------------------- *--------------------------------------
USR.Table.hPW .EQ $1440 K.USR.MAX S.Table.hPW .EQ $1440 K.USR.MAX
USR.Table.hFile .EQ $1450 K.USR.MAX S.Table.hFile .EQ $1450 K.USR.MAX
*-------------------------------------- *--------------------------------------
A2osX.EndTables .EQ $1460 A2osX.EndTables .EQ $1460
*-------------------------------------- *--------------------------------------

View File

@ -7,11 +7,16 @@ NEW
*-------------------------------------- *--------------------------------------
.INB INC/MACROS.I .INB INC/MACROS.I
.INB INC/A2OSX.I .INB INC/A2OSX.I
.INB INC/KERNEL.I
.INB INC/LIBCRYPT.I .INB INC/LIBCRYPT.I
*-------------------------------------- *--------------------------------------
.DUMMY .DUMMY
.OR ZPBIN .OR ZPBIN
ZS.START ZS.START
ZPUsrID .BS 1
ZPUsrPtr .BS 2
ZPSessionPtr .BS 2
ZPShellPtr .BS 2
ZPRetryCnt .BS 1 ZPRetryCnt .BS 1
ZPbValidUser .BS 1 ZPbValidUser .BS 1
@ -45,17 +50,14 @@ CS.START cld
.DA CS.RUN .DA CS.RUN
.DA CS.DOEVENT .DA CS.DOEVENT
.DA CS.QUIT .DA CS.QUIT
L.MSG.NOPASSWD .DA MSG.NOPASSWD L.MSG.NOAUTH .DA MSG.NOAUTH
L.LIBCRYPT .DA LIBCRYPT 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.BAD .DA MSG.BAD L.MSG.BAD .DA MSG.BAD
L.MSG.CRLF .DA MSG.CRLF L.MSG.CRLF .DA MSG.CRLF
L.MSG.BS .DA MSG.BS L.MSG.BS .DA MSG.BS
L.ENV.SHELL .DA ENV.SHELL L.USR.ROOT .DA USR.ROOT
L.SHELL .DA SHELL
L.ENV.HOME .DA ENV.HOME
L.HOME .DA HOME
.DA 0 .DA 0
*-------------------------------------- *--------------------------------------
CS.INIT clc CS.INIT clc
@ -66,17 +68,8 @@ CS.RUN >PUSHW pData PW
>SYSCALL GetPWUID >SYSCALL GetPWUID
bcc CS.RUN.AUTH bcc CS.RUN.AUTH
>PUSHBI 0 jmp CS.RUN.NOAUTH
>LDYA L.MSG.NOPASSWD
>SYSCALL printf
bcs CS.RUN.9
jsr CS.RUN.SETENV
bcs CS.RUN.9
>PUSHBI S.PS.F.HOLD
>LDYA L.SHELL
>SYSCALL ExecL
CS.RUN.9 rts CS.RUN.9 rts
*-------------------------------------- *--------------------------------------
CS.RUN.AUTH >LDYA L.LIBCRYPT CS.RUN.AUTH >LDYA L.LIBCRYPT
@ -140,16 +133,8 @@ CS.RUN.AUTH >LDYA L.LIBCRYPT
* sec * sec
.9 rts .9 rts
*-------------------------------------- *--------------------------------------
CS.RUN.LOGIN jsr CS.RUN.SETENV
bcs .9
>PUSHBI S.PS.F.HOLD
>LDYA L.SHELL
>SYSCALL ExecL
.9 rts
*--------------------------------------
CS.RUN.CHECK rol ZPbValidUser CS.RUN.CHECK rol ZPbValidUser
bcs .9 bcs CS.RUN.CHECK.9
>PUSHW ZPGetlinePtr >PUSHW ZPGetlinePtr
>PUSHW ZPGetlinePtr >PUSHW ZPGetlinePtr
@ -159,20 +144,96 @@ CS.RUN.CHECK rol ZPbValidUser
>LDYA ZPGetlinePtr >LDYA ZPGetlinePtr
>SYSCALL strcmp >SYSCALL strcmp
CS.RUN.CHECK.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
.2 iny
lda (ZPUsrPtr),y
bne .2
tya
sec
adc ZPUsrPtr
sta ZPUsrPtr
bcc .3
inc ZPUsrPtr+1
.3 dex
bne .1
>LDYA ZPUsrPtr
>SYSCALL ExecL
bcs .9
ldx ZPUsrID
lda S.Table.hPW-1,x
stz S.Table.hPW-1,x
stz S.Table.hFILE-1,x
>SYSCALL freemem
.9 rts .9 rts
*-------------------------------------- *--------------------------------------
CS.RUN.SETENV >PUSHW L.HOME CS.RUN.SETUSER >STYA ZPUsrPtr
>LDYA L.ENV.HOME
>SYSCALL setenv 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
>SYSCALL getmem
bcs .9 bcs .9
>STYA ZPSessionPtr
>PUSHW L.SHELL txa
>LDYA L.ENV.SHELL ldx ZPUsrID
>SYSCALL setenv sta S.Table.hPW-1,x
bcs .9
ldy #S.PS.hStdIn
lda (pPS),y
sta S.Table.hFILE-1,x
ldy #USR.ROOT.Size-1
.2 lda (ZPUsrPtr),y
sta (ZPSessionPtr),y
dey
bpl .2
clc
rts
.7 inx
cpx #K.USR.MAX+1
bne .1
* sec
.9 rts .9 rts
*-------------------------------------- *--------------------------------------
CS.DOEVENT CS.DOEVENT
@ -249,18 +310,24 @@ CS.END
*-------------------------------------- *--------------------------------------
LIBCRYPT .AZ "libcrypt" LIBCRYPT .AZ "libcrypt"
hLIBCRYPT .BS 1 hLIBCRYPT .BS 1
MSG.NOPASSWD .AS "\r\n\r\nA2osX-Login:No ETC/PASSWD file present, Logged as ROOT.\r\n" MSG.NOAUTH .AS "\r\n\r\nA2osX-Login:No ETC/PASSWD file present, Logged as ROOT.\r\n"
.AS "Consider adding ROOT password with USERADD command.\r\n" .AS "Consider adding ROOT password with USERADD command.\r\n"
MSG.CRLF .AZ "\r\n" MSG.CRLF .AZ "\r\n"
MSG.LOGIN .AZ "\r\nlogin:" MSG.LOGIN .AZ "\r\nlogin:"
MSG.PASSWORD .AZ "\r\npassword:" MSG.PASSWORD .AZ "\r\npassword:"
MSG.BAD .AZ "Bad user or password\r\n" MSG.BAD .AZ "Bad user or password\r\n"
MSG.BS .DA #C.BS,#C.SPACE,#C.BS,#0 MSG.BS .DA #C.BS,#C.SPACE,#C.BS,#0
ENV.SHELL .AZ "SHELL"
ENV.HOME .AZ "HOME"
SHELL .AZ "${ROOT}BIN/SH"
HOME .AZ "${ROOT}ROOT/"
.HS 00 .HS 00
*--------------------------------------
USR.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
*-------------------------------------- *--------------------------------------
.DUMMY .DUMMY
.OR 0 .OR 0

View File

@ -299,10 +299,7 @@ CORE.Dispatch stz CORE.PSIndex
cpx CORE.PSCount cpx CORE.PSCount
bne .1 bne .1
.9 sec * sec
rts
.8 clc
rts rts
*-------------------------------------- *--------------------------------------
* X unmodified * X unmodified
@ -395,6 +392,13 @@ CORE.PSSelect ldy #S.PS.ZP+ZPBIN.SIZE-1
dex dex
bpl .1 bpl .1
ldy #S.PS.hSID
lda (pPs),y
tax
lda S.Table.hPW-1,x
jsr K.GetmemPtr
>STYA pSession
rts rts
*-------------------------------------- *--------------------------------------
CORE.PSLeave ldy #S.PS.ZP+ZPBIN.SIZE-1 CORE.PSLeave ldy #S.PS.ZP+ZPBIN.SIZE-1

View File

@ -532,20 +532,63 @@ ENV.SysVarsJmp .DA ENV.SysVarsArgs
.DA ENV.SysVarsPID .DA ENV.SysVarsPID
.DA ENV.SysVarsCPID .DA ENV.SysVarsCPID
*-------------------------------------- *--------------------------------------
ENV.StrVars >PSTR "PWD" ENV.StrVars >PSTR "USERNAME"
>PSTR "GECOS"
>PSTR "HOME"
>PSTR "SHELL"
>PSTR "PWD"
>PSTR "UID" >PSTR "UID"
>PSTR "GID"
.DA #0 .DA #0
*-------------------------------------- *--------------------------------------
ENV.StrVarsJmp .DA ENV.StrVarsPWD ENV.StrVarsJmp .DA ENV.StrVarsSession
.DA ENV.StrVarsSession
.DA ENV.StrVarsSession
.DA ENV.StrVarsSession
.DA ENV.StrVarsPWD
.DA ENV.StrVarsUID .DA ENV.StrVarsUID
.DA ENV.StrVarsGID
*-------------------------------------- *--------------------------------------
ENV.StrVarsPWD ldy #S.PS.hPREFIX ENV.StrVarsPWD ldy #S.PS.hPREFIX
lda (pPS),y lda (pPS),y
jsr K.GetMemPtr jsr K.GetMemPtr
jmp ENV.AddYAToBuf jmp ENV.AddYAToBuf
*-------------------------------------- *--------------------------------------
ENV.StrVarsUID ldy #S.PS.hUsr ENV.StrVarsUID ldy #S.USR.UID
.HS 2C .HS 2C
ENV.StrVarsGID ldy #S.USR.GID
lda (pSession),y
bra ENV.SysVarsNum
ENV.StrVarsSession
>DEBUG
lda pSession
clc
adc #S.USR.NAME
sta ZPPtr3
lda pSession+1
adc /S.USR.NAME
sta ZPPtr3+1
.1 dex
dex
bmi .3
ldy #$ff
.2 iny
lda (ZPPtr3),y
bne .2
tya
sec
adc ZPPtr3
sta ZPPtr3
bcc .1
inc ZPPtr3+1
bra .1
.3 jmp ENV.AddP3ToBuf
*-------------------------------------- *--------------------------------------
ENV.SysVarsArgC ldy #S.PS.ARGC ENV.SysVarsArgC ldy #S.PS.ARGC
.HS 2C .HS 2C
@ -558,7 +601,7 @@ ENV.SysVarsPID ldy #S.PS.PID
ENV.SysVarsCPID ldy #S.PS.CPID ENV.SysVarsCPID ldy #S.PS.CPID
lda (pPS),y lda (pPS),y
stz .2+1 ENV.SysVarsNum stz .2+1
stz .3+1 stz .3+1
ldx #8 ldx #8

View File

@ -336,7 +336,7 @@ MemMgrInit >LDYAI Mem.MHiMem
ldx #K.USR.MAX*2-1 ldx #K.USR.MAX*2-1
.6 stz USR.Table.hPW,x .6 stz S.Table.hPW,x
dex dex
bpl .6 bpl .6
@ -1088,23 +1088,24 @@ PwdMgrInit >LDYAI MSG.PWD
*-------------------------------------- *--------------------------------------
.1 >LDYAI PwdMgr.ROOT.Size .1 >LDYAI PwdMgr.ROOT.Size
jsr K.Getmem jsr K.Getmem
>STYA pUser >STYA pSession
stx USR.Table.hPW stx S.Table.hPW
ldy #PwdMgr.ROOT.Size-1 ldy #PwdMgr.ROOT.Size-1
.2 lda PwdMgr.ROOT,y .2 lda PwdMgr.ROOT,y
sta (pUser),y sta (pSession),y
dey dey
bpl .2 bpl .2
ldy #S.PS.hStdIn ldy #S.PS.hStdIn
lda (pPS),y lda (pPS),y
sta USR.Table.hFile sta S.Table.hFile
rts rts
*-------------------------------------- *--------------------------------------
PwdMgr.ROOT .DA #0 UID PwdMgr.ROOT .DA #P.SYSADMIN
.DA #0 UID
.DA #0 GID .DA #0 GID
.BS 17 PASSWD .BS 17 PASSWD
.AZ "ROOT" NAME .AZ "ROOT" NAME

View File

@ -169,6 +169,10 @@ PS.CreateChild ldx #0
cpy #S.PS.hStdErr+1 cpy #S.PS.hStdErr+1
bne .81 bne .81
ldy #S.PS.hSID
lda (pPs),y
sta (PS.NewPSPtr),y
lda #S.PS.F.NOHUP lda #S.PS.F.NOHUP
bit PS.Flags bit PS.Flags
bne .5 bne .5

View File

@ -55,7 +55,6 @@ A2osX.D2 .PH $D000
.INB USR/SRC/SYS/KERNEL.S.TIME .INB USR/SRC/SYS/KERNEL.S.TIME
.INB USR/SRC/SYS/KERNEL.S.BIN .INB USR/SRC/SYS/KERNEL.S.BIN
.INB USR/SRC/SYS/KERNEL.S.PS .INB USR/SRC/SYS/KERNEL.S.PS
.INB USR/SRC/SYS/KERNEL.S.ARG
.INB USR/SRC/SYS/KERNEL.S.ENV .INB USR/SRC/SYS/KERNEL.S.ENV
.INB USR/SRC/SYS/KERNEL.S.MATH .INB USR/SRC/SYS/KERNEL.S.MATH
.EP .EP
@ -68,6 +67,7 @@ A2osX.E0 .PH $E000
.INB USR/SRC/SYS/KERNEL.S.PFT .INB USR/SRC/SYS/KERNEL.S.PFT
.INB USR/SRC/SYS/KERNEL.S.IO .INB USR/SRC/SYS/KERNEL.S.IO
********* TMP ***** go to A2osX.D2 ********* TMP ***** go to A2osX.D2
.INB USR/SRC/SYS/KERNEL.S.ARG
.INB USR/SRC/SYS/KERNEL.S.PWD .INB USR/SRC/SYS/KERNEL.S.PWD
.LIST ON .LIST ON
DevMgr.FreeMem .EQ * DevMgr.FreeMem .EQ *