From 8d0030f3d2ffcbbf27e475e0b9032e74dede5b8f Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Fri, 18 Mar 2011 16:38:30 +0000 Subject: Allow ssh-add to read from FIFOs (thanks, Daniel Kahn Gillmor; closes: #614897). --- authfile.c | 7 +++++-- debian/changelog | 2 ++ debian/patches/series | 1 + debian/patches/ssh-add-fifo.patch | 37 +++++++++++++++++++++++++++++++++++++ 4 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 debian/patches/ssh-add-fifo.patch diff --git a/authfile.c b/authfile.c index be650af67..2ed250232 100644 --- a/authfile.c +++ b/authfile.c @@ -317,7 +317,7 @@ key_parse_public_rsa1(Buffer *blob, char **commentp) static int key_load_file(int fd, const char *filename, Buffer *blob) { - size_t len; + size_t len, readcount; u_char *cp; struct stat st; @@ -337,11 +337,14 @@ key_load_file(int fd, const char *filename, Buffer *blob) return 0; } len = (size_t)st.st_size; /* truncated */ + if (0 == len && S_ISFIFO(st.st_mode)) + len = 8192; /* we will try reading up to 8KiB from a FIFO */ buffer_init(blob); cp = buffer_append_space(blob, len); - if (atomicio(read, fd, cp, len) != len) { + readcount = atomicio(read, fd, cp, len); + if (readcount != len && !(readcount > 0 && S_ISFIFO(st.st_mode))) { debug("%s: read from key file %.200s%sfailed: %.100s", __func__, filename == NULL ? "" : filename, filename == NULL ? "" : " ", diff --git a/debian/changelog b/debian/changelog index b79607514..c75c3f031 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,8 @@ openssh (1:5.8p1-3) UNRELEASED; urgency=low * Correct ssh-keygen instruction in the changelog for 1:5.7p1-1 (thanks, Joel Stanley). + * Allow ssh-add to read from FIFOs (thanks, Daniel Kahn Gillmor; closes: + #614897). -- Colin Watson Wed, 09 Feb 2011 03:02:45 +0000 diff --git a/debian/patches/series b/debian/patches/series index a243174dd..0a21f8ead 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -38,6 +38,7 @@ doc-hash-tab-completion.patch # Miscellaneous bug fixes selinux-build-failure.patch +ssh-add-fifo.patch # Debian-specific configuration gnome-ssh-askpass2-icon.patch diff --git a/debian/patches/ssh-add-fifo.patch b/debian/patches/ssh-add-fifo.patch new file mode 100644 index 000000000..deac58e75 --- /dev/null +++ b/debian/patches/ssh-add-fifo.patch @@ -0,0 +1,37 @@ +Description: Allow ssh-add to read from FIFOs +Author: Daniel Kahn Gillmor +Bug: https://bugzilla.mindrot.org/show_bug.cgi?id=1869 +Bug-Debian: http://bugs.debian.org/614897 +Origin: other, https://bugzilla.mindrot.org/attachment.cgi?id=2002&action=diff +Forwarded: yes +Last-Update: 2011-03-18 + +Index: b/authfile.c +=================================================================== +--- a/authfile.c ++++ b/authfile.c +@@ -317,7 +317,7 @@ + static int + key_load_file(int fd, const char *filename, Buffer *blob) + { +- size_t len; ++ size_t len, readcount; + u_char *cp; + struct stat st; + +@@ -337,11 +337,14 @@ + return 0; + } + len = (size_t)st.st_size; /* truncated */ ++ if (0 == len && S_ISFIFO(st.st_mode)) ++ len = 8192; /* we will try reading up to 8KiB from a FIFO */ + + buffer_init(blob); + cp = buffer_append_space(blob, len); + +- if (atomicio(read, fd, cp, len) != len) { ++ readcount = atomicio(read, fd, cp, len); ++ if (readcount != len && !(readcount > 0 && S_ISFIFO(st.st_mode))) { + debug("%s: read from key file %.200s%sfailed: %.100s", __func__, + filename == NULL ? "" : filename, + filename == NULL ? "" : " ", -- cgit v1.2.3