From owner-freebsd-net Tue Jul 30 11: 8:59 2002 Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 862ED37B400; Tue, 30 Jul 2002 11:08:53 -0700 (PDT) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id DB2B143E65; Tue, 30 Jul 2002 11:08:51 -0700 (PDT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.12.5/8.12.5) id g6UI8pe8056202; Tue, 30 Jul 2002 13:08:51 -0500 (CDT) (envelope-from dan) Date: Tue, 30 Jul 2002 13:08:51 -0500 From: Dan Nelson To: Ruslan Ermilov Cc: current@FreeBSD.ORG, net@FreeBSD.ORG Subject: Re: NIS and getpwent(3) Message-ID: <20020730180851.GC95493@dan.emsphone.com> References: <20020730160931.GA27626@sunbay.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020730160931.GA27626@sunbay.com> X-OS: FreeBSD 5.0-CURRENT X-message-flag: Outlook Error User-Agent: Mutt/1.5.1i Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org In the last episode (Jul 30), Ruslan Ermilov said: > [Sorry for x-posting, not sure where this is more relevant.] > > I have hit the following nasty problem with > /etc/periodic/daily/300.calendar while using NIS. We have our NIS > database distributed with all shells switched off to /sbin/nologin, > and overriding shells as necessary on machines where we need it. > Something like this: > > +ru:::::::::/bin/tcsh > +::::::::: > > The problem is that the "ru" entry is reported by getpwent(3) twice, > first with /bin/tcsh shell, and second with the /sbin/nologin shell. > The net effect is that you get your calendar mail twice. > > Is this the correct behavior of getpwent(3), and then what do we do > with calendar(1), or getpwent(3) is in trouble? (I've checked that > on both 4.x and 5.0.) It looks like the correct behaviour. The nsswitch.conf manpage on FreeBSD actually mentions the possibility of duplication, and I've seen it on BSD, Tru64, Solaris, and Linux. The Solaris manpages for getpwnam and nsswitch.conf say that getpwent+nswwitch is inefficient and is discouraged, but they don't suggest any alternatives. http://docs.sun.com/?q=getpwent&p=/doc/816-0213/6m6ne381v&a=view http://docs.sun.com/?q=getpwent&p=/doc/816-0219/6m6njqbaf&a=view I guess the best solution would be to keep a list of uids that have already been processed by calendar, and ignore duplicates. -- Dan Nelson dnelson@allantgroup.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message