]> 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>
Mon, 22 Jul 2013 21:37:42 +0000 (15:37 -0600)
commitf46872066149868877eaa31a24a9d69643fd6db3
tree27c26b8d9c2e7fea617b247fbc1c16d710e8a26c
parent27b2639f162aef2184b52f24757387ea346fc77a
util: improve user lookup helper

https://bugzilla.redhat.com/show_bug.cgi?id=964358

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>
(cherry picked from commit c1983ba4e3902308054e961fcae75cece73ef4ba)

Conflicts:
src/util/virutil.c - oom reporting/strdup changes not backported
src/util/util.c