bugzilla-daemon at bugzilla.mindrot.org
2015-Oct-21 16:03 UTC
[Bug 2481] New: Tilde expansion in -i option inconsistent
https://bugzilla.mindrot.org/show_bug.cgi?id=2481
Bug ID: 2481
Summary: Tilde expansion in -i option inconsistent
Product: Portable OpenSSH
Version: 6.6p1
Hardware: All
OS: Linux
Status: NEW
Severity: trivial
Priority: P5
Component: ssh
Assignee: unassigned-bugs at mindrot.org
Reporter: nick at nicklott.com
Just noticed some odd behaviour in the identity file option with ~. If
you don't leave a space between -i and the filename the ~ is not
expanded and thus the file is not found. If you leave a space it works
as expected.
ie This doesn't work:
ssh -i~/key_file
This does:
ssh -i ~/key_file
Excerpts from respective strace:
---snip--
stat("~/.ssh/keyfile", 0x7fff73320010) = -1 ENOENT (No such file or
directory)
write(2, "Warning: Identity file ~/.ssh/ke"..., 82Warning: Identity
file ~/.ssh/keyfile not accessible: No such file or directory.
---snip--
---snip--
stat("/home/ec2-user/.ssh/keyfile", {st_mode=S_IFREG|0600,
st_size=1676, ...}) = 0
write(2, "usage: ssh [-1246AaCfgKkMNnqsTtV"..., 524usage: ssh
[-1246AaCfgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]
---snip--
Without a tilde it works with or without a space.
--
You are receiving this mail because:
You are watching the assignee of the bug.
bugzilla-daemon at bugzilla.mindrot.org
2015-Oct-21 22:37 UTC
[Bug 2481] Tilde expansion in -i option inconsistent
https://bugzilla.mindrot.org/show_bug.cgi?id=2481
Darren Tucker <dtucker at zip.com.au> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |dtucker at zip.com.au
--- Comment #1 from Darren Tucker <dtucker at zip.com.au> ---
The reason for the discrepancy is that in this case, -i doesn't do
tilde expansion, the shell does. It only does it at the start of an
argument, and when you combine the arguments like that it doesn't
expand:
$ echo -i~/bin
-i~/bin
$ echo -i ~/bin
-i /home/dtucker/bin
This then falls foul of the file existence check inside the -i
handling:
case 'i':
if (stat(optarg, &st) < 0) {
fprintf(stderr, "Warning: Identity file %s "
"not accessible: %s.\n", optarg,
strerror(errno));
break;
}
add_identity_file(&options, NULL, optarg, 1);
break;
and the key doesn't get added before the call to tilde_expand_filename
later. We could probably fix this by adding a call to
tilde_expand_filename in the -i handling.
--
You are receiving this mail because:
You are watching the assignee of the bug.
You are watching someone on the CC list of the bug.
bugzilla-daemon at bugzilla.mindrot.org
2015-Oct-21 22:49 UTC
[Bug 2481] Tilde expansion in -i option inconsistent
https://bugzilla.mindrot.org/show_bug.cgi?id=2481
Darren Tucker <dtucker at zip.com.au> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |djm at mindrot.org
Attachment #2731| |ok?(djm at mindrot.org)
Flags| |
--- Comment #2 from Darren Tucker <dtucker at zip.com.au> ---
Created attachment 2731
--> https://bugzilla.mindrot.org/attachment.cgi?id=2731&action=edit
Expand tildes for arguments passed to -i.
Please try this patch.
--
You are receiving this mail because:
You are watching someone on the CC list of the bug.
You are watching the assignee of the bug.
bugzilla-daemon at bugzilla.mindrot.org
2015-Oct-21 22:49 UTC
[Bug 2481] Tilde expansion in -i option inconsistent
https://bugzilla.mindrot.org/show_bug.cgi?id=2481
Darren Tucker <dtucker at zip.com.au> changed:
What |Removed |Added
----------------------------------------------------------------------------
Blocks| |2451
Referenced Bugs:
https://bugzilla.mindrot.org/show_bug.cgi?id=2451
[Bug 2451] Bugs intended to be fixed in 7.2
--
You are receiving this mail because:
You are watching the assignee of the bug.
You are watching someone on the CC list of the bug.
bugzilla-daemon at bugzilla.mindrot.org
2015-Oct-21 23:08 UTC
[Bug 2481] Tilde expansion in -i option inconsistent
https://bugzilla.mindrot.org/show_bug.cgi?id=2481
Darren Tucker <dtucker at zip.com.au> changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #2731|ok?(djm at mindrot.org) |
Flags| |
Attachment #2731|0 |1
is obsolete| |
Assignee|unassigned-bugs at mindrot.org |dtucker at zip.com.au
--- Comment #3 from Darren Tucker <dtucker at zip.com.au> ---
Created attachment 2732
--> https://bugzilla.mindrot.org/attachment.cgi?id=2732&action=edit
Expand tildes for arguments passed to -i.
oops, missed a line.
--
You are receiving this mail because:
You are watching someone on the CC list of the bug.
You are watching the assignee of the bug.
bugzilla-daemon at bugzilla.mindrot.org
2015-Oct-22 08:16 UTC
[Bug 2481] Tilde expansion in -i option inconsistent
https://bugzilla.mindrot.org/show_bug.cgi?id=2481 --- Comment #4 from nick at nicklott.com --- Ah, didn't occur to me that is was the shell. Yep, that patch seems to work for me. -- You are receiving this mail because: You are watching the assignee of the bug. You are watching someone on the CC list of the bug.
bugzilla-daemon at bugzilla.mindrot.org
2015-Oct-25 23:42 UTC
[Bug 2481] Tilde expansion in -i option inconsistent
https://bugzilla.mindrot.org/show_bug.cgi?id=2481
Darren Tucker <dtucker at zip.com.au> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|NEW |RESOLVED
--- Comment #5 from Darren Tucker <dtucker at zip.com.au> ---
(slightly simplified) patch applied and will be in the 7.2 release.
Thanks.
--
You are receiving this mail because:
You are watching someone on the CC list of the bug.
You are watching the assignee of the bug.
bugzilla-daemon at bugzilla.mindrot.org
2016-Aug-02 00:41 UTC
[Bug 2481] Tilde expansion in -i option inconsistent
https://bugzilla.mindrot.org/show_bug.cgi?id=2481
Damien Miller <djm at mindrot.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |CLOSED
--- Comment #6 from Damien Miller <djm at mindrot.org> ---
Close all resolved bugs after 7.3p1 release
--
You are receiving this mail because:
You are watching the assignee of the bug.
You are watching someone on the CC list of the bug.
Seemingly Similar Threads
- [PATCH] Expand tilde for UNIX domain socket forwards.
- [PATCH] Expand tilde for UNIX domain socket forwards.
- CentOS6 and tilde expansion
- Tilde expansion in ManageSieve for dovecot-1.1.
- [klibc:update-dash] dash: expand: Use HOME in tilde expansion when it is empty