az ssh config --file crashes if given filename with no / #3512
Labels
feature-request
This issue requires a new behavior in the product in order be resolved.
Service Attention
This issue is responsible by Azure service team.
VM SSH
Extension name (the extension in question)
The
az ssh
extensionDescription of issue (in as much detail as possible)
Attempting to run,
Results in the following crash:
This is because
write_ssh_config
attempts to make any non-existing directories:azure-cli-extensions/src/ssh/azext_ssh/ssh_utils.py
Lines 52 to 54 in 568b8a8
Which calls this:
azure-cli-extensions/src/ssh/azext_ssh/file_utils.py
Lines 10 to 12 in 568b8a8
The immediate problem is that, for
foo
,os.path.dirname
returns''
; it then tries to create this directory, which of course fails.While that's the immediate cause, I would really not expect this utility to be creating directories like that. It's only being asked to emit the config to the path that I've specified. If a directory in that path doesn't exist, just error out & tell me. Worse, if I typo, it will created the typo'd directory. The examples in the docs for this flag also use
~/.ssh
, which needs to have strict permissions on it, which this would ignore. It's better to just to what was asked (emit the config) & not try to correct for mistakes here.The text was updated successfully, but these errors were encountered: