Bug 52554 - sshexec task: Add support for pseudo tty connections
Summary: sshexec task: Add support for pseudo tty connections
Status: RESOLVED FIXED
Alias: None
Product: Ant
Classification: Unclassified
Component: Optional Tasks (show other bugs)
Version: unspecified
Hardware: PC All
: P2 enhancement (vote)
Target Milestone: 1.8.3
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-30 03:47 UTC by Richard Allwood
Modified: 2012-02-01 13:21 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Allwood 2012-01-30 03:47:21 UTC
When using ssh to execute remote scripts containing "sudo" you get the following error if /etc/sudoers contains "Defaults requiretty".

sudo: sorry, you must have a tty to run sudo

The solution is to edit your sudoers file or add support for pseudo tty allocation (this is the same as the ssh -t option in unix).

Adding support for pseudo tty connections is a minor change:

In SSHExec.java
    private boolean tty = false;
    public void setTty(boolean tty) {
        this.tty = tty;
    }


    private void executeCommand(Session session, String cmd, StringBuffer sb)
...
            final ChannelExec channel;
            session.setTimeout((int) maxwait);
            /* execute the command */
            channel = (ChannelExec) session.openChannel("exec");
            channel.setCommand(cmd);
            channel.setOutputStream(tee);
            channel.setExtOutputStream(tee);
            if (istream != null) {
                channel.setInputStream(istream);
            }
+           channel.setPty(tty);
            channel.connect();
Comment 1 Stefan Bodewig 2012-02-01 13:21:34 UTC
added with svn revision 1239121