Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 27 Jul 2018 19:44:37 +0300
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Ian Lepore <ian@freebsd.org>
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>
In-Reply-To: <1532707631.61594.66.camel@freebsd.org>
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>

next in thread | previous in thread | raw e-mail | index | archive | help
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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20180727164437.GC2489>