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
/
login
< prev
next >
Wrap
Text File
|
1984-04-11
|
24KB
|
1,249 lines
opt nol
opt pag
ttl Login Program
lib sysdef
pag
opt lis
info UniFLEX login
info Version 1.05, Released April 11, 1984
info Copyright, (C) 1981, 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
* structures
* ulgtab
org 0
ul_tty rmb 2 tty name
ul_nam rmb 10 user name
ul_tim rmb 4 time
USIZ equ *
* login 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
lbsr gtinfo get tty & time info
ldd 0,s get arg count
cmpd #2 name present?
blo login1
inc noban do not display banner
ldx #buffer point to buffer
ldu 4,s point to name
login0 lda 0,u+ xfr name to buffer
sta 0,x+
bne login0
bra logi25
login1 ldx #lgmsg point to loggin message file name
lbsr prtmsg print the message
lbsr idlin output id line
login2 clr ngflg clear out no good flag
clr pwex clear out password exists flag
ldd #1 set file desc 1
sys write,logst,LSZ output 'Login'
ldd #0 set file desc
sys read,buffer,32 read in response
cmpd #1 eof?
bls login2 if so, repeat
ldx #buffer-1 point to buffer start
clr d,x set null term
logi25 lbsr fixcs fix upper/lower case
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?
beq login2 repeat if so
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?
lda noban check for banner message
bne logi45 if no banner to be printed
ldx #motd point to motd file name
lbsr prtmsg print the message
logi45 lbsr getid get user id from file
lbes login2 error?
lbsr setdr set up user's dir
bec login5 error?
ldd #1 set file desc
sys write,ndrms,NDSZ write error message
sys term terminate task
login5 sys time,ulgtab+ul_tim get system time
lbsr upduf update user file
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
sys time,ulgtab+ul_tim get current time
sys open,bdlgfl,1 open attempts file
bes nogud4 if error - skip this
pshs d save file desc
sys seek,0,0,2 seek to eof
ldd 0,s get file desc
sys write,ulgtab,16 make entry
puls d get file desc
sys close close the file
nogud4 lbra login2
*
* 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
*
* fixcs
*
* Fix upper/lower case by name.
*
fixcs ldx #buffer point to name
lda 0,x get 1st character
cmpa #'a is it lower case?
bhs fixcs4 if so, ok
fixcs2 lda 0,x get char
beq fixcs3 is it null?
adda #$20 make lower case
sta 0,x+ save character
bra fixcs2
fixcs3 lda ttbuf get tty flags
ora #LCASE set lcase bit
sta ttbuf set back in buffer
ldd #0 set file desc
sys ttyset,ttbuf set new status
fixcs4 ldx #buffer
ldy #ulgtab+ul_nam copy name to table
pshs y save start
ldb #5 set count
pshs b save it
ldd #0 set null word
fixcs5 std 0,y++ zero out name
dec 0,s dec count
bne fixcs5
puls b,y reset pointer
ldb #9 set count
pshs b
fixcs6 dec 0,s dec the count
beq fixcs7
lda 0,x+ get name character
sta 0,y+ move to table
bne fixcs6
fixcs7 puls b,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
*
* gtinfo
*
* Get current time and tty info.
*
gtinfo ldd #0 set file desc 0
lbsr ttynam get tty name
bes gtinf2 error?
std ttnam2 save name
std ttchn2
std ulgtab+ul_tty save in table too
sys time,curtim get current time
rts return
gtinf2 ldd #1 set file desc
sys write,bdtr,BDSZ output error msg
sys term terminate login!
*
* idlin
*
* Output id line during login (tty name & time)
*
idlin sys time,ulgtab+ul_tim get system time
ldx #ulgtab+ul_tim point to time
lbsr tmloc convert to local time
ldx #second point to time vector
lbsr tasc convert to ascii
ldd #1 set file desc
sys write,tstr,24 print the date & time
ldd #1 set file desc
sys write,spcs,6 output 6 spaces
lda #$d set up cr
sta ttnam2+2
ldd #1 set file desc
sys write,ttnam,6 output ttyname
clr ttnam2+2
rts return
pag
*
* ttynam
*
* Get the name of the tty whose file desc is in D.
*
ttynam pshs d save file desc
sys ofstat,ttystb get status
bes ttyna5 error?
lda ttystb+4 get modes
bita #$04 is it character device?
beq ttyna5 if not, error
ldd ttystb+2 get fdn number
pshs d save it
sys open,ttydir,0 open device dir for read
bes ttyna4 error?
pshs d save file desc
ttyna2 ldd 0,s get file desc
sys read,ttybuf,16 read in dir entry
bes ttyna3 error?
ldd 2,s get fdn number
cmpd ttybuf same fdn?
bne ttyna2 if not, repeat
puls d get file desc
sys close close the file
leas 4,s clean up stack
ldd ttybuf+5 get name
clc set ok status
rts return
ttyna3 puls d get file desc
sys close close the file
ttyna4 puls d clean up stack
ttyna5 sec set error
puls d,pc return
pag
*
* upduf
*
* Update the act/utmp file with this user
*
upduf sys open,utfn,1 open the file
bes upduf6 if error, skip
pshs d save file desc
ldd ulgtab+ul_tty get tty name
anda #$f mask low 4 bits
andb #$f of each char
asla hi byte times 10
pshs a
asla
asla
adda 0,s result now x10
sta 0,s save result
addb 0,s+ add in low byte
clra clear hi byte
aslb now x16
rola
aslb
rola
aslb
rola
aslb
rola
std isk2 save in seek call
ldd 0,s get file desc
sys ind,isk seek in file
ldd 0,s get file desc
sys write,ulgtab,16 write out entry
puls d get file desc
sys close close the file
upduf6 sys open,hisf,1 open history file
bes upduf8 error?
pshs d save file desc
sys seek,0,0,2 seek to eof
ldd 0,s get file desc
sys write,ulgtab,16 output history data
puls d get file desc
sys close
upduf8 rts return
pag
*
* tmloc
*
* Convert time pointed at by x to vector time (local).
*
tmloc ldd 0,x get time
std ltime
ldd 2,x
std ltime+2
lda 7,x get day light savings flag
sta dlflg
clr eutc init flag
ldd 5,x get time zone
bpl tmloc2 west of GMT?
inc eutc if not - set flag
coma and make pos number
comb
addd #1
tmloc2 std r0+2 save time zone
ldd #60 calculate zone seconds
std r1+2
ldd #0 set hi bytes to 0
std r0
std r1
lbsr lmul calculate time zone seconds
ldd r0 get result
std tzn save it
ldd r0+2
std tzn+2
lbsr adjtim adjust time for zone
ldx #ltime point to time
lbsr tmutc convert to vector
tst dlflg do dlst?
beq tmloc6
lbsr chkdl in dlst?
bne tmloc6
tmloc5 ldd #3600 adjust for dlst
addd ltime+2
std ltime+2
ldd ltime
adcb #0
adca #0
std ltime
ldx #ltime point to time
lbsr tmutc convert to vector
inc daylit set daylit flag
tmloc6 ldx #second point to vector
rts return
pag
*
* tmutc
*
* Convert the internal system time (4 bytes
* pointed at by X on entry) to an 18 byte
* vector representing the broken down time.
* The time in this form is UTC (Universal
* Coordinated Time).
*
tmutc ldd #0 set daylight savings word
std daylit
ldd 0,x get hi word of time
std r0 save ir divide register
ldd 2,x get lo word of time
std r0+2
ldd #60*60 seconds*minutes constant
std r1 set up for divide
lbsr ldiv min*sec=time % 3600
ldd work hour*day=time / 3600
pshs d save min*sec
ldd #24 set up hours per day constant
std r1
lbsr ldiv hours= (hour*day) % 24
ldd work day= (hour*day) / 24
std hours set hours word
ldd r0+2 get day number
std day save the day
addd #2 add in day bias (Jan 1 80 => Tue)
std r0 set up for divide
ldb #7 days per week constant
stb r1
lbsr div wday=(day+2) % 7
ldb work get result
clra make into word
std wday set week day
puls d get min*sec
std r0 set up for divide
ldb #60 seconds per minute
stb r1
lbsr div seconds= (min*sec) % 60
ldb work minutes= (min*sec) / 60
clra
std second set seconds word
ldd r0 get minutes
std minute save it
pag
* continue tutc for year and month data
clr 0,-s clear year counter
tutc2 ldx #ylen point to year length table
lda 0,s get year number
bita #$3 is it leap year?
bne tutc3
leax 2,x if so, move to long year value
tutc3 ldd day get day number
cmpd 0,x day in current year?
blo tutc4 if 'lt' - we got the year!
subd 0,x subtract off years days
std day save new day count
inc 0,s bump the year count
bra tutc2 repeat
tutc4 std yday set day of year word
puls b get year count
addb #80 add to '1980'
clra make 16 bits long
std year save the year
bitb #$3 is it leap year?
bne tutc5
ldd #29 if so, set Feb day count to 29
std mdays+2
tutc5 ldx #mdays point to month-day table
clr 0,-s set month count to zero
ldd yday get day of the year
tutc6 cmpd 0,x in the month?
blo tutc7 if 'lt' - we got the month!
inc 0,s bump the month counter
subd 0,x++ subtract of this month's days
bra tutc6
tutc7 addd #1 add 1 to month day (day 1 is 1 - not 0!)
std mday save the month day
puls b get the month
std month save it
ldd #28 reset month - day table
std mdays+2
rts return
pag
*
* chkdl
*
* Check if in dlst - return 'eq' if so.
*
chkdl ldd #119 check for last Sun in Apr
bsr fixtim
std fstdl first day of dlst
ldd #303 last Sun in Oct
bsr fixtim
std lstdl last day of dlst
ldd yday get day of year
cmpd fstdl up to 1st day yet?
blo chkdl6
bhi chkdl4
ldd hours on the 1st day - so
cmpd #2 is it 2:00 AM yet?
blo chkdl6
bra chkdl5
chkdl4 ldd yday get day of year
cmpd lstdl past last day of dlst?
bhi chkdl6
blo chkdl5
ldd hours on the last day - so
cmpd #1 is it 1:00 AM yet?
bhs chkdl6
chkdl5 sez we are in dlst!
rts return
chkdl6 clz not in dlst
rts return
pag
*
* adjtim
*
* Adjust time for time zone.
*
adjtim ldd ltime+2 get time
tst eutc east of UTC?
bne adjti2
subd r0+2 subtract time zone minutes
std ltime+2
ldd ltime get hi part
sbcb r0+1
sbca r0
bra adjti4
adjti2 addd r0+2 add in minutes
std ltime+2
ldd ltime
adcb r0+1
adca r0
adjti4 std ltime save new time
adjti5 rts return
*
* fixtim
*
* Return the closest day to the date in D
* which is a Sunday.
*
fixtim pshs d save day number
ldd year get year
bitb #$3 is it leap year?
puls d
bne fixti2
addd #1 if so - bump day number
fixti2 pshs d save day number
addd #420 add in 420 so no negatives result
addd wday add in day of week
subd yday subtract day of year
std r0 save result
ldb #7
stb r1 set up for divide
lbsr div do: (day+420+wday-yday) % 7
puls d get day number
subb work
sbca #0
rts return day in d
pag
*
* Divide routines for time conversion use. 'Ldiv'
* divides a 32 bit number (r0 -> r0+3) by a 16 bit
* number (r1 -> r1+1) and produces a 32 bit result
* in r0 and a 16 bit remainder in 'work'. 'Div'
* divides a 16 bit number (r0 -> r0+1) by an 8 bit
* number (r1) and produces a 16 bit result (r0)
* and an 8 bit remainder (work).
*
div lda #17 set up loop counter
clrb do initialize
stb work
bra div2
div1 ldb work
subb r1 do subtraction
bcs div2 s3et new work?
stb work yes!
div2 rol r0+1 do shift left
rol r0
rol work
deca dec the loop count
bne div1 repeat?
com r0 fix up result
com r0+1
lsr work fix remainder
rts
pag
*
* Long divide
*
ldiv ldb #33 set loop counter
pshs b
ldd #0 do init
std work
bra ldiv2
ldiv1 ldd work do subtraction
subd r1
bcs ldiv2 work > r1 ?
std work set new work value
ldiv2 rol r0+3 do shifting
rol r0+2
rol r0+1
rol r0
rol work+1
rol work
dec 0,s dec the loop count
bne ldiv1
com r0 compliment the result
com r0+1
com r0+2
com r0+3
lsr work adjust the remainder
ror work+1
puls b,pc return
pag
*
* lmul
*
* Long multiply - 32 bits (r0) X 32 bits (r1).
* Result is in r0.
*
lmul ldb #32 set loop count
pshs b
ldd #0 init variables
std work
std work+2
lsr r0 do initial shift
ror r0+1
ror r0+2
ror r0+3
lmul1 bcc lmul2 need to add?
ldd work+2
addd r1+2
std work+2
ldd work
adcb r1+1
adca r1
std work save result
lmul2 ror work do shifting
ror work+1
ror work+2
ror work+3
ror r0
ror r0+1
ror r0+2
ror r0+3
dec 0,s dec the loop count
bne lmul1 repeat?
puls b,pc return
pag
*
* tasc
*
* Convert the time vector data (18 bytes) pointed
* at by x into an ascii string. Return x pointing
* to the string.
*
tasc tfr x,u save vector pointer
ldx #tstr point to string
ldd 4,u get hours
lbsr cvt convert to ascii
leax 1,x skip the ':'
ldd 2,u get minutes
lbsr cvt convert to ascii
leax 1,x skip the ':'
ldd 0,u get seconds
lbsr cvt convert to ascii
leax 1,x skip space
ldd 6,u get day of week
ldy #dtab point to day table
bsr tasxfr xfr to string
ldd 10,u get month
ldy #mtab point to month table
bsr tasxfr xfr to string
ldd 8,u get month day
bsr cvt convert to ascii
leax 1,x
ldd #('1<<8)|'9 set up '19'
std 0,x save in string
ldd 12,u get year
cmpd #100 >100 (year 2000 yet?)
blo tasc4
subd #100 remove bias
pshs d save year
ldd #('2<<8)|'0 set up '20'
std 0,x set in string
puls d reset year
tasc4 leax 2,x
bsr cvt convert year to ascii
ldx #tstr point to string
rts return
pag
*
* tasxfr
*
* Transfer the 3 bytes of ascii indexed by b
* at y to location pointed at by x.
*
tasxfr pshs b index * 3
aslb
addb 0,s+
leay b,y point to indexed data
ldd 0,y xfr the data to x
std 0,x++
lda 2,y
sta 0,x
leax 2,x bump string pointer
rts return
*
* cvt
*
* Convert number in b to ascii at x.
*
cvt lda #'0 set ascii 0
cvt2 cmpb #10 >10?
blo cvt4
subb #10 subtract off 10
inca bump ascii
bra cvt2 repeat
cvt4 addb #'0 make 1's ascii
std 0,x++ save ascii at x
rts 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
utfn fcc '/act/utmp',0
homnm fcc '.home?',0
bdlgfl fcc '/act/attempts',0
hisf fcc '/act/history',0 history file
lgmsg fcc '/etc/log/message',0
motd fcc '/etc/log/motd',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
logst fcc $d,$d,'Login: '
LSZ equ *-logst
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
ylen fdb 365 year length
fdb 366 leap year
mdays fdb 31,28,31,30,31,30,31,31,30,31,30,31
tstr fcc 'xx:xx:xx xxx xxx xx xxxx',$d,0
dtab fcc 'SunMonTueWedThuFriSat'
mtab fcc 'JanFebMarAprMayJunJulAugSepOctNovDec'
* buffers
second fdb 0 seconds (0-59)
minute fdb 0 minutes (0-59)
hours fdb 0 hours (0-23)
wday fdb 0 week day (0-6) 0=Sunday
mday fdb 0 month day (1-31)
month fdb 0 month (0-11)
year fdb 0 year (80+)
yday fdb 0 day of year (0-355)
daylit fdb 0 daylight savings flag
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
ulgtab rmb USIZ login table
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