]> thyrsus.com Git - ssh-installkeys.git/commitdiff
Allow use of new-style config location.
authorEric S. Raymond <esr@thyrsus.com>
Thu, 18 Apr 2013 17:04:42 +0000 (13:04 -0400)
committerEric S. Raymond <esr@thyrsus.com>
Thu, 18 Apr 2013 17:04:42 +0000 (13:04 -0400)
NEWS
ssh-installkeys
ssh-installkeys.xml

diff --git a/NEWS b/NEWS
index d80ad1d05f84f930fae7e4696a88ece2be3af13c..95fb3a1630930a9bc8bd39901e74d3fc9646c9c6 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
                NEWS file for project ssh-installkeys
 
+1.8 @ 2013-04-18:
+  Program can now use new-style config-file location ~/.config/ssh-installkeys
+
 1.7 @ 2012-03-26:
   Remote installations are now recorded if your create ~/.ssh-installkeys.
   Code now bails out gracefully on host key changes or broken ptys.
index 6ed1e45b5f272cb96d08bb2c2e645ffcbcd6ceed..5426ee6cc9455926ab3b5eb9828578bec83baac7 100755 (executable)
@@ -1870,7 +1870,7 @@ def split_command_line(command_line):
 #
 ###############################################################################
 
-version = 1.7
+version = 1.8
 
 class ssh_session:
     "Session with extra state including the password to be used."
@@ -1948,14 +1948,19 @@ class KeyConfig(ConfigParser.RawConfigParser):
     "Store our state about remote keys."
     def __init__(self):
         ConfigParser.RawConfigParser.__init__(self)
-        self.have_config = os.path.exists(KeyConfig.configfile())
-        self.read(KeyConfig.configfile())
-    @staticmethod
-    def configfile():
-        return os.path.expanduser('~/.ssh-installkeys')
+        newstyle = os.path.expanduser('~/.config/ssh-installkeys')
+        oldstyle = os.path.expanduser('~/.ssh-installkeys')
+        if os.path.exists(newstyle):
+            self.configfile = newstyle
+        elif os.path.exists(oldstyle):
+            self.configfile = oldstyle
+        else:
+            self.configfile = None
+        if self.configfile:
+            self.read(self.configfile)
     def save(self):
-        if self.have_config:
-            self.write(open(KeyConfig.configfile(), "w"))
+        if self.configfile:
+            self.write(open(self.configfile, "w"))
     def remember(self, session):
         authorized = session.ssh("cat $HOME/.ssh/authorized_keys")
         keydict = {}
@@ -2012,7 +2017,11 @@ def forcefile(session, fn, command, checkonly=False):
 
 if __name__ == '__main__': 
     # Process options
-    (options, arguments) = getopt.getopt(sys.argv[1:], "cdhvp:")
+    try:
+        (options, arguments) = getopt.getopt(sys.argv[1:], "cdhvp:")
+    except getopt.GetoptError, e:
+        print e
+        sys.exit(1)
     check = 0
     verbose = 0
     delete = 0
@@ -2128,6 +2137,7 @@ if __name__ == '__main__':
         pass
     except RuntimeError:
         sys.exit(-1)
+
     # It's all over now...
     os.remove(keyfile)
     config.save()
index 55a0c416d8dac4393202ae7e081c857ad8d64495..fdf4f85194a0f5f0c1f46f91f9e8e984cd25de64 100644 (file)
@@ -50,12 +50,13 @@ user@host syntax to force the remote username.</para>
 </refsect1>
 <refsect1><title>Recording remote key locations</title>
 
-<para>If the file <filename>~/.ssh/installkeys</filename> exists,
-places where you install keys will be recorded in it. This record will 
-also be updated when you use the check option, so you can use
-that option to check sites where you may have previously installed
-keys and add them to the list. Entries are removed when you
-delete remote keys.</para>
+<para>If either of the files
+<filename>~/.config/ssh/installkeys</filename> or
+<filename>~/.ssh/installkeys</filename> exists, places where you
+install keys will be recorded in it. This record will also be updated
+when you use the check option, so you can use that option to check
+sites where you may have previously installed keys and add them to the
+list. Entries are removed when you delete remote keys.</para>
 
 <para>Beware that if your account is cracked, this record will offer
 the intruder a menu of other systems to attack, escalating security