From: Eric S. Raymond Date: Thu, 4 Dec 2003 01:26:59 +0000 (+0000) Subject: Got rid of -l. X-Git-Tag: 1-1~3 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=873614e70a90ecc0a5e4bcaca811e5ac3df81e73;p=ssh-installkeys.git Got rid of -l. --- diff --git a/ssh-installkeys b/ssh-installkeys index ba82a22..92a16e4 100755 --- a/ssh-installkeys +++ b/ssh-installkeys @@ -1,7 +1,7 @@ #!/usr/bin/env python """ssh-installkeys -- prepare a remote account for ssh access -This script tries to export ssh public keys to a specified site. it will +This script tries to export ssh public keys to a specified site. It will walk you through generating key pairs if it doesn't find any to export. It handles all the fiddly details like making sure local and remote permissions are correct, and tells you what it's doing if it has to change @@ -10,14 +10,13 @@ anything. Options: -h Print usage summary and exit --l login Specify login name to be used at the remote site (default '%s') -c Check local and remote configuration only, don't try to fix problems. -d Delete remote .ssh configuration. -v Report all commands sent to host and output received. Author: Eric S. Raymond -$Id: ssh-installkeys,v 1.12 2003/12/03 22:58:22 esr Exp esr $ +$Id: ssh-installkeys,v 1.13 2003/12/04 00:44:45 esr Exp esr $ """ import os, sys, getopt, string, getpass, tempfile @@ -25,7 +24,7 @@ import os, sys, getopt, string, getpass, tempfile ############################################################################### # # pexpect 0.94 is inlined here because it's not in the Python library yet. -# Some comments have been removed, and the interact() method. +# Some comments and trivial unused methods have been removed. # """ @@ -47,9 +46,6 @@ License: Python Software Foundation License http://www.opensource.org/licenses/PythonSoftFoundation.html Noah Spurrier - -$Revision: 1.12 $ -$Date: 2003/12/03 22:58:22 $ """ import os, sys import select @@ -70,7 +66,7 @@ A critical module was not found. Probably this OS does not support it. Currently pexpect is intended for UNIX operating systems (including OS-X).""" __version__ = '0.94' -__revision__ = '$Revision: 1.12 $' +__revision__ = '$Revision: 1.13 $' __all__ = ['ExceptionPexpect', 'EOF', 'TIMEOUT', 'spawn', '__version__', '__revision__'] @@ -119,7 +115,6 @@ class spawn: self.timeout = timeout self.child_fd = -1 self.pid = None - self.log_file = None self.before = None self.after = None self.match = None @@ -206,12 +201,6 @@ class spawn: new[3] = new[3] & ~termios.ECHO # lflags termios.tcsetattr(self.child_fd, termios.TCSADRAIN, new) - def setlog (self, fileobject): - """This sets logging output to go to the given fileobject. - Set fileobject to None to stop logging. - """ - self.log_file = fileobject - def compile_pattern_list(self, pattern): """This compiles a pattern-string or a list of pattern-strings. This is used by expect() when calling expect_list(). @@ -380,8 +369,6 @@ class spawn: It includes a timeout. If the read does not complete within the timeout period then a TIMEOUT exception is raised. If the end of file is read then an EOF exception will be raised. - If a log file was set using setlog() then all data will - also be written to the log file. Notice that if this method is called with timeout=None then it actually may block. @@ -415,29 +402,10 @@ class spawn: self.flag_eof = 1 raise EOF('End Of File (EOF) in read(). Empty string style platform.') - if self.log_file != None: - self.log_file.write (s) - self.log_file.flush() - return s raise ExceptionPexpect('Reached an unexpected state in read().') - def write(self, text): - """This is an alias for send(). - This return the number of bytes actually written. - """ - return self.send (text) - - def writelines (self, sequence): - """This calls write() for each element in the sequence. - This return the number of bytes actually written. - """ - total_n = 0 - for str in sequence: - total_n = total_n + self.write (str) - return total_n - def send(self, text): """This sends a string to the child process. This return the number of bytes actually written. @@ -666,14 +634,11 @@ def forcefile(session, file, command, checkonly=None): if __name__ == '__main__': # Process options - (options, arguments) = getopt.getopt(sys.argv[1:], "cdhl:v") - optlogin = None + (options, arguments) = getopt.getopt(sys.argv[1:], "cdh:v") check = 0 verbose = 0 delete = 0 - print options - for (switch, val) in options: if (switch == '-c'): check = 1 @@ -682,8 +647,6 @@ if __name__ == '__main__': elif (switch == '-h'): print __doc__ % login raise SystemExit, 0 - elif (switch == '-l'): - optlogin = val elif (switch == '-v'): verbose = 1 @@ -694,9 +657,9 @@ if __name__ == '__main__': else: host = arguments[0] if "@" in host: - (atlogin, host) = string.split(host, "@") - login = optlogin or atlogin \ - or os.environ.get("USER") or os.environ.get("LOGNAME") + (login, host) = string.split(host, "@") + else: + login = os.environ.get("LOGNAME") or os.environ.get("USER") # Verify that key pairs are present on the local side print "Checking your local configuration..."