1 Description: Allow ssh-add to read from FIFOs
2 Author: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
3 Bug: https://bugzilla.mindrot.org/show_bug.cgi?id=1869
4 Bug-Debian: http://bugs.debian.org/614897
5 Origin: other, https://bugzilla.mindrot.org/attachment.cgi?id=2002&action=diff
7 Last-Update: 2011-03-18
10 ===================================================================
15 key_load_file(int fd, const char *filename, Buffer *blob)
18 + size_t len, readcount;
25 len = (size_t)st.st_size; /* truncated */
26 + if (0 == len && S_ISFIFO(st.st_mode))
27 + len = 8192; /* we will try reading up to 8KiB from a FIFO */
30 cp = buffer_append_space(blob, len);
32 - if (atomicio(read, fd, cp, len) != len) {
33 + readcount = atomicio(read, fd, cp, len);
34 + if (readcount != len && !(readcount > 0 && S_ISFIFO(st.st_mode))) {
35 debug("%s: read from key file %.200s%sfailed: %.100s", __func__,
36 filename == NULL ? "" : filename,
37 filename == NULL ? "" : " ",