Portable OpenSSH on Linux: confusing error message with scp

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

 



Hi,

With OpenSSH 8.9p1 (and earlier) and scp server-side on Linux 5.13,
one gets a very confusing error message when the target directory ends
with / and *does not exist*:

	% scp /etc/issue localhost:/usr/foobar/
	scp: /usr/foobar/: Is a directory

stracing shows:

[pid 32671] stat("/usr/foobar/", 0x7fff4aaa5fd0) = -1 ENOENT (No such file or directory)
[pid 32671] openat(AT_FDCWD, "/usr/foobar/", O_WRONLY|O_CREAT, 0644) = -1 EISDIR (Is a directory)

scp.c does rougly:

                exists = stat(np, &stb) == 0;
                /* ... stuff elided ... */
                if ((ofd = open(np, O_WRONLY|O_CREAT, mode)) == -1) {
bad:                    run_err("%s: %s", np, strerror(errno));
                        continue;
                }

open(2) says:

       EISDIR pathname refers to a directory and the access requested involved
              writing (that is, O_WRONLY or O_RDWR is set).

Apparently, on OpenBSD it prints "No such file or directory" instead.

I wonder if adding

		if (errno == EISDIR)
			errno = ENOENT;

would be a suitable override, or perhaps you have a better idea.
But printing something is directory when it isn't is confusing. :)

cu,
-- 
Leah Neukirchen  <leah@xxxxxxxx>  https://leahneukirchen.org/
_______________________________________________
openssh-unix-dev mailing list
openssh-unix-dev@xxxxxxxxxxx
https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev



[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux