Merge lp:~smoser/ssh-import-id/trunk.lp1570997 into lp:ssh-import-id

Proposed by Scott Moser
Status: Merged
Merged at revision: 213
Proposed branch: lp:~smoser/ssh-import-id/trunk.lp1570997
Merge into: lp:ssh-import-id
Diff against target: 28 lines (+10/-1)
1 file modified
ssh_import_id/__init__.py (+10/-1)
To merge this branch: bzr merge lp:~smoser/ssh-import-id/trunk.lp1570997
Reviewer Review Type Date Requested Status
ssh-import-id Pending
Review via email: mp+326692@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ssh_import_id/__init__.py'
2--- ssh_import_id/__init__.py 2016-09-16 15:13:35 +0000
3+++ ssh_import_id/__init__.py 2017-07-03 16:18:54 +0000
4@@ -18,6 +18,7 @@
5 # along with ssh-import-id. If not, see <http://www.gnu.org/licenses/>.
6
7 import argparse
8+import getpass
9 import json
10 import logging
11 import os
12@@ -132,7 +133,15 @@
13 Locate key file, read the current state, return lines in a list
14 """
15 lines = []
16- output_file = parser.options.output or os.path.join(os.getenv("HOME"), ".ssh", "authorized_keys")
17+ if parser.options.output:
18+ output_file = parser.options.output
19+ else:
20+ if os.environ.get("HOME"):
21+ home = os.environ["HOME"]
22+ else
23+ home = os.path.expanduser("~" + getpass.getuser())
24+ output_file = os.path.join(home, ".ssh", "authorized_keys")
25+
26 if os.path.exists(output_file):
27 try:
28 with open(output_file, "r") as f:

Subscribers

People subscribed via source and target branches