Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/rpc/virnetclient.c | 12 ++++++------
src/rpc/virnetlibsshsession.c | 8 ++++----
src/rpc/virnetsocket.c | 2 +-
src/rpc/virnetsshsession.c | 11 ++++++-----
src/rpc/virnettlscontext.c | 26 +++++++++++++-------------
5 files changed, 30 insertions(+), 29 deletions(-)
diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c
index a423f4db2f..47a17d30f7 100644
--- a/src/rpc/virnetclient.c
+++ b/src/rpc/virnetclient.c
@@ -343,7 +343,7 @@ virNetClientCheckKeyExists(const char *homedir,
{
char *path;
- virAsprintf(&path, "%s/.ssh/%s", homedir, name);
+ path = g_strdup_printf("%s/.ssh/%s", homedir, name);
if (!(virFileExists(path))) {
VIR_FREE(path);
@@ -565,7 +565,7 @@ virNetClientPtr virNetClientNewLibssh(const char *host,
} else {
confdir = virGetUserConfigDirectory();
if (confdir)
- virAsprintf(&knownhosts, "%s/known_hosts", confdir);
+ knownhosts = g_strdup_printf("%s/known_hosts", confdir);
}
if (privkeyPath) {
@@ -599,10 +599,10 @@ virNetClientPtr virNetClientNewLibssh(const char *host,
if (!(nc = virBufferContentAndReset(&buf)))
goto no_memory;
- virAsprintf(&command, "sh -c "
- "'if '%s' -q 2>&1 | grep \"requires an
argument\" >/dev/null 2>&1; then "
- "ARG=-q0;" "else " "ARG=;" "fi;"
"'%s' $ARG -U %s'", nc, nc,
- socketPath);
+ command = g_strdup_printf("sh -c "
+ "'if '%s' -q 2>&1 | grep
\"requires an argument\" >/dev/null 2>&1; then "
+ "ARG=-q0;" "else " "ARG=;"
"fi;" "'%s' $ARG -U %s'", nc, nc,
+ socketPath);
if (virNetSocketNewConnectLibssh(host, port,
family,
diff --git a/src/rpc/virnetlibsshsession.c b/src/rpc/virnetlibsshsession.c
index 4a9f976914..2fcc606993 100644
--- a/src/rpc/virnetlibsshsession.c
+++ b/src/rpc/virnetlibsshsession.c
@@ -341,9 +341,9 @@ virNetLibsshCheckHostKey(virNetLibsshSessionPtr sess)
if (!keyhashstr)
return -1;
- virAsprintf(&tmp,
- _("Accept SSH host key with hash '%s' for "
"host '%s:%d' (%s/%s)?"),
- keyhashstr, sess->hostname, sess->port, "y",
"n");
+ tmp = g_strdup_printf(
+ _("Accept SSH host key with hash '%s' for
" "host '%s:%d' (%s/%s)?"),
+ keyhashstr, sess->hostname, sess->port,
"y", "n");
askKey.prompt = tmp;
if (sess->cred->cb(&askKey, 1, sess->cred->cbdata)) {
@@ -524,7 +524,7 @@ virNetLibsshAuthenticatePrivkey(virNetLibsshSessionPtr sess,
VIR_DEBUG("sess=%p", sess);
- virAsprintf(&tmp, "%s.pub", priv->filename);
+ tmp = g_strdup_printf("%s.pub", priv->filename);
/* try to open the public part of the private key */
ret = ssh_pki_import_pubkey_file(tmp, &public_key);
diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c
index 2b66bc609b..f2623c58ef 100644
--- a/src/rpc/virnetsocket.c
+++ b/src/rpc/virnetsocket.c
@@ -698,7 +698,7 @@ int virNetSocketNewConnectUNIX(const char *path,
goto cleanup;
}
- virAsprintf(&lockpath, "%s/%s.lock", rundir, binname);
+ lockpath = g_strdup_printf("%s/%s.lock", rundir, binname);
if ((lockfd = open(lockpath, O_RDWR | O_CREAT, 0600)) < 0 ||
virSetCloseExec(lockfd) < 0) {
diff --git a/src/rpc/virnetsshsession.c b/src/rpc/virnetsshsession.c
index 384bedfc34..5b87581b62 100644
--- a/src/rpc/virnetsshsession.c
+++ b/src/rpc/virnetsshsession.c
@@ -365,9 +365,10 @@ virNetSSHCheckHostKey(virNetSSHSessionPtr sess)
keyhashstr = virBufferContentAndReset(&buff);
askKey.type = VIR_CRED_ECHOPROMPT;
- virAsprintf((char **)&askKey.prompt,
- _("Accept SSH host key with hash '%s' for "
"host '%s:%d' (%s/%s)?"),
- keyhashstr, sess->hostname, sess->port, "y",
"n");
+ askKey.prompt = g_strdup_printf(_("Accept SSH host key with hash
'%s' for " "host '%s:%d' (%s/%s)?"),
+ keyhashstr,
+ sess->hostname,
+ sess->port, "y",
"n");
if (sess->cred->cb(&askKey, 1, sess->cred->cbdata)) {
virReportError(VIR_ERR_SSH, "%s",
@@ -628,8 +629,8 @@ virNetSSHAuthenticatePrivkey(virNetSSHSessionPtr sess,
return -1;
}
- virAsprintf((char **)&retr_passphrase.prompt,
- _("Passphrase for key '%s'"), priv->filename);
+ retr_passphrase.prompt = g_strdup_printf(_("Passphrase for key
'%s'"),
+ priv->filename);
if (sess->cred->cb(&retr_passphrase, 1, sess->cred->cbdata)) {
virReportError(VIR_ERR_SSH, "%s",
diff --git a/src/rpc/virnettlscontext.c b/src/rpc/virnettlscontext.c
index af6d29b376..7163775f74 100644
--- a/src/rpc/virnettlscontext.c
+++ b/src/rpc/virnettlscontext.c
@@ -796,13 +796,13 @@ static int virNetTLSContextLocateCredentials(const char *pkipath,
*/
if (pkipath) {
VIR_DEBUG("Told to use TLS credentials in %s", pkipath);
- virAsprintf(cacert, "%s/%s", pkipath, "cacert.pem");
- virAsprintf(cacrl, "%s/%s", pkipath, "cacrl.pem");
- virAsprintf(key, "%s/%s", pkipath,
- isServer ? "serverkey.pem" : "clientkey.pem");
+ *cacert = g_strdup_printf("%s/%s", pkipath, "cacert.pem");
+ *cacrl = g_strdup_printf("%s/%s", pkipath, "cacrl.pem");
+ *key = g_strdup_printf("%s/%s", pkipath,
+ isServer ? "serverkey.pem" :
"clientkey.pem");
- virAsprintf(cert, "%s/%s", pkipath,
- isServer ? "servercert.pem" : "clientcert.pem");
+ *cert = g_strdup_printf("%s/%s", pkipath,
+ isServer ? "servercert.pem" :
"clientcert.pem");
} else if (tryUserPkiPath) {
/* Check to see if $HOME/.pki contains at least one of the
* files and if so, use that
@@ -812,19 +812,19 @@ static int virNetTLSContextLocateCredentials(const char *pkipath,
if (!userdir)
goto error;
- virAsprintf(&user_pki_path, "%s/.pki/libvirt", userdir);
+ user_pki_path = g_strdup_printf("%s/.pki/libvirt", userdir);
VIR_DEBUG("Trying to find TLS user credentials in %s", user_pki_path);
- virAsprintf(cacert, "%s/%s", user_pki_path, "cacert.pem");
+ *cacert = g_strdup_printf("%s/%s", user_pki_path,
"cacert.pem");
- virAsprintf(cacrl, "%s/%s", user_pki_path, "cacrl.pem");
+ *cacrl = g_strdup_printf("%s/%s", user_pki_path,
"cacrl.pem");
- virAsprintf(key, "%s/%s", user_pki_path,
- isServer ? "serverkey.pem" : "clientkey.pem");
+ *key = g_strdup_printf("%s/%s", user_pki_path,
+ isServer ? "serverkey.pem" :
"clientkey.pem");
- virAsprintf(cert, "%s/%s", user_pki_path,
- isServer ? "servercert.pem" : "clientcert.pem");
+ *cert = g_strdup_printf("%s/%s", user_pki_path,
+ isServer ? "servercert.pem" :
"clientcert.pem");
/*
* If some of the files can't be found, fallback
--
2.21.0