Merge lp:~gmb/lpsetup/dont-blow-away-ssh-keys-bug-1018823 into lp:lpsetup
Status: | Merged |
---|---|
Approved by: | Graham Binns |
Approved revision: | 41 |
Merged at revision: | 40 |
Proposed branch: | lp:~gmb/lpsetup/dont-blow-away-ssh-keys-bug-1018823 |
Merge into: | lp:lpsetup |
Diff against target: |
70 lines (+50/-3) 1 file modified
lpsetup/subcommands/inithost.py (+50/-3) |
To merge this branch: | bzr merge lp:~gmb/lpsetup/dont-blow-away-ssh-keys-bug-1018823 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Benji York (community) | code | Approve | |
Review via email: mp+113192@code.launchpad.net |
Commit message
lp-setup will no longer allow you to overwrite your existing SSH keys with new values. Instead, if it encounters an existing SSH key with a value different from the one it's trying to write, it will exit with an error.
Description of the change
This branch fixes the initialize step in init_host so as to prevent the user's SSH keys being overwritten with garbage if they happen to not be paying attention to what they're doing.
I couldn't find any direct tests for initialize(), so I moved the functionality that overwrites the SSH keyfiles out into a utility function and added a doctest for it. The new functionality is to raise an error if the file already exists with different contents from those we're trying to write to it (so opening the file, reading it and then writing its contents back again - our existing behaviour - shouldn't cause problems). I've also updated python-
This looks good.
I am a little worried that mode could be something like "w+" or "a+" and that would break the function. Perhaps an assertion that the mode is "w" or "r" and nothing else.