]> 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>
Fri, 19 Jul 2013 23:14:34 +0000 (17:14 -0600)
commit3a2d5e7e70eb93be43d244268679bbb1e4ccf795
treebb749772cdd107ba6a5f47f80414e363f45ab9dd
parentb5ed23b7d12174ebf326a6c37002e4d4e75994ef
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/virutil.c