[libvirt] [PATCH 1/2] Remove uid param from directory lookup APIs

Eric Blake eblake at redhat.com
Thu May 24 14:18:55 UTC 2012


On 05/24/2012 07:44 AM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange at redhat.com>
> 
> Remove the uid param from virGetUserConfigDirectory,
> virGetUserCacheDirectory, virGetUserRuntimeDirectory,
> and virGetUserDirectory
> 
> These functions were universally called with the
> results of getuid() or geteuid(). To make it practical
> to port to Win32, remove the uid parameter and hardcode
> geteuid()

Confirmed that we were universally using a current id, and that blindly
using geteuid() is the best approach.

ACK.

> +++ b/src/remote/remote_driver.c
> @@ -578,7 +578,7 @@ doRemoteOpen (virConnectPtr conn,
>      case trans_unix:
>          if (!sockname) {
>              if (flags & VIR_DRV_OPEN_REMOTE_USER) {
> -                char *userdir = virGetUserRuntimeDirectory(getuid());
> +                char *userdir = virGetUserRuntimeDirectory();

There's probably a subtle difference for the effects if getuid() and
geteuid() differed in value if you ever got here while linking to
libvirt.so from a setuid binary, but I think that is unlikely enough and
that our switch to geteuid() feels safer anyways.

-- 
Eric Blake   eblake at redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120524/cf9f4a67/attachment-0001.sig>


More information about the libvir-list mailing list