On 11/04/2011 04:58 AM, Jongki Suwandi wrote:
I wonder if that "Failed to add" failure was because ssh now checks for the existence of the file. IIRC it used to work.

I suppose you can try using the tempfile module (e.g. tempfile.mkstemp()) to create a temporary file and pass the path (instead of the fd) to UserKnownHostsFile. You just have to make sure it gets deleted when autoserv quits. The advantage of the os.tmpfile() approach is the temporary file has no directory entry so it will get deleted automatically at the end and it's secure; but it no longer works for ssh apparently.

-Jongki

On Thu, Nov 3, 2011 at 5:40 AM, Wenyi Gao <[email protected] <mailto:[email protected]>> wrote:

    On 11/02/2011 06:38 PM, Jongki Suwandi wrote:
    Are you sure this is not going to print lots of messages like
    this in the log file?

    [stderr] Warning: Permanently added '192.168.122.99' (RSA) to the
    list
    of known hosts.

    A long time ago I suggested the /dev/fd solution to replace
    /dev/null to cut down the number of those messages which gets
    printed *everytime* ssh is run.  Those messages could number in
    the hundreds for long running tests.

    -Jongki

    On Wed, Nov 2, 2011 at 2:12 AM, Wenyi Gao <[email protected]
    <mailto:[email protected]>> wrote:

        The host_file got by os.tmpfile() is not available for "ssh
        -o UserKnownHostsFile " on ubuntu 11.10 and will have the
        error "Failed to add the host to the list of known hosts
        (/dev/fd/11)", so the patch just replace it with '/dev/null'.

        Signed-off-by: Wenyi Gao <[email protected]>
        <mailto:[email protected]>
        ---
         server/hosts/abstract_ssh.py |    5 +----
         1 files changed, 1 insertions(+), 4 deletions(-)

        diff --git a/server/hosts/abstract_ssh.py
        b/server/hosts/abstract_ssh.py
        index 582fa40..1a0b3e9 100644
        --- a/server/hosts/abstract_ssh.py
        +++ b/server/hosts/abstract_ssh.py
        @@ -50,9 +50,7 @@ class AbstractSSHHost(SiteHost):
                 self.port = port
                 self.password = password
                 self._use_rsync = None
        -        self.known_hosts_file = os.tmpfile()
        -        known_hosts_fd = self.known_hosts_file.fileno()
        -        self.known_hosts_fd = '//dev/fd//%s' % known_hosts_fd
        +        self.known_hosts_fd = '/dev/null'

                 """
                 Master SSH connection background job, socket temp
        directory and socket
        @@ -567,7 +565,6 @@ class AbstractSSHHost(SiteHost):
             def close(self):
                 super(AbstractSSHHost, self).close()
                 self._cleanup_master_ssh()
        -        self.known_hosts_file.close()


             def _cleanup_master_ssh(self):
-- 1.7.5.4

        _______________________________________________
        Autotest mailing list
        [email protected] <mailto:[email protected]>
        http://test.kernel.org/cgi-bin/mailman/listinfo/autotest


    Yes, this will print the message mentioned by you. I understand
    your solution now, but is there other solutions to avoid the error
    message  "Failed to add the host to the list of known hosts
    (/dev/fd/11)" ?




Ok, thanks all of you, I will try the solutions you suggested.

_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to