From owner-svn-src-head@freebsd.org Fri Jul 27 16:44:47 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 17B7E10506A1; Fri, 27 Jul 2018 16:44:47 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (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 711867D22D; Fri, 27 Jul 2018 16:44:46 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id w6RGichx030741 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 27 Jul 2018 19:44:41 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua w6RGichx030741 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id w6RGibPM030740; Fri, 27 Jul 2018 19:44:37 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Fri, 27 Jul 2018 19:44:37 +0300 From: Konstantin Belousov To: Ian Lepore Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r336746 - in head/lib: libc/gen libutil Message-ID: <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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1532707631.61594.66.camel@freebsd.org> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home 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 16:44:47 -0000 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.