]> git.pld-linux.org Git - packages/openssh.git/blame - ldap-helper-sigpipe.patch
- release 2 (by relup.sh)
[packages/openssh.git] / ldap-helper-sigpipe.patch
CommitLineData
c53de5e9
ER
1ignore SIGPIPE from ldap-helper. ssh server does not read whole input if matching key is found
2
3with latest ldap patch from fedora openssh package repo
4(84822b5decc2ddd8415a3167b9ff9f0a368929a3), i encountered bug that if there are
5lots of keys for user and matching key is found near the beginning, the
6ssh-ldap-helper gets sigpipe because apparently sshd server does not read out
7whole output. and that killed by signal is propagated so that whole key auth
8fails.
9
10i'm not sure in which side the fixing should be made, should ldap-helper ignore
11SIGPIPE? should ssh authorizedkeyscommand always read up whole input?
12
13in my case user had only 51 keys outputing ~35k of text:
14# /usr/lib/openssh/ssh-ldap-helper -s git | wc
15 51 251 35685
16
17i think it's quite easy to reproduce:
18- print out matchin key early
19- produce more lines of output
20
21so, here's strace of ssh-ldap-helper being called from ssh-ldap-wrapper:
22
23execve("/usr/lib/openssh/ssh-ldap-helper", ["/usr/lib/openssh/ssh-ldap-helper", "-s", "git"], [/* 13 vars */]) = 0
24access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
25open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
26open("/usr/lib/libldap-2.4.so.2", O_RDONLY|O_CLOEXEC) = 3
27open("/usr/lib/liblber-2.4.so.2", O_RDONLY|O_CLOEXEC) = 3
28open("/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
29open("/usr/lib/libsasl2.so.3", O_RDONLY|O_CLOEXEC) = 3
30open("/lib/libresolv.so.2", O_RDONLY|O_CLOEXEC) = 3
31open("/lib/libssl.so.1.0.0", O_RDONLY|O_CLOEXEC) = 3
32open("/lib/libcrypto.so.1.0.0", O_RDONLY|O_CLOEXEC) = 3
33open("/lib/libcrypt.so.1", O_RDONLY|O_CLOEXEC) = 3
34open("/lib/libpam.so.0", O_RDONLY|O_CLOEXEC) = 3
35open("/lib/libaudit.so.1", O_RDONLY|O_CLOEXEC) = 3
36open("/lib/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3
37open("/lib/libz.so.1", O_RDONLY|O_CLOEXEC) = 3
38open("/lib/libfreebl3.so", O_RDONLY|O_CLOEXEC) = 3
39open("/dev/null", O_RDWR|O_LARGEFILE) = 4
40open("/etc/ldap.conf", O_RDONLY|O_LARGEFILE) = 4
41open("/etc/resolv.conf", O_RDONLY|O_CLOEXEC) = 4
42open("/etc/nsswitch.conf", O_RDONLY|O_CLOEXEC) = 4
43open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 4
44open("/lib/libnss_files.so.2", O_RDONLY|O_CLOEXEC) = 4
45open("/etc/host.conf", O_RDONLY|O_CLOEXEC) = 4
46open("/etc/hosts", O_RDONLY|O_CLOEXEC) = 4
47open("/etc/openldap/ldap.conf", O_RDONLY) = -1 ENOENT (No such file or directory)
48open("/tmp/ldaprc", O_RDONLY) = -1 ENOENT (No such file or directory)
49open("/tmp/.ldaprc", O_RDONLY) = -1 ENOENT (No such file or directory)
50stat64("/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=247, ...}) = 0
51open("/etc/resolv.conf", O_RDONLY|O_CLOEXEC) = 4
52open("/etc/hosts", O_RDONLY|O_CLOEXEC) = 4
53open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 4
54open("/lib/libnss_dns.so.2", O_RDONLY|O_CLOEXEC) = 4
55--- SIGPIPE {si_signo=SIGPIPE, si_code=SI_USER, si_pid=615, si_uid=99} ---
56+++ killed by SIGPIPE +++
57
58at the same time in the log:
59
60Nov 2 18:20:44 gitolite3 sshd[605]: debug1: matching key found: file /usr/lib/openssh/ssh-ldap-wrapper, line 1 DSA 96:a8:6c:5b:42:ad:b4:f3:01:fc:19:38:da:63:0b:37
61Nov 2 18:20:44 gitolite3 sshd[605]: error: AuthorizedKeysCommand /usr/lib/openssh/ssh-ldap-wrapper returned status 141
62Nov 2 18:20:44 gitolite3 sshd[605]: debug1: restore_uid: 0/0
63Nov 2 18:20:44 gitolite3 sshd[605]: debug1: temporarily_use_uid: 264/264 (e=0/0)
64Nov 2 18:20:44 gitolite3 sshd[605]: debug1: trying public key file /home/services/git/.ssh/authorized_keys
65Nov 2 18:20:44 gitolite3 sshd[605]: debug1: fd 8 clearing O_NONBLOCK
66Nov 2 18:20:44 gitolite3 sshd[605]: debug1: restore_uid: 0/0
67Nov 2 18:20:44 gitolite3 sshd[605]: Failed publickey for git from 127.0.0.1 port 34574 ssh2: DSA 96:a8:6c:5b:42:ad:b4:f3:01:fc:19:38:da:63:0b:37
68Nov 2 18:20:44 gitolite3 sshd[605]: debug1: userauth-request for user git service ssh-connection method keyboard-interactive [preauth]
69Nov 2 18:20:44 gitolite3 sshd[605]: debug1: attempt 2 failures 1 [preauth]
70Nov 2 18:20:44 gitolite3 sshd[605]: debug1: keyboard-interactive devs [preauth]
71Nov 2 18:20:44 gitolite3 sshd[605]: debug1: auth2_challenge: user=git devs= [preauth]
72Nov 2 18:20:44 gitolite3 sshd[605]: debug1: kbdint_alloc: devices 'pam' [preauth]
73Nov 2 18:20:44 gitolite3 sshd[605]: debug1: auth2_challenge_start: trying authentication method 'pam' [preauth]
74
75there's quick workaround too (without patching),
76instead of "exec ssh-ldap-helper", run it, and "exit 0" from the wrapper
77script. i don't like this solution, but it makes the problem go away:
78
79# cat /usr/lib/openssh/ssh-ldap-wrapper
80#!/bin/sh
81/usr/lib/openssh/ssh-ldap-helper -s "$1"
82exit 0
83
51f3c37a
ER
84--- openssh-6.6p1/ldap-helper.c~ 2014-05-13 17:04:22.258162978 +0300
85+++ openssh-6.6p1/ldap-helper.c 2014-05-13 17:14:08.398824417 +0300
86@@ -31,6 +31,7 @@
87 #include "ldapbody.h"
88 #include <string.h>
89 #include <unistd.h>
90+#include <signal.h>
91
92 static int config_debug = 0;
93 int config_exclusive_config_file = 0;
c53de5e9
ER
94@@ -137,6 +137,8 @@
95 ldap_checkconfig();
96 ldap_do_connect();
97
98+ signal(SIGPIPE, SIG_IGN);
99+
100 if (config_single_user) {
101 process_user (config_single_user, outfile);
102 } else {
This page took 0.118428 seconds and 4 git commands to generate.