Revision 7bd70e6b lib/ssh.py
b/lib/ssh.py | ||
---|---|---|
48 | 48 |
return ":".join(re.findall(r"..", fingerprint.lower())) |
49 | 49 |
|
50 | 50 |
|
51 |
def GetUserFiles(user, mkdir=False, kind=constants.SSHK_DSA, |
|
51 |
def GetUserFiles(user, mkdir=False, dircheck=True, kind=constants.SSHK_DSA,
|
|
52 | 52 |
_homedir_fn=None): |
53 | 53 |
"""Return the paths of a user's SSH files. |
54 | 54 |
|
... | ... | |
56 | 56 |
@param user: Username |
57 | 57 |
@type mkdir: bool |
58 | 58 |
@param mkdir: Whether to create ".ssh" directory if it doesn't exist |
59 |
@type dircheck: bool |
|
60 |
@param dircheck: Whether to check if ".ssh" directory exists |
|
59 | 61 |
@type kind: string |
60 | 62 |
@param kind: One of L{constants.SSHK_ALL} |
61 | 63 |
@rtype: tuple; (string, string, string) |
... | ... | |
64 | 66 |
@raise errors.OpExecError: When home directory of the user can not be |
65 | 67 |
determined |
66 | 68 |
@raise errors.OpExecError: Regardless of the C{mkdir} parameters, this |
67 |
exception is raised if C{~$user/.ssh} is not a directory |
|
69 |
exception is raised if C{~$user/.ssh} is not a directory and C{dircheck} |
|
70 |
is set to C{True} |
|
68 | 71 |
|
69 | 72 |
""" |
70 | 73 |
if _homedir_fn is None: |
... | ... | |
84 | 87 |
ssh_dir = utils.PathJoin(user_dir, ".ssh") |
85 | 88 |
if mkdir: |
86 | 89 |
utils.EnsureDirs([(ssh_dir, constants.SECURE_DIR_MODE)]) |
87 |
elif not os.path.isdir(ssh_dir): |
|
90 |
elif dircheck and not os.path.isdir(ssh_dir):
|
|
88 | 91 |
raise errors.OpExecError("Path %s is not a directory" % ssh_dir) |
89 | 92 |
|
90 | 93 |
return [utils.PathJoin(ssh_dir, base) |
Also available in: Unified diff