A2osX/SBIN/LOGIN.S.txt

478 lines
8.1 KiB
Plaintext
Raw Normal View History

2015-06-03 18:30:57 +00:00
NEW
2019-04-15 05:40:13 +00:00
AUTO 3,1
2015-06-03 18:30:57 +00:00
.LIST OFF
.OP 65C02
.OR $2000
2019-12-05 15:09:38 +00:00
.TF sbin/login
2015-06-03 18:30:57 +00:00
*--------------------------------------
2018-07-20 05:43:11 +00:00
.INB INC/MACROS.I
.INB INC/A2OSX.I
2019-04-15 15:29:07 +00:00
.INB INC/KERNEL.I
2019-04-16 15:54:56 +00:00
.INB INC/MLI.I
*--------------------------------------
2018-12-18 14:37:07 +00:00
.DUMMY
.OR ZPBIN
ZS.START
2019-06-06 06:37:30 +00:00
ZPhBuf .BS 1
ZPBufPtr .BS 2
2019-04-15 05:40:13 +00:00
ZPRetryCnt .BS 1
ZPbValidUser .BS 1
2019-06-06 15:45:40 +00:00
ZPUID .BS 1
2019-04-15 05:40:13 +00:00
ZPhGetLine .BS 1
ZPGetLinePtr .BS 2
ZPbGetLineSecret .BS 1
2019-04-29 15:47:17 +00:00
ZPbEsc .BS 1
2019-04-15 05:40:13 +00:00
ZPGetLineLen .BS 1
ZPGetLineMax .BS 1
2019-04-16 15:54:56 +00:00
2019-06-06 06:37:30 +00:00
ZPhPW .BS 1
ZPPWPtr .BS 2
2020-02-04 16:27:37 +00:00
hSession .BS 1
ZPNewSID .BS 1
ZPOldSID .BS 1
2019-04-16 15:54:56 +00:00
ZPhFile .BS 1
ZPStrPtr .BS 2
2018-12-18 14:37:07 +00:00
ZS.END
.ED
2015-06-03 18:30:57 +00:00
*--------------------------------------
* File Header (16 Bytes)
*--------------------------------------
CS.START cld
jmp (.1,x)
.DA #$61 6502,Level 1 (65c02)
.DA #1 BIN Layout Version 1
2018-09-19 15:25:42 +00:00
.DA #S.PS.F.EVENT S.PS.F
.DA #0
2018-12-18 14:37:07 +00:00
.DA CS.END-CS.START Code Size (without Constants)
2019-05-05 17:15:37 +00:00
.DA DS.END-DS.START Data Segment Size
2019-10-18 11:41:27 +00:00
.DA #32 Stack Size
2018-12-18 14:37:07 +00:00
.DA #ZS.END-ZS.START Zero Page Size
2015-06-03 18:30:57 +00:00
.DA 0
*--------------------------------------
* Relocation Table
*--------------------------------------
.1 .DA CS.INIT
.DA CS.RUN
.DA CS.DOEVENT
.DA CS.QUIT
2019-04-15 15:29:07 +00:00
L.MSG.NOAUTH .DA MSG.NOAUTH
2015-06-03 18:30:57 +00:00
L.MSG.LOGIN .DA MSG.LOGIN
L.MSG.PASSWORD .DA MSG.PASSWORD
2019-04-15 05:40:13 +00:00
L.MSG.BAD .DA MSG.BAD
L.MSG.CRLF .DA MSG.CRLF
L.MSG.BS .DA MSG.BS
2019-04-16 15:54:56 +00:00
L.ETCISSUE .DA ETCISSUE
L.ETCMOTD .DA ETCMOTD
L.SHELL .DA SHELL
2015-06-03 18:30:57 +00:00
.DA 0
*--------------------------------------
2018-09-19 15:25:42 +00:00
CS.INIT clc
2019-04-16 15:54:56 +00:00
CS.INIT.RTS rts
2015-06-03 18:30:57 +00:00
*--------------------------------------
2019-06-06 15:45:40 +00:00
CS.RUN >LDYAI 33 Enough for HASH
2019-04-16 15:54:56 +00:00
>SYSCALL getmem
bcs CS.INIT.RTS
>STYA ZPGetLinePtr
stx ZPhGetLine
2019-07-24 15:17:08 +00:00
2019-04-16 15:54:56 +00:00
>LDYA L.ETCISSUE
jsr CS.RUN.DUMPFILE
2019-10-19 20:54:59 +00:00
>PUSHWZ Dry Run, no output
2019-06-06 06:37:30 +00:00
* lda #0 ROOT user
2019-03-12 14:41:55 +00:00
>SYSCALL GetPWUID
2019-06-06 15:45:40 +00:00
bcc CS.RUN.AUTH
2019-10-19 20:54:59 +00:00
2020-02-04 14:35:48 +00:00
>LDYA L.MSG.NOAUTH
jsr CS.RUN.StrOut
2019-06-06 15:45:40 +00:00
bcs .9
2020-02-04 14:35:48 +00:00
2020-02-04 16:27:37 +00:00
ldy #S.PS.hSID
lda (pPS),y
tax
lda S.Table.hSession-1,x
sta hSession
2019-10-19 20:54:59 +00:00
2019-06-06 15:45:40 +00:00
jmp CS.RUN.EXEC
2019-10-03 06:25:27 +00:00
.9 rts
2019-04-12 15:41:05 +00:00
*--------------------------------------
2020-01-24 15:54:31 +00:00
CS.RUN.AUTH lda #3
2019-04-15 05:40:13 +00:00
sta ZPRetryCnt
2019-11-20 10:08:49 +00:00
.1 >LDYA L.MSG.LOGIN
jsr CS.RUN.StrOut
bcs .9
2019-11-20 10:08:49 +00:00
2019-04-15 05:40:13 +00:00
lda #16
clc
jsr CS.RUN.GetLine
2019-02-20 16:07:43 +00:00
bcs .9
2019-06-11 05:52:24 +00:00
2019-06-20 15:47:03 +00:00
>PUSHWZ Dry Run
2019-04-15 05:40:13 +00:00
>LDYA ZPGetLinePtr
>SYSCALL GetPWName
ror ZPbValidUser
2019-06-06 15:45:40 +00:00
sta ZPUID
2019-11-20 10:08:49 +00:00
2015-06-03 18:30:57 +00:00
>LDYA L.MSG.PASSWORD
2019-11-20 10:08:49 +00:00
jsr CS.RUN.StrOut
bcs .9
2019-06-06 06:37:30 +00:00
lda #32
2019-04-15 05:40:13 +00:00
sec
jsr CS.RUN.GetLine
2019-02-20 16:07:43 +00:00
bcs .9
2019-06-11 05:52:24 +00:00
2019-04-15 05:40:13 +00:00
>LDYA L.MSG.CRLF
2019-11-20 10:08:49 +00:00
jsr CS.RUN.StrOut
bcs .9
2019-04-12 15:41:05 +00:00
2019-04-16 15:54:56 +00:00
jsr CS.RUN.CHECKPWD
2019-06-06 15:45:40 +00:00
bcs .8
jsr CS.RUN.SetUserSession
bcs .9
jmp CS.RUN.EXEC
2019-10-19 20:54:59 +00:00
2019-11-15 14:40:48 +00:00
.8 >LDYA L.MSG.BAD
>SYSCALL puts
2019-04-15 05:40:13 +00:00
bcs .9
2019-10-19 20:54:59 +00:00
2019-04-15 05:40:13 +00:00
dec ZPRetryCnt
2019-06-06 06:37:30 +00:00
beq .99
2019-10-19 20:54:59 +00:00
2019-06-06 06:37:30 +00:00
jmp .1
2019-10-19 20:54:59 +00:00
2019-06-06 06:37:30 +00:00
.99 lda #E.IUSR
2019-10-03 06:25:27 +00:00
sec
2019-04-15 05:40:13 +00:00
.9 rts
*--------------------------------------
2019-04-16 15:54:56 +00:00
CS.RUN.SetUserSession
2019-04-23 15:47:40 +00:00
ldx #S.SESSION.NAME P+UID+GID
2019-04-16 15:54:56 +00:00
ldy #S.PW.NAME-1
2019-06-06 06:37:30 +00:00
jsr CS.RUN.AddStrLen NAME len
2019-04-16 15:54:56 +00:00
inx
ldy #S.PW.GECOS-1
2019-06-06 06:37:30 +00:00
jsr CS.RUN.AddStrLen GECOS len
2019-04-16 15:54:56 +00:00
inx
ldy #S.PW.DIR-1
2019-06-06 06:37:30 +00:00
jsr CS.RUN.AddStrLen DIR len
2019-04-16 15:54:56 +00:00
inx
2019-04-15 15:29:07 +00:00
2019-04-16 15:54:56 +00:00
ldy #S.PW.SHELL-1
2019-06-06 06:37:30 +00:00
jsr CS.RUN.AddStrLen SHELL len
2019-04-16 15:54:56 +00:00
2019-04-15 15:29:07 +00:00
txa
2019-04-16 15:54:56 +00:00
tay
lda #0
2019-04-15 15:29:07 +00:00
>SYSCALL getmem
2018-11-23 16:20:19 +00:00
bcs .9
2019-04-26 15:07:22 +00:00
2020-02-04 14:35:48 +00:00
>STYA ZPStrPtr
2020-02-04 16:27:37 +00:00
stx hSession
2019-04-16 15:54:56 +00:00
* clc
2019-04-26 15:07:22 +00:00
2019-04-16 15:54:56 +00:00
ldy #S.PW.GID
2019-06-06 06:37:30 +00:00
lda (ZPPWPtr),y
2019-04-16 15:54:56 +00:00
tax
bne .5
sec
.5 ldy #S.PW.UID
2019-06-06 06:37:30 +00:00
lda (ZPPWPtr),y
2019-04-16 15:54:56 +00:00
bne .6
2017-01-12 17:43:45 +00:00
sec
2019-04-16 15:54:56 +00:00
.6 lda #0
ror
jsr CS.RUN.AddByte PRIV
2019-06-06 06:37:30 +00:00
lda (ZPPWPtr),y
2019-04-16 15:54:56 +00:00
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
*--------------------------------------
2019-06-06 15:45:40 +00:00
CS.RUN.CHECKPWD rol ZPbValidUser
bcs CS.RUN.CHECK.9
>LDYAI S.PW
>SYSCALL getmem
bcs CS.RUN.CHECK.9
>STYA ZPPWPtr
stx ZPhPW
2019-10-19 20:54:59 +00:00
2019-06-06 15:45:40 +00:00
>PUSHYA
lda ZPUID
>SYSCALL GetPWUID
bcs CS.RUN.CHECK.9
>PUSHW ZPGetlinePtr
>PUSHW ZPGetlinePtr
2020-01-24 15:54:31 +00:00
>SYSCALL MD5
2019-10-19 20:54:59 +00:00
2019-06-06 15:45:40 +00:00
lda ZPPWPtr
clc
adc #S.PW.PASSWD
tay
lda ZPPWPtr+1
adc /S.PW.PASSWD
2019-10-19 20:54:59 +00:00
2019-06-06 15:45:40 +00:00
>PUSHYA
>LDYA ZPGetlinePtr
>SYSCALL strcmp
2019-10-19 20:54:59 +00:00
bcc CS.RUN.CHECK.9
2019-11-20 10:08:49 +00:00
jsr CS.CLEANUP.hPW
2019-10-19 20:54:59 +00:00
sec
2019-06-06 15:45:40 +00:00
CS.RUN.CHECK.9 rts
*--------------------------------------
2020-02-04 16:27:37 +00:00
CS.RUN.EXEC ldx #1
2019-06-06 15:45:40 +00:00
2020-02-04 16:27:37 +00:00
.1 lda S.Table.hSession-1,x
beq .2
2019-10-19 20:54:59 +00:00
2020-02-04 16:27:37 +00:00
inx
cpx #K.USR.MAX+1
bne .1
2019-10-19 20:54:59 +00:00
2020-02-04 16:27:37 +00:00
lda #E.OOH
* sec
rts
2020-02-04 14:35:48 +00:00
2020-02-04 16:27:37 +00:00
.2 stx ZPNewSID
ldy #S.PS.hSID
lda (pPS),y
sta ZPOldSID
txa
sta (pPS),y
2020-02-04 14:35:48 +00:00
2020-02-04 16:27:37 +00:00
lda hSession
sta S.Table.hSession-1,x
2020-02-04 14:35:48 +00:00
2020-02-04 16:27:37 +00:00
ldy #S.PS.hStdIn
lda (pPS),y
sta S.Table.hFILE-1,x
2019-10-19 20:54:59 +00:00
2019-06-06 15:45:40 +00:00
>LDYA L.ETCMOTD
jsr CS.RUN.DumpFile
jsr CS.CLEANUP
2020-01-24 14:21:08 +00:00
>PUSHW L.SHELL
2019-06-06 15:45:40 +00:00
>PUSHBI S.PS.F.HOLD
>SYSCALL ExecL
bcs .9
2019-10-19 20:54:59 +00:00
2019-06-06 15:45:40 +00:00
>SLEEP
2020-02-04 16:27:37 +00:00
ldx ZPNewSID
lda S.Table.hSession-1,x
stz S.Table.hSession-1,x
stz S.Table.hFILE-1,x
>SYSCALL freemem
ldy #S.PS.hSID
lda ZPOldSID
sta (pPS),y
2019-06-06 15:45:40 +00:00
sec
.9 rts
*--------------------------------------
2019-06-06 06:37:30 +00:00
CS.RUN.AddStrLen
.1 inx
iny
lda (ZPPWPtr),y
bne .1
rts
*--------------------------------------
CS.RUN.AddStr lda (ZPPWPtr),y
2019-04-16 15:54:56 +00:00
jsr CS.RUN.AddByte
iny
tax
bne CS.RUN.AddStr
2015-06-03 18:30:57 +00:00
rts
*--------------------------------------
2019-04-16 15:54:56 +00:00
CS.RUN.AddByte sta (ZPStrPtr)
inc ZPStrPtr
bne .8
inc ZPStrPtr+1
.8 rts
*--------------------------------------
2019-04-15 05:40:13 +00:00
CS.RUN.GetLine sta ZPGetLineMax
ror ZPbGetLineSecret
stz ZPGetLineLen
2019-04-29 15:47:17 +00:00
stz ZPbEsc
2019-10-19 20:54:59 +00:00
2019-04-15 05:40:13 +00:00
.1 >SYSCALL getchar
bcs .9
2019-10-19 20:54:59 +00:00
2019-04-29 15:47:17 +00:00
bit ZPbEsc
bpl .11
2019-10-19 20:54:59 +00:00
2019-05-04 21:13:50 +00:00
* clc
2019-04-29 15:47:17 +00:00
ror ZPbEsc
cmp #'D'
bne .1
2019-10-19 20:54:59 +00:00
2019-04-29 15:47:17 +00:00
bra .3
2019-10-19 20:54:59 +00:00
2019-04-29 15:47:17 +00:00
.11 cmp #C.DEL
beq .3
2019-10-19 20:54:59 +00:00
2019-04-15 05:40:13 +00:00
cmp #C.SPACE
2015-06-03 18:30:57 +00:00
bcc .2
2019-10-19 20:54:59 +00:00
2019-04-15 05:40:13 +00:00
ldy ZPGetLineLen
cpy ZPGetLineMax
beq .1
2019-10-19 20:54:59 +00:00
2019-04-15 05:40:13 +00:00
sta (ZPGetLinePtr),y
2019-04-29 15:47:17 +00:00
inc ZPGetLineLen
2019-04-15 05:40:13 +00:00
bit ZPbGetLineSecret
bmi .1
2019-10-19 20:54:59 +00:00
2019-04-15 05:40:13 +00:00
>SYSCALL putchar
bra .1
2018-12-04 13:20:35 +00:00
2019-04-15 05:40:13 +00:00
.2 cmp #3 Ctrl-C
beq .9
cmp #C.CR
beq .8
2019-10-19 20:54:59 +00:00
2019-04-29 15:47:17 +00:00
cmp #C.ESC
2019-04-15 05:40:13 +00:00
bne .1
2019-10-19 20:54:59 +00:00
2019-04-29 15:47:17 +00:00
* sec
ror ZPbEsc
bra .1
2019-10-19 20:54:59 +00:00
2019-04-29 15:47:17 +00:00
.3 ldy ZPGetLineLen
2018-12-04 13:20:35 +00:00
beq .1
2019-10-19 20:54:59 +00:00
2019-04-15 05:40:13 +00:00
dec ZPGetLineLen
bit ZPbGetLineSecret
bmi .1
2019-10-19 20:54:59 +00:00
2019-04-15 05:40:13 +00:00
>LDYA L.MSG.BS
2019-11-20 10:08:49 +00:00
jsr CS.RUN.StrOut
2019-04-15 05:40:13 +00:00
bra .1
2019-10-19 20:54:59 +00:00
2019-04-15 05:40:13 +00:00
.8 ldy ZPGetLineLen
lda #0
sta (ZPGetLinePtr),y
clc
.9 rts
2015-06-03 18:30:57 +00:00
*--------------------------------------
2020-01-31 20:26:51 +00:00
CS.RUN.StrOut >PUSHYA
2019-11-20 10:08:49 +00:00
>PUSHBI 0
2020-01-31 20:26:51 +00:00
>SYSCALL printf2
2019-11-20 10:08:49 +00:00
rts
*--------------------------------------
2019-04-16 15:54:56 +00:00
CS.RUN.DumpFile pha
2019-06-07 15:02:51 +00:00
>PUSHWZ Aux type
2019-04-16 15:54:56 +00:00
>PUSHBI S.FI.T.TXT
>PUSHBI O.RDONLY+O.TEXT
pla
>SYSCALL FOpen
bcs .9
2019-11-20 10:08:49 +00:00
2019-04-16 15:54:56 +00:00
stx ZPhFile
2019-06-06 06:37:30 +00:00
>LDYAI 256
>SYSCALL getmem
bcs .99
>STYA ZPBufPtr
stx ZPhBuf
2019-11-20 10:08:49 +00:00
2019-04-16 15:54:56 +00:00
.1 >PUSHWI 256
2019-06-06 06:37:30 +00:00
>PUSHW ZPBufPtr
2019-04-16 15:54:56 +00:00
lda ZPhFile
>SYSCALL fgets
2019-06-06 06:37:30 +00:00
bcs .7
2019-11-20 10:08:49 +00:00
2019-06-06 06:37:30 +00:00
>LDYA ZPBufPtr
2020-01-17 11:23:11 +00:00
>SYSCALL Expand
2019-04-16 15:54:56 +00:00
bcc .2
2019-06-06 06:37:30 +00:00
.99 php
2019-04-16 15:54:56 +00:00
pha
jsr .8
pla
plp
2019-06-06 06:37:30 +00:00
.9 rts
2019-10-18 11:41:27 +00:00
2019-04-16 15:54:56 +00:00
.2 phx
2019-06-06 06:37:30 +00:00
>SYSCALL puts
2019-04-16 15:54:56 +00:00
pla
>SYSCALL freemem
bra .1
2019-10-18 11:41:27 +00:00
2019-06-06 06:37:30 +00:00
.7 lda ZPhBuf
>SYSCALL freemem
2019-10-18 11:41:27 +00:00
2019-04-16 15:54:56 +00:00
.8 lda ZPhFile
>SYSCALL fclose
2019-10-03 06:25:27 +00:00
rts
2019-04-16 15:54:56 +00:00
*--------------------------------------
CS.DOEVENT
sec
rts
*--------------------------------------
2020-01-24 15:54:31 +00:00
CS.QUIT
2019-06-06 06:37:30 +00:00
CS.CLEANUP lda ZPhGetLine
2019-11-20 10:08:49 +00:00
beq CS.CLEANUP.hPW
2019-10-18 11:41:27 +00:00
2019-06-06 06:37:30 +00:00
stz ZPhGetLine
2019-04-16 15:54:56 +00:00
>SYSCALL freemem
2019-10-18 11:41:27 +00:00
2019-11-20 10:08:49 +00:00
CS.CLEANUP.hPW lda ZPhPW
2019-04-16 15:54:56 +00:00
beq .8
2019-10-19 20:54:59 +00:00
2019-06-06 06:37:30 +00:00
stz ZPhPW
>SYSCALL freemem
2019-10-18 11:41:27 +00:00
2019-04-16 15:54:56 +00:00
.8 clc
rts
*--------------------------------------
2015-06-03 18:30:57 +00:00
CS.END
2019-04-12 15:41:05 +00:00
*--------------------------------------
2019-04-15 15:29:07 +00:00
MSG.NOAUTH .AS "\r\n\r\nA2osX-Login:No ETC/PASSWD file present, Logged as ROOT.\r\n"
2019-04-15 05:40:13 +00:00
.AS "Consider adding ROOT password with USERADD command.\r\n"
MSG.CRLF .AZ "\r\n"
MSG.LOGIN .AZ "\r\nlogin:"
MSG.PASSWORD .AZ "\r\npassword:"
2019-11-15 14:40:48 +00:00
MSG.BAD .AZ "Bad user or password"
2019-04-15 05:40:13 +00:00
MSG.BS .DA #C.BS,#C.SPACE,#C.BS,#0
2019-12-05 15:09:38 +00:00
ETCISSUE .AZ "${ROOT}etc/issue"
ETCMOTD .AZ "${ROOT}etc/motd"
2019-04-16 15:54:56 +00:00
SHELL .AZ "${SHELL}"
*--------------------------------------
2015-06-03 18:30:57 +00:00
.DUMMY
.OR 0
DS.START
2019-10-19 20:54:59 +00:00
DS.END .ED
2015-06-03 18:30:57 +00:00
*--------------------------------------
MAN
2018-11-17 17:17:13 +00:00
SAVE USR/SRC/SBIN/LOGIN.S
2015-06-03 18:30:57 +00:00
ASM