From owner-svn-src-head@freebsd.org Fri Jul 27 18:57:58 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 782AC1053CCC for ; Fri, 27 Jul 2018 18:57:58 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from outbound1b.ore.mailhop.org (outbound1b.ore.mailhop.org [54.200.247.200]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0167B82EF3 for ; Fri, 27 Jul 2018 18:57:57 +0000 (UTC) (envelope-from ian@freebsd.org) X-MHO-RoutePath: aGlwcGll X-MHO-User: f8442ad9-91ce-11e8-93fa-f3ebd9db2b94 X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Originating-IP: 67.177.211.60 X-Mail-Handler: DuoCircle Outbound SMTP Received: from ilsoft.org (unknown [67.177.211.60]) by outbound1.ore.mailhop.org (Halon) with ESMTPSA id f8442ad9-91ce-11e8-93fa-f3ebd9db2b94; Fri, 27 Jul 2018 18:57:55 +0000 (UTC) Received: from rev (rev [172.22.42.240]) by ilsoft.org (8.15.2/8.15.2) with ESMTP id w6RIvsZd024615; Fri, 27 Jul 2018 12:57:54 -0600 (MDT) (envelope-from ian@freebsd.org) Message-ID: <1532717874.61594.79.camel@freebsd.org> Subject: Re: svn commit: r336746 - in head/lib: libc/gen libutil From: Ian Lepore To: Konstantin Belousov Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Date: Fri, 27 Jul 2018 12:57:54 -0600 In-Reply-To: <20180727164437.GC2489@kib.kiev.ua> References: <201807261834.w6QIYc9i080738@repo.freebsd.org> <20180727150304.GA2489@kib.kiev.ua> <1532705741.61594.53.camel@freebsd.org> <20180727154359.GB2489@kib.kiev.ua> <1532707631.61594.66.camel@freebsd.org> <20180727164437.GC2489@kib.kiev.ua> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.18.5.1 FreeBSD GNOME Team Port Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Jul 2018 18:57:58 -0000 On Fri, 2018-07-27 at 19:44 +0300, Konstantin Belousov wrote: > On Fri, Jul 27, 2018 at 10:07:11AM -0600, Ian Lepore wrote: > > > > I believe pw_scan() was originally a static function in libc used by > > getpwent() and related functions. When libutil grew some pw utilties, > > it looks like the static pw_scan was renamed to __pw_scan and added to > > the private list, so that it could be shared with libutil (and so I > > copied that process with pw_init(), but I had to rename it to > > pw_initpwd because libutil already has a pw_init()). > > > > I'm not sure how to make the functions more generic, pw_scan() parses a > > line of text in passwd(5) format, optionally warns about errors, and > > fills in a struct passwd with what it finds. pw_initpwd() inits a > > struct passwd to (well-)known default values. But libutil pw_scan() > > allocates the struct and requires the caller to free it, and the > > internal __pw_scan() fills in a struct passed in to it and returns an > > int, so there's no way to re-unify the functions under a single name. > I did not asked to make it more generic.  I mean, if the function is > exported, its interface should be useful enough for generic consumers. > If the current interface is fine, so be it, but see below. > > > > > > > It would be strange to me to have one or two of the pw_xxxx() family of > > functions in libc and the rest of them in libutil. Libutil seems like a > > fine place for password/group file utilities that go beyond the posix > > functions. It's just an implementation detail that we'd prefer to share > > the source code for a small bit of common functionality around parsing > > lines of passwd file data. > Would it be a solution to stop exporting these functions at all, and > just sompile them twice, once in libc, and second time in libutil ? > libutil would add a source file from libc into it SRCS. Yes, this is exactly what I think we should do after your description of how FBSDprivate_1.0 exists specifically to solve some interactions between rtld, libc, and libthr. This is what I meant when I said in one of the earlier emails: > I also noticed that chpass(1) and pwd_mkdb(8)_both directly compile in > their own copy of the pw_scan.c source using .PATH in their makefiles. > I wonder if doing that as the way of sharing the code between libc and > libutil would be a better thing to do? (And presumably that would > remove the need to have entries in the FBSDprivate_1.0 list?) So if we do that, are there any special considerations about removing the __pw_scan entry (and now __pw_initpwd as well) from the private list? Or can they just be deleted without needing to do anything else? Does anything need to be done to make the __pw_scan symbol not directly visible for linking to resolve external references? -- Ian