Sender: owner-m...@openbsd.org
On-Behalf-Of: s...@spacehopper.org
Subject: Re: dovecot issues
Message-Id: <slrnlqda14.53v....@naiad.spacehopper.org>
Recipient: adam.atkin...@damovo.com
Received: from Mail2.damovo.com (109.204.121.44)
        by UK001B237.d.grp (10.8.1.9) with Microsoft SMTP Server (TLS) id 
14.2.318.4; Sun, 22 Jun 2014 10:56:38 +0100
Received: from cluster-j.mailcontrol.com (85.115.54.190)
        by Mail2.damovo.com (109.204.121.44) with Microsoft SMTP Server (TLS) 
id 14.2.318.4; Sun, 22 Jun 2014 10:56:36 +0100
Received: from shear.ucar.edu (lists.openbsd.org [192.43.244.163])
        by rly33j.srv.mailcontrol.com (MailControl) with ESMTP id 
s5M9uXqK017194 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 
verify=FAIL)
        for <adam.atkin...@damovo.com>; Sun, 22 Jun 2014 10:56:36 +0100
Received: from openbsd.org (localhost [127.0.0.1])
        by shear.ucar.edu (8.14.5/8.14.5) with ESMTP id s5MA6YIX016881
        for <adam.atkin...@damovo.com>; Sun, 22 Jun 2014 04:06:36 -0600 (MDT)
Received: from plane.gmane.org (plane.gmane.org [80.91.229.3])
        by shear.ucar.edu (8.14.5/8.14.5) with ESMTP id s5MA6Asi022634
        for <misc@openbsd.org>; Sun, 22 Jun 2014 04:06:11 -0600 (MDT)
Received: from list
        by plane.gmane.org with local (Exim 4.69) (envelope-from 
<goom-m...@m.gmane.org>) id 1WyeVD-00063u-5m
        for misc@openbsd.org; Sun, 22 Jun 2014 11:55:59 +0200
Received: from naiad.spacehopper.org ([195.95.187.26])
        by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00
        for <misc@openbsd.org>; Sun, 22 Jun 2014 11:55:59 +0200
Received: from stu
        by naiad.spacehopper.org with local (Gmexim 0.1 (Debian)) id 
1AlnuQ-0007hv-00
        for <misc@openbsd.org>; Sun, 22 Jun 2014 11:55:59 +0200
X-Injected-Via-Gmane: http://gmane.org/
To: <misc@openbsd.org>
From: Stuart Henderson <s...@spacehopper.org>
Subject: Re: dovecot issues
Date: Sun, 22 Jun 2014 09:55:48 +0000
Lines: 126
Message-ID: <slrnlqda14.53v....@naiad.spacehopper.org>
References: <53a4f29b.90...@pettijohn.no-ip.biz> 
<2805d8d2f74335349086adea01d62...@chaoticsystems.org> 
<53a4f88b.6040...@pettijohn.no-ip.biz> 
<57151f82a682a28b0168eadb701b6...@chaoticsystems.org> 
<53a50821.1040...@pettijohn.no-ip.biz> <53a50bf3.8050...@pettijohn.no-ip.biz> 
<20140621071729.gd2...@fubar.drijf.net>
X-Complaints-To: use...@ger.gmane.org
X-Gmane-NNTP-Posting-Host: naiad.spacehopper.org
User-Agent: slrn/1.0.1 (OpenBSD)
List-Help: <mailto:majord...@openbsd.org?body=help>
List-ID: <misc.openbsd.org>
List-Owner: <mailto:owner-m...@openbsd.org>
List-Post: <mailto:misc@openbsd.org>
List-Subscribe: <mailto:majord...@openbsd.org?body=sub%20misc>
List-Unsubscribe: <mailto:majord...@openbsd.org?body=unsub%20misc>
X-Loop: misc@openbsd.org
Precedence: list
Sender: <owner-m...@openbsd.org>
X-Mailcontrol-Inbound: 8gSgIv9v3sbRnxYICSb3h!uiaIa96vptNsOUTq2TeYo=
X-Spam-Score: -0.7
X-Scanned-By: MailControl 28796.38 (www.mailcontrol.com) on 10.74.0.143
MIME-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
Return-Path: owner-misc+M140771=adam.atkinson=damovo....@openbsd.org
X-MS-Exchange-Organization-OriginalArrivalTime: 22 Jun 2014 09:56:36.9984 (UTC)
X-MS-Exchange-Organization-OriginalClientIPAddress: 85.115.54.190
X-MS-Exchange-Organization-OriginalServerIPAddress: 109.204.121.44
X-MS-Exchange-Organization-MessageDirectionality: Incoming
X-MS-Exchange-Organization-Cross-Premises-Headers-Processed: Mail2.damovo.com
X-MS-Exchange-Organization-PRD: openbsd.org
Received-SPF: None (Mail2.damovo.com: owner-m...@openbsd.org does not designate 
permitted sender hosts)
X-MS-Exchange-Organization-OriginalSize: 6183
X-MS-Exchange-Forest-MessageScope: 00000000-0000-0000-0000-000000000000
X-MS-Exchange-Organization-MessageScope: 00000000-0000-0000-0000-000000000000
X-MS-Exchange-Organization-HygienePolicy: Standard
X-MS-Exchange-Organization-AVStamp-Mailbox: MSFTFF;1;0;0 0 0
X-MS-Exchange-Organization-MessageLatencyInProgress: 
LSRV=Mail2.damovo.com:TOTAL=0;2014-06-22T09:56:37.232Z
X-MS-Exchange-Forest-ArrivalHubServer: UK001B237.d.grp
X-MS-Exchange-Organization-SenderIdResult: NONE
X-MS-Exchange-Organization-AuthSource: Mail2.damovo.com
X-MS-Exchange-Organization-AuthAs: Anonymous
X-MS-Exchange-Organization-MessageLatency: SRV=Mail2.damovo.com:TOTAL=0
X-MS-Exchange-Organization-Recipient-Limit-Verified: True
X-MS-Exchange-Forest-RulesExecuted: UK001B237
X-MS-Exchange-Organization-Rules-Execution-History: 
WW-SetDomainsAsNotJunk%%%DamovoUK-FaultEscalation%%%DamovoUK_AutoResponse%%%DE-UPSAlarmRule%%%BE-OutboundDisclaimer%%%WW-OutboundDisclaimer%%%UK-OutboundDisclaimer%%%IE-OutboundDisclaimer%%%DamovoUK_GFiRule%%%DE-Redirect_Techem%%%CH-SupportRule%%%UKScanToEmailBlockExternal

On 2014-06-21, Otto Moerbeek <o...@drijf.net> wrote:
>
> This is a know bug. If an unknown user tries to log in, the login code
> goes into a loop expanding a buffer until it runs out of mem. The
> cause of the bug is also known, but nobody (including myself) came up
> with a diff yet.

To be clear: this is fixed in libc but it's a post-5.5 change - when Otto
says that nobody came up with a diff, he's talking about a diff to have
dovecot cope with the old libc code. The relevant libc commit (below) should
apply directly to a 5.5 system.

Also note that you can use a separate passwd-like file for dovecot
authentication, which is not affected by this bug, so you can work around
it without configuring ldap/sql. (Personally I like to use different
passwords for email and login accounts so I do this anyway..)


---------------------
PatchSet 5269 
Date: 2014/03/05 23:44:47
Author: schwarze
Branch: HEAD
Tag: (none) 
Log:
Fix the return values of getpwnam_r(), getpwuid_r(), getgrnam_r(),
and getgrgid_r() to agree with POSIX.  Not touching errno handling
yet, which will also need fixing.

Problem originally reported by william at 25thandClement dot com on bugs@.
OK sthen@, and kettenis@ agrees it's "a step in the right direction".

Members: 
        gen/getgrent.c:1.38->1.39 
        gen/getpwent.c:1.48->1.49 

Index: src/lib/libc/gen/getgrent.c
diff -u src/lib/libc/gen/getgrent.c:1.38 src/lib/libc/gen/getgrent.c:1.39
--- src/lib/libc/gen/getgrent.c:1.38    Wed Apr 17 17:40:35 2013
+++ src/lib/libc/gen/getgrent.c Wed Mar  5 23:44:47 2014
@@ -1,4 +1,4 @@
-/*     $OpenBSD: getgrent.c,v 1.38 2013/04/17 17:40:35 tedu Exp $ */
+/*     $OpenBSD: getgrent.c,v 1.39 2014/03/05 23:44:47 schwarze Exp $ */
 /*
  * Copyright (c) 1989, 1993
  *     The Regents of the University of California.  All rights reserved.
@@ -134,6 +134,7 @@
        if (bufsize < GETGR_R_SIZE_MAX)
                return ERANGE;
        errnosave = errno;
+       errno = 0;
        *result = getgrnam_gs(name, grp, (struct group_storage *)buffer);
        if (*result == NULL)
                ret = errno;
@@ -180,6 +181,7 @@
        if (bufsize < GETGR_R_SIZE_MAX)
                return ERANGE;
        errnosave = errno;
+       errno = 0;
        *result = getgrgid_gs(gid, grp, (struct group_storage *)buffer);
        if (*result == NULL)
                ret = errno;
Index: src/lib/libc/gen/getpwent.c
diff -u src/lib/libc/gen/getpwent.c:1.48 src/lib/libc/gen/getpwent.c:1.49
--- src/lib/libc/gen/getpwent.c:1.48    Fri Nov 15 22:32:55 2013
+++ src/lib/libc/gen/getpwent.c Wed Mar  5 23:44:47 2014
@@ -1,4 +1,4 @@
-/*     $OpenBSD: getpwent.c,v 1.48 2013/11/15 22:32:55 benno Exp $ */
+/*     $OpenBSD: getpwent.c,v 1.49 2014/03/05 23:44:47 schwarze Exp $ */
 /*
  * Copyright (c) 2008 Theo de Raadt
  * Copyright (c) 1988, 1993
@@ -708,8 +708,12 @@
 {
        struct passwd *pwret = NULL;
        int flags = 0, *flagsp;
+       int my_errno = 0;
+       int saved_errno;
 
        _THREAD_PRIVATE_MUTEX_LOCK(pw);
+       saved_errno = errno;
+       errno = 0;
        if (!_pw_db && !__initdb())
                goto fail;
 
@@ -733,8 +737,12 @@
 fail:
        if (pwretp)
                *pwretp = pwret;
+       if (pwret == NULL)
+               my_errno = errno;
+       if (!errno)
+               errno = saved_errno;
        _THREAD_PRIVATE_MUTEX_UNLOCK(pw);
-       return (pwret ? 0 : 1);
+       return (my_errno);
 }
 
 struct passwd *
@@ -753,8 +761,12 @@
 {
        struct passwd *pwret = NULL;
        int flags = 0, *flagsp;
+       int my_errno = 0;
+       int saved_errno;
 
        _THREAD_PRIVATE_MUTEX_LOCK(pw);
+       saved_errno = errno;
+       errno = 0;
        if (!_pw_db && !__initdb())
                goto fail;
 
@@ -778,8 +790,12 @@
 fail:
        if (pwretp)
                *pwretp = pwret;
+       if (pwret == NULL)
+               my_errno = errno;
+       if (!errno)
+               errno = saved_errno;
        _THREAD_PRIVATE_MUTEX_UNLOCK(pw);
-       return (pwret ? 0 : 1);
+       return (my_errno);
 }
 
 struct passwd *

Reply via email to