Password info encrypted/clear from Log

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I don't have a Windows server so don't have ExecDOS. Post the routine code, wrapped in

Code: Select all

 tags and we'll see what we can do.
-craig

"You can never have too many knives" -- Logan Nine Fingers
nivas
Participant
Posts: 117
Joined: Sun Mar 21, 2004 4:40 pm

Post by nivas »

chulett wrote:I don't have a Windows server so don't have ExecDOS. Post the routine code, wrapped in

Code: Select all

 tags and we'll see what we can do. ...[/quote]


jobName="runSSISPackageBOALoad"

*Run SSIS Package  
DosCommand="C:\psexec\psexec -U hcf":UserID:" -p ":Password:" \\HCF15 -i dtexec /SQL \ZeroCouponLoad\BOALoad /SERVER HCF15 /CHECKPOINTING OFF  /REPORTING EW"
call DSU.ExecDOS(DosCommand,ErrCode);    
if ErrCode <> 0 
Then Call DSLogFatal("DOS script failed.", jobName)
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Sorry, I meant the source code for the ExecDOS routine, not your wrapper code. Odd that it has a DSU prefix, that means it is a User written routine so someone told it to log the command line. :?

You could also switch to using DSExecute() directly, that doesn't log anything like the ExecXX wrapper does. The only difference between ExecXX and ExecXXSilent (UNIX or DOS) is what each chooses to log after calling DSExecute.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Use an after job subroutine to replace the password in the log. Most error handling has been omitted from the example below for clarity.

Code: Select all

SUBROUTINE HideLogPassword(InputArg,ErrorCode)
$IFNDEF JOBCONTROL.H
$INCLUDE DSINCLUDE JOBCONTROL.H
$ENDIF

* Get job information
JobName = Field(DSGetJobInfo(DSJ.ME, DSJ.JOBNAME), ".", 1,1)
JobNumber = Trans("DS_JOBS", JobName, 5, "X")
JobStart = DSGetJobInfo(DSJ.ME, DSJ.JOBSTARTTIMESTAMP)

* Open the job log
LogFileName = "RT_LOG" : JobNumber
Open LogFileName To hLogFile
Then

   * Generate Select List of log entries for current run
   Perform "SELECT " : LogFileName : " WITH TIMESTAMP > " : SQuote(JobStart) : " TO 9"

   Loop
   While ReadNext EventNo From 9

      * Read the logfile entry text, locking for update.
      ReadVU LogEntry From hLogFile, EventNo, 10
      Then

         * Determine whether "psexec" occurs in entry.
         If Index(LogEntry, "psexec", 1)
         Then

            * Extract the password from that entry.
            Password = Field(LogEntry, "-p", 2 1)
            Password = Left(Password, Index(Password, "\\", 1) - 1)
            Password = Trim(Password)

            * Replace the found password with asterisks.
            LogEntry = Ereplace(LogEntry, Password, "********", 1, 1)

            * Replace that line into the log.
            WriteV LogEntry To hLogFile, EventNo, 10)
            Else
               Release hLogFile, EventNo
            End

         End

      End
      Else
         Release hLogFile, EventNo
      End

   Repeat

Close hLogFile

End

RETURN
Last edited by ray.wurlod on Thu Sep 04, 2008 5:01 pm, edited 1 time in total.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Yikes. Interesting idea, but why not just not write it there in the first place?
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Because DataStage writes it there if it's an ExecXXX subroutine.

Of couse, if writing from job control, one can determine exactly what to include in your DSLogInfo() and DSLogWarn() calls.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
umamahes
Premium Member
Premium Member
Posts: 110
Joined: Tue Jul 04, 2006 9:08 pm

Post by umamahes »

I am deleting my post from here
Last edited by umamahes on Thu Sep 04, 2008 4:50 pm, edited 2 times in total.
HI
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

:!: Now, hold on a darn minute. This isn't your thread so let's not steer the boat off course quite yet. You need to start a new thread if you want to talk about your problems.
-craig

"You can never have too many knives" -- Logan Nine Fingers
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

ray.wurlod wrote:Because DataStage writes it there if it's an ExecXXX subroutine.
Which is exactly why I suggested creating a 'Silent' version of the routine that doesn't log that stuffs or since it's all custom code, switch to using DSExecute directly.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply