Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Subroutine CS_SETSTATION_HOOK(flag,station)
- Declare Function GetCommandLine, InList
- CommandLine = GetCommandLine()
- TrustedStations = "SERVER1,SERVER2,ADMINSTATION"
- TrustedAccounts = "ADMIN1,ADMIN2,DEV3"
- *Get the command line arguments used to launch oinsight.exe
- CmdArgs = GetCommandLine()
- Token = '/DV=' ;*Look for this command like argument
- TokenLen = Len(Token)
- CommandLineDVValue = '' ;* If found, store cmd arg value here
- *Index and IndexC are not available at this point in launch.
- *Loop through all characters in the command line arguments
- CharCount = Len(CmdArgs)
- For i = 1 To CharCount
- *Does this section match the argument we are searching for?
- If CmdArgs[i,TokenLen] EQ Token Then
- *Found the parameter
- *Parameter value starts here:
- TokenValuePos = i + TokenLen
- *Find the value and length of parameter
- TokenValue = ''
- TokenValueLen = ''
- For j = TokenValuePos To CharCount
- *Now find the end of the value
- If CmdArgs[j,1] EQ ' ' Then
- *This is the first space after the beginning of the parm value
- *so it must be the end of the value
- TokenValueLen = j - TokenValuePos
- j = CharCount ;* Break the loop
- End
- Next j
- If TokenValue EQ '' And TokenValueLen EQ '' Then
- *Didn't find an end value to the token so maybe it was the last position
- *in the command line arguments and has no ending space character
- TokenValueLen = (CharCount - TokenValuePos) + 1
- End
- TokenValue = CmdArgs[TokenValuePos, TokenValueLen]
- *Drop any quotes protecting the UN value
- Swap "'" With '' In TokenValue
- Swap '"' With '' In TokenValue
- CommandLineDVValue = TokenValue
- i = CharCount ;* Break out of parent loop
- End
- Next i
- Token = '/UN=' ;*Look for this command like argument
- TokenLen = Len(Token)
- CommandLineUNValue = '' ;* If found, store cmd arg value here
- *Index and IndexC are not available at this point in launch.
- *Loop through all characters in the command line arguments
- CharCount = Len(CmdArgs)
- For i = 1 To CharCount
- *Does this section match the argument we are searching for?
- If CmdArgs[i,TokenLen] EQ Token Then
- *Found the parameter
- *Parameter value starts here:
- TokenValuePos = i + TokenLen
- *Find the value and length of parameter
- TokenValue = ''
- TokenValueLen = ''
- For j = TokenValuePos To CharCount
- *Now find the end of the value
- SingleChar = CmdArgs[j,1]
- If SingleChar EQ ' ' Then
- *This is the first space after the beginning of the parm value
- *so it must be the end of the value
- TokenValueLen = j - TokenValuePos
- j = CharCount ;* Break the loop
- End
- Next j
- If TokenValue EQ '' And TokenValueLen EQ '' Then
- *Didn't find an end value to the token so maybe it was the last position
- *in the command line arguments and has no ending space character
- TokenValueLen = (CharCount - TokenValuePos) + 1
- End
- TokenValue = CmdArgs[TokenValuePos, TokenValueLen]
- *Drop any quotes protecting the UN value
- Swap "'" With '' In TokenValue
- Swap '"' With '' In TokenValue
- CommandLineUNValue = TokenValue
- i = CharCount ;* Break out of parent loop
- End
- Next i
- CommandLineUNValue = Trim(CommandLineUNValue)
- *
- * At this point the program didn't terminate so we aren't on a trusted station
- *
- If InList(TrustedAccounts,CommandLineUNValue,',') Then
- *The account is trusted even if we aren't on a trusted station
- Return
- End
- *
- * Account is not trusted nor is the staion.
- * Must use the correct command line arguments
- *
- If CommandLineUNValue EQ '' Or CommandLineDVValue NE '0' Then
- *No user specified on command line so don't allow run or
- *Run mode was not specified.
- *In other words, only allow user to run OI with command line arguments and DV=0
- isRestricted = 1
- End Else
- isRestricted = 0
- End
- If isRestricted Then
- Call Msg(@Window, 'Command line not correct for account')
- Call Utility("DESTROY", "SYSTEM")
- End
- Return
Add Comment
Please, Sign In to add comment