[PATCH v2 4/4] util: Rewrite virGetUserRuntimeDirectory() using g_get_user_runtime_dir()

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

 



Signed-off-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx>
---
 src/util/virutil.c | 35 ++++++-----------------------------
 1 file changed, 6 insertions(+), 29 deletions(-)

diff --git a/src/util/virutil.c b/src/util/virutil.c
index 9485316e05..10bf96f193 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -598,6 +598,12 @@ char *virGetUserCacheDirectory(void)
 }
 
 
+char *virGetUserRuntimeDirectory(void)
+{
+    return g_strdup_printf("%s/libvirt", g_get_user_runtime_dir());
+}
+
+
 #ifdef HAVE_GETPWUID_R
 /* Look up fields from the user database for the given user.  On
  * error, set errno, report the error if not instructed otherwise via @quiet,
@@ -748,20 +754,6 @@ char *virGetUserShell(uid_t uid)
 }
 
 
-char *virGetUserRuntimeDirectory(void)
-{
-    const char *path = getenv("XDG_RUNTIME_DIR");
-
-    if (!path || !path[0]) {
-        return virGetUserCacheDirectory();
-    } else {
-        char *ret;
-
-        ret = g_strdup_printf("%s/libvirt", path);
-        return ret;
-    }
-}
-
 char *virGetUserName(uid_t uid)
 {
     char *ret;
@@ -1171,12 +1163,6 @@ virGetUserShell(uid_t uid G_GNUC_UNUSED)
     return NULL;
 }
 
-char *
-virGetUserRuntimeDirectory(void)
-{
-    return virGetUserCacheDirectory();
-}
-
 # else /* !HAVE_GETPWUID_R && !WIN32 */
 char *
 virGetUserDirectoryByUID(uid_t uid G_GNUC_UNUSED)
@@ -1195,15 +1181,6 @@ virGetUserShell(uid_t uid G_GNUC_UNUSED)
 
     return NULL;
 }
-
-char *
-virGetUserRuntimeDirectory(void)
-{
-    virReportError(VIR_ERR_INTERNAL_ERROR,
-                   "%s", _("virGetUserRuntimeDirectory is not available"));
-
-    return NULL;
-}
 # endif /* ! HAVE_GETPWUID_R && ! WIN32 */
 
 char *
-- 
2.23.0

--
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]

  Powered by Linux