From: Laine Stump <laine@redhat.com>
All the other wrapper functions for glib g_get_user_*_dir() have the
type of directory (the "*" in that wildcarded name) in the libvirt
function name. These functions, on the other hand, call
g_get_home_dir(), but the libvirt API is called
virGetUserDirectory*(). Let's make it *a bit* closer to consistent (at
least the libvirt API names will be consistent with each other, even
if glib isn't).
Signed-off-by: Laine Stump <laine@redhat.com>
---
src/libvirt_private.syms | 4 ++--
src/qemu/qemu_interop_config.c | 2 +-
src/rpc/virnetclient.c | 4 ++--
src/rpc/virnettlsconfig.c | 2 +-
src/util/virutil.c | 10 +++++-----
src/util/virutil.h | 4 ++--
src/vbox/vbox_storage.c | 2 +-
tools/virt-login-shell-helper.c | 2 +-
tools/vsh.c | 2 +-
9 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index b200037189..a2636652ef 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -3723,8 +3723,8 @@ virGetSystemPageSize;
virGetSystemPageSizeKB;
virGetUserCacheDirectory;
virGetUserConfigDirectory;
-virGetUserDirectory;
-virGetUserDirectoryByUID;
+virGetUserHomeDirectory;
+virGetUserHomeDirectoryByUID;
virGetUserID;
virGetUserName;
virGetUserRuntimeDirectory;
diff --git a/src/qemu/qemu_interop_config.c b/src/qemu/qemu_interop_config.c
index 08fb68c901..2280b8a2df 100644
--- a/src/qemu/qemu_interop_config.c
+++ b/src/qemu/qemu_interop_config.c
@@ -105,7 +105,7 @@ qemuInteropFetchConfigs(const char *name,
xdgConfig = g_strdup(getenv("XDG_CONFIG_HOME"));
if (!xdgConfig) {
- g_autofree char *home = virGetUserDirectory();
+ g_autofree char *home = virGetUserHomeDirectory();
xdgConfig = g_strdup_printf("%s/.config", home);
}
diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c
index ee729d5e62..3ad4655e6e 100644
--- a/src/rpc/virnetclient.c
+++ b/src/rpc/virnetclient.c
@@ -539,7 +539,7 @@ virNetClient *virNetClientNewLibSSH2(const char *host,
if (privkeyPath) {
privkey = g_strdup(privkeyPath);
} else {
- homedir = virGetUserDirectory();
+ homedir = virGetUserHomeDirectory();
if (virNetClientFindDefaultSshKey(homedir, &privkey) < 0)
return NULL;
}
@@ -604,7 +604,7 @@ virNetClient *virNetClientNewLibssh(const char *host,
if (privkeyPath) {
privkey = g_strdup(privkeyPath);
} else {
- homedir = virGetUserDirectory();
+ homedir = virGetUserHomeDirectory();
if (virNetClientFindDefaultSshKey(homedir, &privkey) < 0)
return NULL;
}
diff --git a/src/rpc/virnettlsconfig.c b/src/rpc/virnettlsconfig.c
index eec20cf6b7..6ad7a02779 100644
--- a/src/rpc/virnettlsconfig.c
+++ b/src/rpc/virnettlsconfig.c
@@ -36,7 +36,7 @@ VIR_LOG_INIT("rpc.nettlsconfig");
char *virNetTLSConfigUserPKIBaseDir(void)
{
- g_autofree char *userdir = virGetUserDirectory();
+ g_autofree char *userdir = virGetUserHomeDirectory();
return g_strdup_printf("%s/.pki/libvirt", userdir);
}
diff --git a/src/util/virutil.c b/src/util/virutil.c
index fb64237692..3c0d04c3d7 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -589,7 +589,7 @@ virGetHostnameQuiet(void)
char *
-virGetUserDirectory(void)
+virGetUserHomeDirectory(void)
{
return g_strdup(g_get_home_dir());
}
@@ -753,7 +753,7 @@ static char *virGetGroupEnt(gid_t gid)
char *
-virGetUserDirectoryByUID(uid_t uid)
+virGetUserHomeDirectoryByUID(uid_t uid)
{
char *ret;
virGetUserEnt(uid, NULL, NULL, &ret, NULL, false);
@@ -1091,7 +1091,7 @@ virDoesGroupExist(const char *name G_GNUC_UNUSED)
# ifdef WIN32
char *
-virGetUserDirectoryByUID(uid_t uid G_GNUC_UNUSED)
+virGetUserHomeDirectoryByUID(uid_t uid G_GNUC_UNUSED)
{
/* Since Windows lacks setuid binaries, and since we already fake
* geteuid(), we can safely assume that this is only called when
@@ -1111,10 +1111,10 @@ virGetUserShell(uid_t uid G_GNUC_UNUSED)
# else /* !WITH_GETPWUID_R && !WIN32 */
char *
-virGetUserDirectoryByUID(uid_t uid G_GNUC_UNUSED)
+virGetUserHomeDirectoryByUID(uid_t uid G_GNUC_UNUSED)
{
virReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("virGetUserDirectory is not available"));
+ "%s", _("virGetUserHomeDirectory is not available"));
return NULL;
}
diff --git a/src/util/virutil.h b/src/util/virutil.h
index 7e1705e7ce..2accb5777d 100644
--- a/src/util/virutil.h
+++ b/src/util/virutil.h
@@ -95,8 +95,8 @@ static inline int pthread_sigmask(int how,
char *virGetHostname(void) ATTRIBUTE_MOCKABLE;
char *virGetHostnameQuiet(void);
-char *virGetUserDirectory(void);
-char *virGetUserDirectoryByUID(uid_t uid);
+char *virGetUserHomeDirectory(void);
+char *virGetUserHomeDirectoryByUID(uid_t uid);
char *virGetUserConfigDirectory(void);
char *virGetUserCacheDirectory(void);
char *virGetUserRuntimeDirectory(void) ATTRIBUTE_MOCKABLE;
diff --git a/src/vbox/vbox_storage.c b/src/vbox/vbox_storage.c
index 56be618fb8..72c67d2143 100644
--- a/src/vbox/vbox_storage.c
+++ b/src/vbox/vbox_storage.c
@@ -445,7 +445,7 @@ vboxStorageVolCreateXML(virStoragePoolPtr pool,
/* If target.path isn't given, use default path ~/.VirtualBox/image_name */
if (!def->target.path) {
- homedir = virGetUserDirectory();
+ homedir = virGetUserHomeDirectory();
def->target.path = g_strdup_printf("%s/.VirtualBox/%s", homedir, def->name);
}
VBOX_UTF8_TO_UTF16(def->target.path, &hddNameUtf16);
diff --git a/tools/virt-login-shell-helper.c b/tools/virt-login-shell-helper.c
index cb59b5dec0..a1c68a1afa 100644
--- a/tools/virt-login-shell-helper.c
+++ b/tools/virt-login-shell-helper.c
@@ -253,7 +253,7 @@ main(int argc, char **argv)
if (!name)
goto cleanup;
- homedir = virGetUserDirectoryByUID(uid);
+ homedir = virGetUserHomeDirectoryByUID(uid);
if (!homedir)
goto cleanup;
diff --git a/tools/vsh.c b/tools/vsh.c
index 69d3930e43..18914cc818 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -3333,7 +3333,7 @@ cmdCd(vshControl *ctl, const vshCmd *cmd)
g_autofree char *dir_malloced = NULL;
if (vshCommandOptStringQuiet(ctl, cmd, "dir", &dir) <= 0)
- dir = dir_malloced = virGetUserDirectory();
+ dir = dir_malloced = virGetUserHomeDirectory();
if (!dir)
dir = "/";
--
2.52.0
On 2/24/26 09:22, Laine Stump via Devel wrote:
> From: Laine Stump <laine@redhat.com>
>
> All the other wrapper functions for glib g_get_user_*_dir() have the
> type of directory (the "*" in that wildcarded name) in the libvirt
> function name. These functions, on the other hand, call
> g_get_home_dir(), but the libvirt API is called
> virGetUserDirectory*(). Let's make it *a bit* closer to consistent (at
> least the libvirt API names will be consistent with each other, even
> if glib isn't).
>
> Signed-off-by: Laine Stump <laine@redhat.com>
> ---
> src/libvirt_private.syms | 4 ++--
> src/qemu/qemu_interop_config.c | 2 +-
> src/rpc/virnetclient.c | 4 ++--
> src/rpc/virnettlsconfig.c | 2 +-
> src/util/virutil.c | 10 +++++-----
> src/util/virutil.h | 4 ++--
> src/vbox/vbox_storage.c | 2 +-
> tools/virt-login-shell-helper.c | 2 +-
> tools/vsh.c | 2 +-
> 9 files changed, 16 insertions(+), 16 deletions(-)
>
> diff --git a/src/util/virutil.c b/src/util/virutil.c
> index fb64237692..3c0d04c3d7 100644
> --- a/src/util/virutil.c
> +++ b/src/util/virutil.c
> @@ -589,7 +589,7 @@ virGetHostnameQuiet(void)
>
>
> char *
> -virGetUserDirectory(void)
> +virGetUserHomeDirectory(void)
> {
> return g_strdup(g_get_home_dir());
> }
> @@ -753,7 +753,7 @@ static char *virGetGroupEnt(gid_t gid)
>
>
> char *
> -virGetUserDirectoryByUID(uid_t uid)
> +virGetUserHomeDirectoryByUID(uid_t uid)
> {
> char *ret;
> virGetUserEnt(uid, NULL, NULL, &ret, NULL, false);
> @@ -1091,7 +1091,7 @@ virDoesGroupExist(const char *name G_GNUC_UNUSED)
>
> # ifdef WIN32
> char *
> -virGetUserDirectoryByUID(uid_t uid G_GNUC_UNUSED)
> +virGetUserHomeDirectoryByUID(uid_t uid G_GNUC_UNUSED)
> {
> /* Since Windows lacks setuid binaries, and since we already fake
> * geteuid(), we can safely assume that this is only called when
> @@ -1111,10 +1111,10 @@ virGetUserShell(uid_t uid G_GNUC_UNUSED)
>
> # else /* !WITH_GETPWUID_R && !WIN32 */
> char *
> -virGetUserDirectoryByUID(uid_t uid G_GNUC_UNUSED)
> +virGetUserHomeDirectoryByUID(uid_t uid G_GNUC_UNUSED)
> {
> virReportError(VIR_ERR_INTERNAL_ERROR,
> - "%s", _("virGetUserDirectory is not available"));
> + "%s", _("virGetUserHomeDirectory is not available"));
I think this should be either full function name, or an error message
not containing the function name at all (e.g. "getting home directory is
not available"). Partial function name is misleading IMO.
>
> return NULL;
> }
Michal
© 2016 - 2026 Red Hat, Inc.