A2osX/BIN/USERMOD.S.txt

246 lines
5.0 KiB
Plaintext
Raw Normal View History

2020-07-31 06:37:02 +00:00
NEW
AUTO 3,1
.LIST OFF
.OP 65C02
.OR $2000
.TF bin/usermod
*--------------------------------------
USER.MAX .EQ 16
PASS.MAX .EQ 64
*--------------------------------------
.INB inc/macros.i
.INB inc/a2osx.i
*--------------------------------------
* Zero Page Segment, up to 32 bytes
*--------------------------------------
.DUMMY
.OR ZPBIN
ZS.START
ArgIndex .BS 1
ArgUsername .BS 1
ZPStrPtr .BS 2
ZPTmpPtr .BS 2
ZS.END .ED
*--------------------------------------
* File Header (16 Bytes)
*--------------------------------------
CS.START cld
jmp (.1,x)
.DA #$61 6502,Level 1 (65c02)
.DA #1 BIN Layout Version 1
.DA #0 S.PS.F.EVENT
.DA #0
.DA CS.END-CS.START Code Size (without Constants)
.DA DS.END-DS.START Data Segment Size
.DA #64 Stack Size
.DA #ZS.END-ZS.START Zero Page Size
.DA 0
*--------------------------------------
* Relocation Table
*--------------------------------------
.1 .DA CS.INIT
.DA CS.RUN
2020-07-31 10:28:04 +00:00
.DA CS.DOEVENT
2020-07-31 06:37:02 +00:00
.DA CS.QUIT
L.MSG.USAGE .DA MSG.USAGE
L.MSG.CRLF .DA MSG.CRLF
2020-07-31 10:28:04 +00:00
L.MSG.BS .DA MSG.BS
2020-07-31 06:37:02 +00:00
J.CS.RUN.CheckArg
.DA CS.RUN.CheckArg.C
.DA CS.RUN.CheckArg.D
.DA CS.RUN.CheckArg.P
.DA CS.RUN.CheckArg.S
.DA 0
*--------------------------------------
* Called once at process creation
* Put code for loading LIB here
*--------------------------------------
CS.INIT clc
rts
*--------------------------------------
* Called until exit with CS
* if RUN exits with CC, RN entered again
*--------------------------------------
2020-07-31 10:28:04 +00:00
CS.RUN ldy #S.PS.ARGC
lda (pPS),y
beq .9
2020-07-31 06:37:02 +00:00
jsr CS.RUN.CheckArg
2020-07-31 10:28:04 +00:00
bcs .99
2020-07-31 06:37:02 +00:00
>PUSHW pData
2020-08-25 14:54:30 +00:00
>SYSCALL PutPW
2020-07-31 06:37:02 +00:00
bcs .99
2020-07-31 10:28:04 +00:00
2020-07-31 06:37:02 +00:00
lda #0
sec
rts
.9 >PUSHW L.MSG.USAGE
>PUSHBI 0
>SYSCALL PrintF
lda #E.SYN
sec
.99 rts
*--------------------------------------
CS.RUN.CheckArg inc ArgIndex
lda ArgIndex
>SYSCALL ArgV
bcs .8
>STYA ZPStrPtr
lda (ZPStrPtr)
cmp #'-'
bne .4
2020-07-31 10:28:04 +00:00
lda ArgUsername
beq CS.RUN.CheckArg.9
2020-07-31 06:37:02 +00:00
ldy #1
lda (ZPStrPtr),y
ldx #OptionCnt-1
2020-07-31 10:28:04 +00:00
2020-07-31 06:37:02 +00:00
.2 cmp OptionList,x
beq .3
dex
bpl .2
lda #E.SYN
sec
rts
2020-07-31 10:28:04 +00:00
2020-07-31 06:37:02 +00:00
.3 txa
and #$fe
tax
jmp (J.CS.RUN.CheckArg,x)
*--------------------------------------
.4 lda ArgUsername
bne CS.RUN.CheckArg.9
lda ArgIndex
sta ArgUsername
>SYSCALL ArgV
>PUSHYA
2020-07-31 10:28:04 +00:00
>PUSHW pData
2020-07-31 06:37:02 +00:00
>SYSCALL GetPWName
2020-07-31 10:28:04 +00:00
bcs .9
2020-07-31 06:37:02 +00:00
bra CS.RUN.CheckArg
2020-07-31 10:28:04 +00:00
.8 lda ArgUsername
2020-07-31 06:37:02 +00:00
beq CS.RUN.CheckArg.9
2020-07-31 10:28:04 +00:00
2020-07-31 06:37:02 +00:00
clc
rts
2020-07-31 10:28:04 +00:00
.9 lda #E.IUSR
2020-07-31 06:37:02 +00:00
sec
rts
CS.RUN.CheckArg.9
lda #E.SYN
sec
rts
*--------------------------------------
CS.RUN.CheckArg.P
inc ArgIndex
lda ArgIndex
>SYSCALL ArgV
bcs CS.RUN.CheckArg.9
>PUSHYA
>PUSHEA.G S.PW.PASSWD
>SYSCALL MD5
jmp CS.RUN.CheckArg
*--------------------------------------
CS.RUN.CheckArg.C
inc ArgIndex
lda ArgIndex
>SYSCALL ArgV
bcs CS.RUN.CheckArg.9
ldx #S.PW.GECOS
bra CS.RUN.CheckArg.Next
*--------------------------------------
CS.RUN.CheckArg.D
inc ArgIndex
lda ArgIndex
>SYSCALL ArgV
bcs CS.RUN.CheckArg.9
ldx #S.PW.DIR
bra CS.RUN.CheckArg.Next
*--------------------------------------
CS.RUN.CheckArg.S
inc ArgIndex
lda ArgIndex
>SYSCALL ArgV
bcs CS.RUN.CheckArg.9
2020-07-31 10:28:04 +00:00
2020-07-31 06:37:02 +00:00
ldx #S.PW.SHELL
CS.RUN.CheckArg.Next
>STYA ZPStrPtr
2020-07-31 10:28:04 +00:00
2020-07-31 06:37:02 +00:00
* clc
txa
adc pData
sta ZPTmpPtr
lda pData+1
adc #0
sta ZPTmpPtr+1
2020-07-31 10:28:04 +00:00
2020-07-31 06:37:02 +00:00
ldy #$ff
.1 iny
lda (ZPStrPtr),y
sta (ZPTmpPtr),y
beq .8
cpy #64
bne .1
lda #0
sta (ZPTmpPtr),y
2020-07-31 10:28:04 +00:00
2020-07-31 06:37:02 +00:00
.8 jmp CS.RUN.CheckArg
*--------------------------------------
CS.RUN.MkDir >PUSHEA.G S.PW.DIR
>PUSHWI S.STAT.MODE.RO+S.STAT.MODE.RG+S.STAT.MODE.FU
>SYSCALL MKDir
rts
*--------------------------------------
* Called if option S.PS.F.EVENT enabled in Header
* Timer Event : every 10th seconds
*--------------------------------------
CS.DOEVENT sec
rts
*--------------------------------------
* Called once, when RUN exited with CS
* Put code for unloading LIB here
*--------------------------------------
2020-07-31 10:28:04 +00:00
CS.QUIT clc
2020-07-31 06:37:02 +00:00
rts
*--------------------------------------
CS.END
*--------------------------------------
OptionList .AS "CcDdPpSs"
OptionCnt .EQ *-OptionList
*--------------------------------------
* Initialized DATA
*--------------------------------------
MSG.USAGE .AS "Usage : USERMOD username\r\n"
.AS " -c : Comment (GECOS)\r\n"
.AS " -d : Home Directory\r\n"
.AS " -p : Password\r\n"
2020-07-31 10:28:04 +00:00
.AS " -s : Shell"
MSG.CRLF .AZ "\r\n"
MSG.BS .DA #C.BS,#C.SPACE,#C.BS,#0
2020-07-31 06:37:02 +00:00
*--------------------------------------
.DUMMY
.OR 0
2020-07-31 10:28:04 +00:00
DS.START
2020-07-31 06:37:02 +00:00
PW .BS S.PW
2020-07-31 10:28:04 +00:00
DS.END .ED
2020-07-31 06:37:02 +00:00
*--------------------------------------
MAN
SAVE usr/src/bin/usermod.s
ASM