]> git.ipfire.org Git - thirdparty/libvirt.git/commit
util: improve user lookup helper
authorEric Blake <eblake@redhat.com>
Tue, 9 Jul 2013 23:57:48 +0000 (17:57 -0600)
committerEric Blake <eblake@redhat.com>
Thu, 11 Jul 2013 21:12:56 +0000 (15:12 -0600)
commitc1983ba4e3902308054e961fcae75cece73ef4ba
tree01088f6cd5fe52fa181f75ee7929fd42285aea00
parenta5fcea5513bfcaef979d24b9410181bbb82f50a6
util: improve user lookup helper

A future patch needs to look up pw_gid; but it is wasteful
to crawl through getpwuid_r twice for two separate pieces
of information, and annoying to copy that much boilerplate
code for doing the crawl.  The current internal-only
virGetUserEnt is also a rather awkward interface; it's easier
to just design it to let callers request multiple pieces of
data as needed from one traversal.

And while at it, I noticed that virGetXDGDirectory could deref
NULL if the getpwuid_r lookup fails.

* src/util/virutil.c (virGetUserEnt): Alter signature.
(virGetUserDirectory, virGetXDGDirectory, virGetUserName): Adjust
callers.

Signed-off-by: Eric Blake <eblake@redhat.com>
src/util/virutil.c