Portable OpenSSH on Linux: confusing error message with scp
Thorsten Glaser
t.glaser at tarent.de
Wed Apr 6 10:27:17 AEST 2022
On Tue, 5 Apr 2022, Leah Neukirchen wrote:
> 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;
> }
> would be a suitable override, or perhaps you have a better idea.
Without looking at the code (asking the Linux kernel developers to
fix their errno… probably doesn’t have a chance), maybe:
nexists = stat(np, &stb) ? errno : 0;
/*…*/
if (nexists ||
(ofd = open(np, O_WRONLY|O_CREAT, mode)) == -1) {
run_err("%s: %s", np,
strerror(nexists ? nexists : errno));
continue;
}
(and do something about that bad label)
Or even:
if (!(exists = stat(np, &stb) == 0))
goto bad;
/*… rest as above */
But only if that elided stuff isn’t important. If it is, maybe:
nexists = stat(np, &stb) ? errno : 0;
/*…*/
if ((ofd = open(np, O_WRONLY|O_CREAT, mode)) == -1) {
run_err("%s: %s", np,
strerror(nexists ? nexists : errno));
continue;
}
Just a shoot into the blue that came to me while reading the mail.
bye,
//mirabilos
--
Sometimes they [people] care too much: pretty printers [and syntax highligh-
ting, d.A.] mechanically produce pretty output that accentuates irrelevant
detail in the program, which is as sensible as putting all the prepositions
in English text in bold font. -- Rob Pike in "Notes on Programming in C"
More information about the openssh-unix-dev
mailing list