/**/
trace o
'@ECHO OFF'
arg input
call a_initial
if result = 0 then do
do usercnt = 1 to words(input)
userid = word(input,usercnt)
call x_msg '20' , userid
call b_gethomedir
if result = 0 then do
revpos = wordpos(userid,revoke_user)
if revpos <> 0 then do
savedaccess = substr(revoke_user.revpos,26,length(revoke_user.revpos)-25)
used = substr(revoke_user.revpos,9,8)
if terminate = 1 then leave
call c_chgaccess
if result = 0 then do
swoprequired = 1
if inform = 'Y' then ,
rc = ChkStNetSend(userid,sendunrevokemsg)
if informexit = 'Y' then do
if stream(UserNotifyEXE,'c','query exists') <> '' then UserNotifyEXE 'CHKREST' userid used allowed
else if stream(UserNotifyCMD,'c','query exists') <> '' then 'call' UserNotifyCMD 'CHKREST' userid used allowed
end
call x_msg '1' , userid
okuser = okuser userid
end
end
else do
if terminate = 1 then leave
call x_msg '21' , userid
end
end
end
call d_updatedb
end
finalrc = result
call z_terminate
exit result
a_initial:
terminate    = 0
OutputOpen   = 0
swopok       = 0
swoprequired = 0
signal on syntax
call on halt
'@ECHO OFF'
call aa_nlssetup
call ab_otherinit
call ac_parameters
if result <> 0 then return result
call ad_check
if result <> 0 then return result
return 0
aa_nlssetup:
esc = '1b'x'['
normal = esc'0;37;40m'
crlf = '0d'x||'0a'x
msg.1 = "URV0001I: homedirectory owned by %1, now restored"
msg.2 = "URV0002E: No userid given to unrevoke. Enter %1 ? for help"
msg.3 = "URV0003E: You are currently not logged on to any domain. command cannot be issued"
msg.4 = "URV0004I: unrevoking %1 on domain %2"
msg.5 = "URV0005E: The domain %1 is not valid or is unavailable. Command cannot continue"
msg.6 = "URV0006E: The alias %1 is not a valid alias, database cannot be located"
msg.7 = "URV0007W: A new database is being created probably by another CHKSTORE"||crlf
msg.7 = msg.7||"          or CHKUNREV action. Please try again later"
msg.8 = "URV0008E: Unable to Open Database file, program terminating"||crlf
msg.8 = msg.8||"          possible causes are :-"||crlf
msg.8 = msg.8||"          1. Administrator id not logged on"
msg.9 = "URV0009E: Unable to Open New Database file, program terminating"||crlf
msg.9 = msg.9||"          possible causes are :-"||crlf
msg.9 = msg.9||"          1. Administrator id not logged on"
msg.10 = "URV0010E: Unable to determine home directory for user %1"||crlf
msg.10 = msg.10||"          user will not be processed"
msg.11 = "URV0011I: restoring saved acl access for %1"||crlf
msg.11 = msg.11||"          on %2 owned by user %3"
msg.12 = "URV0012E: Unable to change access permissions for %1 on server %2"
msg.12 = msg.12||"          return code was %3, userid will be skipped"
msg.13 = "URV0013I: Updating the database"
msg.14 = "URV0014W: Attempt %1 to swop database files failed. %2 attempts remaining"
msg.15 = "URV0015E: an unknown error %1 occurred trying to access"||crlf
msg.15 = msg.15||"          an existing new database file. Program Terminating"
msg.16 = "URV0016E: REXXUTIL.DLL or CHKSTDLL.DLL could not be accessed. Please ensure"||crlf
msg.16 = msg.16||"that these DLLs are in a directory specified in the LIBPATH"
msg.17 = "URV0017I: An external interrupt was received (CTRL-C most likely)."||crlf
msg.17 = msg.17||"The program will terminate as requested at the first oppurtunity"
msg.18 = "URV0018E: SERIOUS ERROR ****** Database file could not be updated ******, CHKSTORE"||crlf
msg.18 = msg.18||"should not be allowed to run again until a manual swop has been done"||crlf
msg.18 = msg.18||"The database has remained locked."
msg.19 = "URV0019W: Unable to change access permissions for %1"||crlf
msg.19 = msg.19||"          on server %2 return code was %3, will try to continue...."
msg.20 = "URV0020I: Processing home directory owned by %1"
msg.21 = "URV0021W: home directory owned by %1 is not listed as being revoked"||crlf
msg.21 = msg.21||"          unable to unrevoke. Use Standard Lan Server interface"||crlf
msg.21 = msg.21||"          to alter the Access Control Profiles."
msg.22 = "URV0022I: The Program has been flagged for termination already."||crlf
msg.22 = msg.22||"Please be patient"
msg.23 = "URV0023E: Users have been modified, but a system error occured and the new "||crlf
msg.23 = msg.23||"          database cannot be used. Database recovery"||crlf
msg.23 = msg.23||"          will be required."
msg.24 = "URV0024E: Unable to update the new database. Return code was %1"||crlf
msg.24 = msg.24||"          database cannot be used. Database recovery is required"
msg.25 = "URV0025E: A new database file exists, but no CHKSTORE, CHKUNREV or"||crlf
msg.25 = msg.25||"          CHKRECVR running. Database recovery is -->REQUIRED<--"
bm = center("****** U N R E V O K E D ******",66)||crlf
bm = bm||center("You now have full privileges for your home directory",60)
sendunrevokemsg = bm
drop bm crlf
return 0
ab_otherinit:
version = '2.12'
ChkstorFile = 'CHKSTORE.DBF'
OutputFile = 'CHKSTORE.DBN'
UserNotifyEXE = 'CHKINFRM.EXE'
UserNotifyCMD = 'CHKINFRM.CMD'
retry_delay = 10
retry_limit = 10
okuser = ''
call RxFuncAdd "SysLoadFuncs" , "REXXUTIL" , "SysLoadFuncs"
call SysLoadFuncs
call RxFuncAdd "ChkStLoadFuncs" , "CHKSTDLL" , "ChkStLoadFuncs"
call ChkStLoadFuncs
do i = 1 to queued() ; pull . ; end
parse source . . thisprg .
thisprg_drive = filespec('drive',thisprg)
thisprg_path = filespec('path',thisprg)
prgpath = thisprg_drive||thisprg_path
return 0
ac_parameters:
if left(input,1) = '?' then do
call aca_help
exit 0
end
inputlen = length(input)
if inputlen = 0 then do
call x_msg '2' , 'CHKUNREV'
exit 0
end
inform = 'N'
informexit = 'N'
db_location = 'LOGON'
domain = ''
if pos('/I',input) <> 0 then do
inform = 'Y'
parse var input beg '/I' end
input = beg||end
end
if pos('/U',input) <> 0 then do
informexit = 'Y'
parse var input beg '/U' end
input = beg||end
end
if pos('/DB:',input) <> 0 then do
parse var input beg '/DB:'db_location end
input = beg||end
end
if pos('/D:',input) <> 0 then do
parse var input beg '/D:'domain end
input = beg||end
end
parse value ChkStNetUser() with myuserid mycomputername mydomain
if mydomain = '' then do
call x_msg '3'
return 3
end
if domain = '' then domain = mydomain
domain_server = ChkStDCName(domain)
if pos('ERROR',domain_server) <> 0 then do
call x_msg '5' , domain
return 5
end
if left(db_location,1) <> '\' & substr(db_location,2,1) <> ':' & ,
left(db_location,1) <> '.' then do
parse value ChkStNetAlias(domain_server,db_location) with alias_server alias_path
if pos('ERROR',alias_server) <> 0 then do
call x_msg '6' , db_location
return 6
end
if strip(alias_server,'L','\') <> computername then ,
alias_drive  = alias_server'\'translate(alias_path,'$',':')
else
alias_drive = alias_path
end
else ,
alias_drive = strip(db_location,'t','\')
OutputFile = alias_drive||'\'||OutputFile
ChkstorFile = alias_drive||'\'||ChkstorFile
return 0
aca_help:
say 'CHKUNREV - version' version
say '(c) Copyright International Business Machines Corporation 1994.'
say 'All rights Reserved'
say
say 'CHKUNREV: This application will give full access back to a users home'
say "          directory and all it's subdirectories. It also updates the"
say '          information files maintained by CHKSTORE to reflect this.'
say '          You must be logged on as an administrator to do this.'
say
say 'Calling Convention'
say '------------------'
say 'CHKUNREV userid1 userid2 ...  (/i | /u) /D:domain /DB:database_location'
say
say 'where:-'
say '   userid1, userid2  = userid to unrevoke'
say '   domain            = domain users are in. in not supplied, the current'
say '                       logged on domain is used'
say '   database_location = alternative location of the chkstore database'
say '                       This is optional, the default being locate the'
say '                       database on the LOGON alias.'
say '   /I                = Inform users using a NET SEND'
say '   /U                = Inform users by calling the CHKSTORE notify exit'
return 0
ad_check:
if stream(OutputFile,'c','query exists') <> '' then do
rc = stream(OutputFile,'c','open')
if rc = 'READY:' then do
call x_msg '25'
return 25
end
else do
if rc = 'NOTREADY:32' then do
call x_msg '7'
return 7
end
else do
call x_msg '15' , rc
return 15
end
end
end
rc = stream(OutputFile,'c','open')
if rc <> 'READY:' then do
call x_msg '9'
return 9
end
OutputOpen = 1
revcnt = 0
revoke_user = ''
if stream(ChkstorFile,'c','query exists') <> '' then do
filedataentries = ChkStReadFile(ChkstorFile)
if pos('ERROR:',entries) <> 0 then do
call x_msg '8'
return 8
end
do i = 1 to filedataentries
if SubStr(filedata.i,25,1) = 'R' then do
revoke_user = revoke_user strip(left(filedata.i,8))
revcnt = revcnt + 1
revoke_user.revcnt  = filedata.i
end
end
revoke_user.0 = revcnt
end
return 0
b_gethomedir:
parse value ChkStHomeDir(domain_server,userid) with allowed homedir
if pos('ERROR',out) <> 0 then do
call x_msg '10'
return 10
end
return 0
c_chgaccess:
path = strip(homedir)
if left(path,1) = '\' then ,
parse var path '\\'server'\'drive'$'pathname
else ,
parse var path homedrv'\'server'\'drive'$'pathname
if mycomputername <> server then ,
call SysFileTree '\\'server'\'drive'$'||pathname'\*.*' , 'subdir' , 'SD'
else ,
call SysFileTree drive':'||pathname'\*.*' , 'subdir' , 'SD'
call x_msg '11' , drive':'||pathname , server , userid
if left(savedaccess,1) <> ' ' then do
accuser.1 = userid
accacl.1 = left(savedaccess,7)
count = 1
end
else count = 0
start = 8
do while length(savedaccess) > start
count = count + 1
accuser.count = strip(substr(savedaccess,start,9))
accacl.count = strip(substr(savedaccess,start+9,7))
start = start + 16
end
accuser.0 = count
accacl.0 = count
if server <> mycomputername then ,
rc = ChkStSetAcc('\\'server,drive':'||pathname)
else ,
rc = ChkStSetAcc('',drive':'||pathname)
if rc <> 0 then do
call x_msg '12' , drive':'pathname , server , rc
return 12
end
do subloop = 1 to subdir.0
parse var subdir.subloop . . . . directory
directory = strip(directory)
if left(directory,1) = '\' then ,
parse var directory '\\'.'\'.'$'accpath
else ,
parse var directory ':'accpath
call x_msg '11' , drive':'||accpath , server , userid
if server <> mycomputername then ,
rc = ChkStSetAcc('\\'server,drive':'||accpath)
else ,
rc = ChkStSetAcc('',drive':'||accpath)
if rc <> 0 then do
call x_msg '19' , drive':'||accpath , server , rc
return 19
end
end
return 0
d_updatedb:
if swoprequired = 1 then do
call x_msg '13'
do i = 1 to filedataentries
if wordpos(strip(left(filedata.i,8)),okuser) <> 0 then ,
output = left(filedata.i,24)
else ,
output = filedata.i
rc = lineout(OutputFile,output)
if rc <> 0 then do
call x_msg '24' , rc
return 24
end
end
swopok = 1
end
return 0
x_msg:
msgno = arg(1)
do argloop = 2 to arg()
mypos = argloop - 1
field.mypos = arg(argloop)
end
msgcol = normal
msgout = msg.msgno
msgtype = substr(msgout,8,1)
startpos = 1
endflag = 0
do until endflag = 1
replacepoint = pos(' %',msgout,startpos)
if replacepoint <> 0 then do
if replacepoint+1 = length(msgout) then endflag = 1
else startpos = replacepoint + 3
fieldno = substr(msgout,replacepoint+2,1)
if datatype(fieldno,'num') = 1 then do
msgout = left(msgout,replacepoint)||field.fieldno||right(msgout,length(msgout)-replacepoint-2)
end
end
else endflag = 1
end
if msgtype = 'E' then do
call lineout "STDERR:",esc'1;31;40m'||msgout||normal
call beep 200,300
end
else do
if msgtype = 'W' then ,
msgcol = esc'1;32;40m'
else ,
msgcol = normal
say msgcol||msgout||normal
end
return 0
z_terminate:
termrc = 0
if OutputOpen = 1 then ,
rc = stream(OutputFile,'c','close')
if swoprequired = 1 then do
if swopok = 1 then do
i = 0
do while i < retry_limit
rc = 0
if stream(ChkstorFile,'c','query exists') <> '' then ,
rc = SysFileDelete(ChkstorFile)
if rc = 0 then do
RenameFile = filespec("name",ChkstorFile)
'RENAME' OutputFile RenameFile '1>NUL 2>NUL'
i = retry_limit
end
else do
i=i+1
call x_msg '14' , i , retry_limit-i
if i < retry_limit then ,
call SysSleep retry_delay
else do
call x_msg '18'
end
end
end
end
else do
call x_msg '23'
termrc = 23
end
end
else call SysFileDelete OutputFile
swopok = 0
do queued(); pull .; end
return termrc
syntax:
signal off syntax
where = SigL
say 'Syntax Error in line' where 'occured'
call z_terminate
call x_msg '16'
exit 0
halt:
if terminate = 0 then ,
call x_msg '17'
else do
terminate = 1
call x_msg '22'
end
return
