Reputation: 1713
I want to execute Ant with the verbose option but I don't want the arguments passed into the Exec task to be displayed in situations where they are sensitive (i.e. user/password).
An example is where there's a connection to a database:
<exec executable="/bin/sh" failonerror="true">
<arg line="/opt/blah/blah/bin/frmcmp_batch.sh Module=blah Userid=username/mypassword@blah Module_Type=blah"/>
</exec>
I don't want the arguments (specifically "Userid=username/mypassword@blah" showing up in the log).
What is the best way to hide/secure the arguments?
Upvotes: 0
Views: 1946
Reputation: 77981
Best way to secure the password is not to use one :-) The following answer describes how to setup an SSH key:
The ANT sshexec command supports a "keyfile" attribute.
Ahhh, scripting sudo can be a royal pain.
Here are solutions which have worked for me in the past.
It seems you're concerned about the password appearing in a log file? My fixation is to never write my password down or hard-code it within a script....
Upvotes: 1
Reputation: 1713
Currently I'm using the following workaround (described here) to hide "mypassword" but I was wondering if there's a more elegant solution?
build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project default="test">
<target name="test" depends="">
<echo message="Testing..."/>
<echo message="Turning verbose off... you should NOT see the arguments..."/>
<script language="javascript">
var logger = project.getBuildListeners().firstElement();
// 2 works to turn off verbose
logger.setMessageOutputLevel(2);
</script>
<exec dir="." executable="cmd">
<arg line="/c dummy.bat mypassword"/>
</exec>
<echo message="Turning verbose on... you should see the arguments..."/>
<script language="javascript">
var logger = project.getBuildListeners().firstElement();
// 3 works to turn verbose back on
logger.setMessageOutputLevel(3);
</script>
<exec dir="." executable="cmd">
<arg line="/c dummy.bat mypassword"/>
</exec>
</target>
</project>
dummy.bat
@echo off
echo dummy
Output
test:
[echo] Testing...
[echo] Turning verbose off... you should NOT see the arguments...
[exec] dummy
[echo] Turning verbose on... you should see the arguments...
[exec] Current OS is Windows XP
[exec] Executing 'cmd' with arguments:
[exec] '/c'
[exec] 'dummy.bat'
[exec] 'mypassword'
[exec]
[exec] The ' characters around the executable and arguments are
[exec] not part of the command.
[exec] dummy
Upvotes: 0