LGTM, thanks

On Fri, Jul 03, 2015 at 09:27:34AM +0000, Helga Velroyen wrote:
Hi!

indeed, sorry I missed that option. I tried it and it indeed creates the
directory with the correct permissions. So disregard the patch, but
consider this one (*not* an interdiff, it's the entire patch with the
description from the original one).

diff --git a/lib/ssh.py b/lib/ssh.py
index 4514b5e..bf39606 100644
--- a/lib/ssh.py
+++ b/lib/ssh.py
@@ -684,7 +684,7 @@ def InitSSHSetup(error_fn=errors.OpPrereqError,
_homedir_fn=None,

  """
  priv_key, _, auth_keys = GetUserFiles(constants.SSH_LOGIN_USER,
-                                        _homedir_fn=_homedir_fn)
+                                        mkdir=True,
_homedir_fn=_homedir_fn)

  new_priv_key_name = priv_key + _suffix
  new_pub_key_name = priv_key + _suffix + ".pub"


On Fri, 3 Jul 2015 at 10:42 Petr Pudlak <[email protected]> wrote:

On Wed, Jul 01, 2015 at 05:25:03PM +0200, 'Helga Velroyen' via
ganeti-devel wrote:
>This patch extends the SSH handling by creating the .ssh
>directory when generating SSH keys if it did not exist
>yet. This fixes Issue 1103.
>
>Signed-off-by: Helga Velroyen <[email protected]>
>---
> lib/ssh.py | 7 +++++++
> 1 file changed, 7 insertions(+)
>
>diff --git a/lib/ssh.py b/lib/ssh.py
>index 4514b5e..efee389 100644
>--- a/lib/ssh.py
>+++ b/lib/ssh.py
>@@ -48,6 +48,7 @@ from ganeti import vcluster
> from ganeti import compat
> from ganeti import serializer
> from ganeti import ssconf
>+from ganeti import runtime
>
>
> def GetUserFiles(user, mkdir=False, dircheck=True,
kind=constants.SSHK_DSA,
>@@ -694,6 +695,12 @@ def InitSSHSetup(error_fn=errors.OpPrereqError,
_homedir_fn=None,
>       utils.CreateBackup(name)
>     utils.RemoveFile(name)
>
>+  ssh_dir = utils.PathJoin(_homedir_fn(constants.SSH_LOGIN_USER), ".ssh")
>+  if not os.path.exists(ssh_dir):
>+    getent = runtime.GetEnts()
>+    utils.MakeDirWithPerm(ssh_dir, "700", getent.noded_uid,
>+                          getent.noded_gid)

Function GetUserFiles that is called just at the beginning of InitSSHSetup
has an keyword argument "mkdir" that does just that. There is a slight
difference though, it seems that GetUserFiles doesn't ensure the proper
owner. So perhaps adding mkdir=True above instead would suffice? And check,
if it might be necessary to update the owner/group and if so, add it to
   GetUserFiles?

Thanks!

Petr

>+
>   result = utils.RunCmd(["ssh-keygen", "-t", "dsa",
>                          "-f", new_priv_key_name,
>                          "-q", "-N", ""])
>--
>2.4.3.573.g4eafbef
>

Reply via email to