Signed-off-by: Fabiano FidĂȘncio <fidencio(a)redhat.com>
---
src/util/virutil.c | 40 +++++++++++-----------------------------
1 file changed, 11 insertions(+), 29 deletions(-)
diff --git a/src/util/virutil.c b/src/util/virutil.c
index 993a959555..62cb3390f8 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -614,6 +614,17 @@ char *virGetUserCacheDirectory(void)
}
+char *virGetUserRuntimeDirectory(void)
+{
+ const char *runtimedir = g_get_user_runtime_dir();
+
+ if (!runtimedir)
+ return NULL;
+
+ return g_strdup_printf("%s/libvirt", runtimedir);
+}
+
+
#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,
@@ -764,20 +775,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;
@@ -1187,12 +1184,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)
@@ -1211,15 +1202,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