Question

I'm trying to better integrate Eclipse with my build.xml. My build file calls GNU Make for the native portion of the program, and the Makefile uses sudo to movethe compiled libs into system path. Unfortunately that requires entering a password, and Eclipse's terminal doesn't accept user input. So the result from running the build in eclipse is:

 [exec] sudo: no tty present and no askpass program specified
 [exec] make: *** [install] Error 1

Any way around this problem? Can the ant build be elevated to root some other way?

Was it helpful?

Solution

Set up a separate account, e.g. deployer. Modify /etc/sudoers to include aliases that allow deployer to execute a single command, e.g. deploy, as root. Make deployer NOEXEC:. Store the deployer password in an invisible file, e.g. .deployconf having user-only access: e.g. 400 or 600. Load the password in ant, and use as required:

<loadfile srcfile="${user.home}/.deployconf" property="deployconf"/>

This works well with <signjar/>, but I've not tried it with <exec/>. Some effort may be required to keep linefeeds out of .deployconf.

OTHER TIPS

You could set up your /etc/sudoers file so that it specifies NOPASSWD: for the user under which Eclipse is running, and for the command you're using to move the libs. Using the visudo command, you could add this to the end of /etc/sudoers:

eclipseuser ALL = NOPASSWD: /bin/cp

Be aware that this does present a security risk as the eclipseuser would then have the power to overwrite any file on the system.

Perhaps a stupid 'solution', but why not make the deploy a separate step? Have the build make an packaging artifact: DEP, RPM or something.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top