A2osX/SBIN/LOGIN.S.txt

359 lines
6.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
2020-02-04 16:27:37 +00:00
ZPNewSID .BS 1
ZPOldSID .BS 1
2019-04-16 15:54:56 +00:00
2020-03-12 16:44:11 +00:00
ZPNewSession .BS 1
ZPOldSession .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
2020-02-28 07:21:46 +00:00
>SYSCALL GetMem
2019-04-16 15:54:56 +00:00
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
2020-02-17 16:55:02 +00:00
lda #0
>PUSHA ROOT user
2020-03-12 16:44:11 +00:00
>PUSHA
>PUSHA Dry Run, no output
2019-03-12 14:41:55 +00:00
>SYSCALL GetPWUID
2019-06-06 15:45:40 +00:00
bcc CS.RUN.AUTH
2020-03-12 16:44:11 +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-03-13 07:15:58 +00:00
2020-03-12 16:44:11 +00:00
ldy #S.PS.hSession
2020-02-04 16:27:37 +00:00
lda (pPS),y
tax
2020-03-12 16:44:11 +00:00
lda S.Table.hSID-1,x
sta ZPNewSID
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
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
2020-03-12 16:44:11 +00:00
bra *
2019-06-06 15:45:40 +00:00
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
2020-02-28 07:21:46 +00:00
>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
*--------------------------------------
2020-02-04 16:27:37 +00:00
CS.RUN.EXEC ldx #1
2019-06-06 15:45:40 +00:00
2020-03-13 16:10:36 +00:00
*.1 lda S.Table.hSID-1,x
* beq .2
* inx
* cpx #K.USR.MAX+1
* bne .1
* lda #E.OOH
** sec
* rts
.2
* stx ZPNewSession
* ldy #S.PS.hSession
* lda (pPS),y
* sta ZPOldSession
2020-02-04 16:27:37 +00:00
2020-03-13 16:10:36 +00:00
* txa
* sta (pPS),y
2020-02-04 14:35:48 +00:00
2020-03-13 16:10:36 +00:00
* lda ZPNewSID
* sta S.Table.hSID-1,x
2020-02-04 14:35:48 +00:00
2020-03-13 16:10:36 +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
2020-03-13 16:10:36 +00:00
* lda ZPOldSID
* beq .8
2020-03-12 16:44:11 +00:00
2020-03-13 16:10:36 +00:00
* >SYSCALL CloseSession
2020-03-12 16:44:11 +00:00
2020-03-13 16:10:36 +00:00
* stz ZPOldSID
2020-03-12 16:44:11 +00:00
2020-03-13 16:10:36 +00:00
*.8 ldx ZPNewSession
* lda S.Table.hSID-1,x
* stz S.Table.hSID-1,x
* stz S.Table.hFILE-1,x
2020-03-12 16:44:11 +00:00
* >SYSCALL FreeMem
2020-03-13 16:10:36 +00:00
* ldy #S.PS.hSession
* lda ZPOldSession
* sta (pPS),y
2020-02-04 16:27:37 +00:00
2019-06-06 15:45:40 +00:00
sec
.9 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-02-28 07:21:46 +00:00
>SYSCALL PrintF
2019-11-20 10:08:49 +00:00
rts
*--------------------------------------
2020-02-14 07:21:56 +00:00
CS.RUN.DumpFile >PUSHYA
2019-04-16 15:54:56 +00:00
>PUSHBI O.RDONLY+O.TEXT
2020-02-14 07:21:56 +00:00
>PUSHBI S.FI.T.TXT
>PUSHWZ Aux type
2019-04-16 15:54:56 +00:00
>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
2020-02-28 07:21:46 +00:00
>SYSCALL GetMem
2019-06-06 06:37:30 +00:00
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
2020-02-14 07:21:56 +00:00
>PUSHW ZPBufPtr
>PUSHWI 0
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
2020-02-28 07:21:46 +00:00
>SYSCALL PutS
2019-04-16 15:54:56 +00:00
pla
2020-02-28 07:21:46 +00:00
>SYSCALL FreeMem
2019-04-16 15:54:56 +00:00
bra .1
2019-10-18 11:41:27 +00:00
2019-06-06 06:37:30 +00:00
.7 lda ZPhBuf
2020-02-28 07:21:46 +00:00
>SYSCALL FreeMem
2019-10-18 11:41:27 +00:00
2019-04-16 15:54:56 +00:00
.8 lda ZPhFile
2020-02-28 07:21:46 +00:00
>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
2020-03-12 16:44:11 +00:00
beq .8
2019-10-18 11:41:27 +00:00
2019-06-06 06:37:30 +00:00
stz ZPhGetLine
2020-02-28 07:21:46 +00:00
>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