home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
UNIFLEX
/
UNIFLEX
/
UniFLEX_Std.Utils1.tar.Z
/
UniFLEX_Std.Utils1.tar
/
utils1
/
newuser
< prev
next >
Wrap
Text File
|
1984-02-01
|
11KB
|
601 lines
opt nol
opt pag
ttl Newuser Program
lib sysdef
pag
opt lis
info UniFLEX newuser
info Version 1.00, Released Feb 3, 1984
info Copyright, (C) 1984, by
info Technical Systems Consultants, Inc.
info All rights reserved.
* constants
ECHO equ %00000010 echo bit
LCASE equ %00001000 lower case bit
CR equ $d carriage return
st_siz equ 9 status size offset
* newuser program
org 0
login sys cpint,2,1 catch INTS
sys cpint,3,1 catch QUITS
ldd #0 set user id to 0
sta pwex
sys suid
ldd #2 close file 2
sys close
ldd #1 get standard out file desc
sys dup duplicate the file (error chan)
ldd #0 set priority bias
sys setpr
ldd #0 set file desc
sys ttyget,ttbuf
lda ttbuf get flag bits
anda #%10111110
sta ttbuf set back in buffer
ldd #0 set file desc
sys ttyset,ttbuf
ldd 0,s get arg count
ldx #buffer point to buffer
ldu 4,s point to name
cmpd #2 name specified?
bhs login0
ldu #sysnam point to "system" string
login0 lda 0,u+ xfr name to buffer
sta 0,x+
bne login0
logi25 lbsr fndnam find login name in file
bec login3 error?
inc ngflg set no good ind
inc pwex set flag
login3 tst pwex password exist?
beq login4 if not - no prompt
lda ttbuf get flags
anda #!ECHO turn off echo
sta ttbuf
ldd #0 set file desc
sys ttyset,ttbuf
ldd #1 set file desc
sys write,pswst,PSZ output 'Password'
ldd #0 set file desc
sys read,buffer,32 read response
pshs d save count
lda ttbuf get tty flags
ora #ECHO set echo on
sta ttbuf
ldd #0 set file desc
sys ttyset,ttbuf set status
ldd #1 set file desc
sys write,crst,1 write out cr
puls d get count
cmpd #0 end of file?
lbeq nogud
ldx #buffer-1 point to buffer
clr d,x set null term
login4 tst ngflg no good set?
lbne nogud if so, error
lbsr chkps check password
lbes nogud error?
logi45 lbsr getid get user id from file
lbes nogud
lbsr setdr set up user's dir
bec login5 error?
ldd #1 set file desc
sys write,ndrms,NDSZ write error message
ldd #$ff
sys term terminate task
login5 ldd usrid get user id
std icho2 set up os call
sys ind,icho change tty owner
ldd usrid get user id
sys suid set user id
lbsr mkhom write home file
lda [nxtfld] program specified?
cmpa #$d if null - do shell
bne login6
lbsr chkml check for mail
sys exec,shell,args
sys term
login6 ldx nxtfld get field pointer
stx subrg2 set up call
login7 lda 0,x+ look for line end
cmpa #$d is it cr?
bne login7
clr -1,x set line end
sys exec,shell,subrg execute the program thru shell
sys term error?
pag
* print file message
prtmsg stx iopn2 save file name in ind call
sys ind,iopn do file open for read (ind)
bes prtms8 error?
pshs d save file desc
prtms2 ldd 0,s get file desc
sys read,buffer,32 read in file
bes prtms5 error?
std iwrt2 set count in ind call
beq prtms5
ldd #1 set file desc
sys ind,iwrt do write
bra prtms2 repeat
prtms5 puls d get file desc
sys close close the file
prtms8 rts return
*
* nogud
*
* Report incorrect login
*
nogud lda ttbuf get ttyset flags
anda #!LCASE reset lower case bit
sta ttbuf
ldd #0 set file desc
sys ttyset,ttbuf reset data
ldd #1 set file desc
sys write,ngmsg,NGSZ write out message
ldd #$ff
sys term
*
* mkhom
*
* Create the 'home*' file which contains the name of
* this guys login directory. This is used by shell.
*
mkhom sys create,homnm,$1b create file
bes mkhom6 if error - skip
pshs d save file desc
ldx ichd2 get ptr to dir name
stx ihwrt2 set up os call
ldd #0 set counter to 0
mkhom2 tst 0,x+ get size of string
beq mkhom3
incb
bra mkhom2
mkhom3 incb
std ihwrt3 save count in call
ldd 0,s get file desc
sys ind,ihwrt output name
puls d get file desc
sys close close the file
mkhom6 rts return
pag
*
* fndnam
*
* Find name in password file. Return error set
* if error.
*
fndnam ldx #fbuf point to file buffer
stx linpt init buf ptrs
stx linend
sys open,nfile,0 open password file
bes fndna4 error?
std namfd save file desc
fndna2 bsr getlin get a line from the file
beq fndna5 eof?
ldx #buffer point to name
ldy #linbuf point to line
bsr cmpnam compare names
bne fndna2 if no compare, repeat
sty nxtfld save field pointer
lda 0,y check for null pw
cmpa #':
beq fndna3
inc pwex set pw flag
fndna3 ldd namfd get file desc
sys close close the file
clc clear error
fndna4 rts return
fndna5 ldd namfd get file desc
sys close close the file
sec set error
rts return
*
* getlin
*
* Get a line from the password file. Put it
* in the linbuf.
*
getlin ldx #linbuf point to line buffer
getli2 bsr gtch get a character
beq getli4 eof?
sta 0,x+ save character in buffer
cmpa #CR end of line?
bne getli2
clz set ok status
getli4 rts return
pag
*
* gtch
*
* Get a character from the password file. Return
* eq status if eof.
*
gtch pshs x save x
gtch2 ldx linpt get line pointer
cmpx linend end of buffer?
bne gtch4
ldd namfd get file desc
sys read,fbuf,512 read in some file
bes gtch6 error?
cmpd #0 eof?
beq gtch6
ldx #fbuf point to buffer begin
stx linpt save pointer
leax d,x mark end of buffer
stx linend
ldx linpt reset pointer
gtch4 lda 0,x+ get next character
stx linpt save pointer
clz set ok status
puls x,pc return
gtch6 sez set error
puls x,pc return
*
* cmpnam
*
* Compare name pointed at by X to name pointed
* at by Y. Return eq or ne status.
*
cmpnam lda 0,x+ get a character
beq cmpna4 end of name?
cmpa 0,y+ compare chars
beq cmpnam repeat?
rts return ne
cmpna4 lda 0,y+ get next
beq cmpna6 null?
cmpa #': end of field?
cmpna6 rts return
pag
*
* decvt
*
* Decimal convert routine. Convert ascii string
* pointed at by x and null terminated.
* Return number in D and ne if error.
*
decvt ldd #0 set up zero
pshs d
decvt2 lda 0,x+ get character
beq decvt4 end of list?
cmpa #'0 check for valid number
blo decvt3 error?
cmpa #'9
bhi decvt3
anda #$F mask character
pshs a save digit
ldd 1,s get number
aslb multiply by 8
rola
aslb
rola
aslb
rola
addd 1,s add in original twice
addd 1,s
addb 0,s+ add in new digit
adca #0
std 0,s save result
bra decvt2 repeat
decvt3 clz set error
decvt4 puls d,pc return
pag
*
* chkps
*
* Check for valid password. Return carry set on error.
*
chkps pshs d save count
bsr gtnxt get next field
puls d reset count
tst pwex pw exist?
beq chkps4
cmpd #1 check for eof or cr
bls chkps3 if so, error
pshs x save buffer pointer
ldx #buffer point to name
pshs x save as arg
ldx #encpw point to encryption buffer
pshs x save as arg
lbsr crypt do encryption
leas 4,s clean stack
lbsr mkasc make ascii string
puls x
ldy #ascpw point to encrypted pswd
lbsr cmpnam compare names
beq chkps4
chkps3 sec set error
rts return
chkps4 clc clear error
rts return
pag
*
* gtnxt
*
* Get next field from linbuf
*
gtnxt ldx nxtfld get field pointer
pshs x save it
gtnxt2 lda 0,x+ get character
cmpa #': is it term?
bne gtnxt2
clr -1,x set null term
stx nxtfld set next ptr
puls x,pc return
*
* getid
*
* Get user id from password file.
*
getid bsr gtnxt get next field
lbsr decvt convert number to binary
bne getid4 error?
std usrid save id
clc set ok status
rts return
getid4 sec set error
rts return
*
* setdr
*
* Setup new user directory.
*
setdr bsr gtnxt get next field
stx ichd2 set in ind call
sys ind,ichd do chdir
rts return
pag
*
* chkml
*
* Check for mail file.
*
chkml sys status,malnm,stb check status
bes chkml6 if error, no mail
ldd stb+st_siz+2 check size of file
bne chkml4 if != 0, then mail
ldd stb+st_siz
beq chkml6
chkml4 ldd #1 set file desc
sys write,mlstr,MLSZ output message
chkml6 rts return
*
* mkasc
*
* Make encrypted password an ascii string.
*
mkasc ldb #8 set count
pshs b
ldx #encpw point to password
ldy #ascpw point to buffer
mkasc2 lda 0,x get a byte
anda #$f mask low 4 bits
adda #'k make a letter
sta 0,y+ save in buffer
lda 0,x+ get byte
lsra shift to get hi 4 bits
lsra
lsra
lsra
adda #'a make a letter
sta 0,y+ add to buffer
dec 0,s dec the count
bne mkasc2 repeat?
puls b,pc return
pag
** CRYPT - ENCRYPT PASSWORD.
*
* ENTRY (2,S)=POINTER TO 8 BYTE RESPONSE AREA
* (4,S)=POINTER TO PASSWORD, TERMINATED BY
* A ZERO BYTE
SPC 2
crypt LDX 2,S (X)=ADDRESS OF RESPONSE AREA
LDY 4,S (Y)=ADDRESS OF PASSWORD
LDA #251 SET LOOP COUNTER
PSHS A
LEAS -8,S RESERVE WORK SPACE
CLRB (B)=INDEX/COUNTER
* COPY PASSWORD TO RESPONSE AND WORK AREAS.
crypt1 LDA 0,Y+
BNE crypt2 IF NOT END OF PASSWORD
LEAY -1,Y BACK UP POINTER
crypt2 STA B,X STORE IN RESPONSE AREA
STA B,S STORE IN WORK AREA
INCB COUNT CHARACTER
CMPB #8
BLO crypt1 LOOP FOR 8 BYTES
* TAUSWORTHE RANDOM NUMBER GENERATOR.
* ADAPTED FROM THE ALGORITHM OF E. J. WATSON,
* UNIVERSITY OF MANCHESTER.
* ALGORITHM DOCUMENTED IN CACM, VOL 11, NO. 9, SEPT, 1968
* P. 643.
* VALUES USED: N=63, M=31
* TO BE CONSISTENT WITH ALGORITHM, BITS NUMBERS ARE FROM
* LEFT TO RIGHT, STARTING AT ZERO.
crypt4 LDA 4,S PUT BIT 32 IN CARRY
LSLA
LDD 2,S (D)=BITS 16-31
ROLB
ROLA (D)=BITS 17-32, CARRY=BIT 16
EORB 7,S BITS 17-32 XOR BITS 48-63
EORA 6,S
STD 6,S REPLACE BITS 48-63
EORB 3,S NEW 48-64 XOR BITS 16-31
EORA 2,S
STD 2,S REPLACE BITS 16-31
LDD 0,S (D)=BITS 0-15
ROLB
ROLA (D)=BITS 1-16
EORB 5,S BITS 1-16 XOR BITS 32-47
EORA 4,S
STD 4,S REPLACE BITS 32-47
EORB 1,S NEW 32-47 XOR BITS 0-15
EORA 0,S
STD 0,S REPLACE BITS 0-15
DEC 8,S COUNT ITERATION
BNE crypt4 REPEAT 8 TIMES
LDB #7 (B)=BYTE COUNTER
ANDCC #$FE CLEAR CARRY
crypt5 LDA B,S ADD BACK ORIGINAL PASSWORD
ADCA B,X
STA B,X
DECB
BPL crypt5
LEAS 9,S CLEAN UP STACK
RTS RETURN
pag
* indirect calls
iopn fcb open
iopn2 fdb 0,0
iwrt fcb write
fdb buffer
iwrt2 fdb 0
ichd fcb chdir ind chdir call
ichd2 fdb 0
isk fcb seek ind seek call
fdb 0
isk2 fdb 0,0
icho fcb chown change owner
fdb ttchn
icho2 fdb 0
ihwrt fcb write
ihwrt2 fdb 0
ihwrt3 fdb 0
* constant strings
sysnam fcc 'system',0
homnm fcc '.home?',0
shell fcc '/bin/shell',0
args fdb shelln,0
shelln fcc '+shell',0
nfile fcc '/etc/log/password',0
malnm fcc '.mail',0
cptst fcc '+cx',0
ttydir fcc '/dev',0
ttnam fcc 'tty'
ttnam2 fcc 'xx',0
spcs fcc ' '
ttchn fcc '/dev/tty'
ttchn2 fcc 'xx',0
ngmsg fcc 'Login incorrect!',$d,$d
NGSZ equ *-ngmsg
pswst fcc 'Password: '
PSZ equ *-pswst
ndrms fcc 'No directory!'
NDSZ equ *-ndrms
mlstr fcc 'You have mail.',$d
MLSZ equ *-mlstr
bdtr fcc 'Bad terminal.',$d
BDSZ equ *-bdtr
crst fcb $d carriage string
subrg fdb shell+5,cptst
subrg2 fdb 0,0
* buffers
r0 fdb 0,0 regs for div and mul
r1 fdb 0,0
work fdb 0,0
day fdb 0 day temp
ntime fdb 0,0 new time
eutc fcb 0 east of utc flag
fstdl fdb 0 1st day of dlst
lstdl fdb 0 last day of dlst
dlflg fcb 0 dlst flag
ltime fdb 0,0 local time
tzn fdb 0,0 time zone seconds
ttbuf rmb 6 ttyset buffer
buffer rmb 32
ngflg fcb 0 no good flag
nxtfld fdb 0 next field pointer
namfd fdb 0 name file descriptor
linpt fdb 0 line pointer
linend fdb 0 end of line pointer
usrid fdb 0 user id
pwex fcb 0 pw exists flag
noban fcb 0 if banner should not be displayed
stb rmb 24 status buffer
encpw rmb 8 password buffer
ascpw rmb 16 ascii pswd buffer
fcb 0 null term for above
curtim rmb 8 current time
rmb 4 spare
ttybuf rmb 16 tty buffer
ttystb rmb 24 tty status buffer
linbuf rmb 128 line buffer
org $E00
fbuf rmb 512 file buffer
end login