On Wed, Feb 05, 2014 at 12:52:12PM -0500, Ted Unangst wrote:
> On Wed, Feb 05, 2014 at 12:41, Brad Smith wrote:
> >> They do (but through errno).  Of course there may be other places where
> >> the internal functions clobber errno before returning to the user code,
> >> but some fixes have been applied already (eg. rev 1.43 of getpwent.c).
> > 
> > Is anyone actually looking into fixing this? This issue was also noticed
> > when Dovecot was updated to 2.2 and it broke local account authentication.
> 
> Test cases? The fix here will fix this test case, but it's probably
> one of the more contrived error cases.

Well I don't have a minimal test but for Dovecot nothing special had to
be done. Out of the box it'll try to authenticate against local user
accounts. Just trying to login to the IMAP server with the non-compliant
functions as is would fail. The diff below reverts the hack that was added
for OpenBSD to workaround the non-compliant state of these functions. I
haven't tested guenther@'s diff yet but I'll do so in a bit.


Index: Makefile
===================================================================
RCS file: /home/cvs/ports/mail/dovecot/Makefile,v
retrieving revision 1.218
diff -u -p -u -p -r1.218 Makefile
--- Makefile    22 Dec 2013 22:23:10 -0000      1.218
+++ Makefile    6 Feb 2014 05:02:49 -0000
@@ -20,6 +20,8 @@ PKGNAME-postgresql= dovecot-postgresql-$
 CATEGORIES=    mail
 MASTER_SITES=  ${HOMEPAGE}releases/${V_MAJOR}/
 
+REVISION-server=       0
+
 SHARED_LIBS=   dovecot-compression 0.0 \
                dovecot-lda     2.0 \
                dovecot-login   2.0 \
Index: patches/patch-src_lib_ipwd_c
===================================================================
RCS file: patches/patch-src_lib_ipwd_c
diff -N patches/patch-src_lib_ipwd_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_lib_ipwd_c        6 Feb 2014 05:04:40 -0000
@@ -0,0 +1,27 @@
+$OpenBSD$
+--- src/lib/ipwd.c.orig        Thu Feb  6 00:04:06 2014
++++ src/lib/ipwd.c     Thu Feb  6 00:04:31 2014
+@@ -50,11 +50,6 @@ int i_getpwnam(const char *name, struct passwd *pwd_r)
+       do {
+               pw_init();
+               errno = getpwnam_r(name, pwd_r, pwbuf, pwbuf_size, &result);
+-#ifdef __OpenBSD__
+-              /* OpenBSD returns 1 for all errors, assume it's ERANGE */
+-              if (errno == 1)
+-                      errno = ERANGE;
+-#endif
+       } while (errno == ERANGE);
+       if (result != NULL)
+               return 1;
+@@ -73,11 +68,6 @@ int i_getpwuid(uid_t uid, struct passwd *pwd_r)
+       do {
+               pw_init();
+               errno = getpwuid_r(uid, pwd_r, pwbuf, pwbuf_size, &result);
+-#ifdef __OpenBSD__
+-              /* OpenBSD returns 1 for all errors, assume it's ERANGE */
+-              if (errno == 1)
+-                      errno = ERANGE;
+-#endif
+       } while (errno == ERANGE);
+       if (result != NULL)
+               return 1;

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

Reply via email to