[PATCH 1/2] Add virGetUserDirectoryByUID to retrieve users homedir based on UID.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Dan Walsh <dwalsh@xxxxxxxxxx>

This function is needed for virt-login-shell.  Also modify virGirUserDirectory
to use the new function, to simplify the code.
---
 src/libvirt_private.syms | 1 +
 src/util/virutil.c       | 9 +++++++--
 src/util/virutil.h       | 1 +
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index d9615ea..201b2cb 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2044,6 +2044,7 @@ virGetUnprivSGIOSysfsPath;
 virGetUserCacheDirectory;
 virGetUserConfigDirectory;
 virGetUserDirectory;
+virGetUserDirectoryByUID;
 virGetUserID;
 virGetUserName;
 virGetUserRuntimeDirectory;
diff --git a/src/util/virutil.c b/src/util/virutil.c
index adcdb3c..99812ca 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -750,13 +750,18 @@ static char *virGetGroupEnt(gid_t gid)
     return ret;
 }
 
-char *virGetUserDirectory(void)
+char *virGetUserDirectoryByUID(uid_t uid)
 {
     char *ret;
-    virGetUserEnt(geteuid(), NULL, NULL, &ret);
+    virGetUserEnt(uid, NULL, NULL, &ret);
     return ret;
 }
 
+char *virGetUserDirectory(void)
+{
+    return virGetUserDirectoryByUID(geteuid());
+}
+
 static char *virGetXDGDirectory(const char *xdgenvname, const char *xdgdefdir)
 {
     const char *path = getenv(xdgenvname);
diff --git a/src/util/virutil.h b/src/util/virutil.h
index 526c610..4b06992 100644
--- a/src/util/virutil.h
+++ b/src/util/virutil.h
@@ -111,6 +111,7 @@ static inline int getgid (void) { return 0; }
 char *virGetHostname(void);
 
 char *virGetUserDirectory(void);
+char *virGetUserDirectoryByUID(uid_t uid);
 char *virGetUserConfigDirectory(void);
 char *virGetUserCacheDirectory(void);
 char *virGetUserRuntimeDirectory(void);
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]