mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
rpc: use g_strdup instead of VIR_STRDUP
Replace all occurrences of if (VIR_STRDUP(a, b) < 0) /* effectively dead code */ with: a = g_strdup(b); Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
b2d079c113
commit
45bf10ba1d
@ -773,10 +773,9 @@ elsif ($mode eq "server") {
|
|||||||
# SPECIAL: virConnectGetType returns a constant string that must
|
# SPECIAL: virConnectGetType returns a constant string that must
|
||||||
# not be freed. Therefore, duplicate the string here.
|
# not be freed. Therefore, duplicate the string here.
|
||||||
push(@vars_list, "const char *$1");
|
push(@vars_list, "const char *$1");
|
||||||
push(@ret_list, "/* We have to VIR_STRDUP because remoteDispatchClientRequest will");
|
push(@ret_list, "/* We have to g_strdup because remoteDispatchClientRequest will");
|
||||||
push(@ret_list, " * free this string after it's been serialised. */");
|
push(@ret_list, " * free this string after it's been serialised. */");
|
||||||
push(@ret_list, "if (VIR_STRDUP(ret->type, type) < 0)");
|
push(@ret_list, "ret->type = g_strdup(type);");
|
||||||
push(@ret_list, " goto cleanup;");
|
|
||||||
} else {
|
} else {
|
||||||
push(@vars_list, "char *$1");
|
push(@vars_list, "char *$1");
|
||||||
push(@ret_list, "ret->$1 = $1;");
|
push(@ret_list, "ret->$1 = $1;");
|
||||||
@ -795,8 +794,7 @@ elsif ($mode eq "server") {
|
|||||||
"if (VIR_ALLOC($1_p) < 0)\n" .
|
"if (VIR_ALLOC($1_p) < 0)\n" .
|
||||||
" goto cleanup;\n" .
|
" goto cleanup;\n" .
|
||||||
"\n" .
|
"\n" .
|
||||||
" if (VIR_STRDUP(*$1_p, $1) < 0)\n".
|
" *$1_p = g_strdup($1);\n");
|
||||||
" goto cleanup;\n");
|
|
||||||
|
|
||||||
$single_ret_var = $1;
|
$single_ret_var = $1;
|
||||||
$single_ret_by_ref = 0;
|
$single_ret_by_ref = 0;
|
||||||
@ -1936,17 +1934,11 @@ elsif ($mode eq "client") {
|
|||||||
if ($single_ret_as_list) {
|
if ($single_ret_as_list) {
|
||||||
print " /* This call is caller-frees (although that isn't clear from\n";
|
print " /* This call is caller-frees (although that isn't clear from\n";
|
||||||
print " * the documentation). However xdr_free will free up both the\n";
|
print " * the documentation). However xdr_free will free up both the\n";
|
||||||
print " * names and the list of pointers, so we have to VIR_STRDUP the\n";
|
print " * names and the list of pointers, so we have to g_strdup the\n";
|
||||||
print " * names here. */\n";
|
print " * names here. */\n";
|
||||||
print " for (i = 0; i < ret.$single_ret_list_name.${single_ret_list_name}_len; ++i) {\n";
|
print " for (i = 0; i < ret.$single_ret_list_name.${single_ret_list_name}_len; ++i) {\n";
|
||||||
print " if (VIR_STRDUP(${single_ret_list_name}[i],\n";
|
print " ${single_ret_list_name}[i] = \n";
|
||||||
print " ret.$single_ret_list_name.${single_ret_list_name}_val[i]) < 0) {\n";
|
print " g_strdup(ret.$single_ret_list_name.${single_ret_list_name}_val[i]);\n";
|
||||||
print " size_t j;\n";
|
|
||||||
print " for (j = 0; j < i; j++)\n";
|
|
||||||
print " VIR_FREE(${single_ret_list_name}[j]);\n";
|
|
||||||
print "\n";
|
|
||||||
print " goto cleanup;\n";
|
|
||||||
print " }\n";
|
|
||||||
print " }\n";
|
print " }\n";
|
||||||
print "\n";
|
print "\n";
|
||||||
} elsif ($modern_ret_as_list) {
|
} elsif ($modern_ret_as_list) {
|
||||||
|
@ -316,8 +316,7 @@ static virNetClientPtr virNetClientNew(virNetSocketPtr sock,
|
|||||||
client->wakeupSendFD = wakeupFD[1];
|
client->wakeupSendFD = wakeupFD[1];
|
||||||
wakeupFD[0] = wakeupFD[1] = -1;
|
wakeupFD[0] = wakeupFD[1] = -1;
|
||||||
|
|
||||||
if (VIR_STRDUP(client->hostname, hostname) < 0)
|
client->hostname = g_strdup(hostname);
|
||||||
goto error;
|
|
||||||
|
|
||||||
PROBE(RPC_CLIENT_NEW,
|
PROBE(RPC_CLIENT_NEW,
|
||||||
"client=%p sock=%p",
|
"client=%p sock=%p",
|
||||||
@ -454,8 +453,7 @@ virNetClientPtr virNetClientNewLibSSH2(const char *host,
|
|||||||
|
|
||||||
/* Use default paths for known hosts an public keys if not provided */
|
/* Use default paths for known hosts an public keys if not provided */
|
||||||
if (knownHostsPath) {
|
if (knownHostsPath) {
|
||||||
if (VIR_STRDUP(knownhosts, knownHostsPath) < 0)
|
knownhosts = g_strdup(knownHostsPath);
|
||||||
goto cleanup;
|
|
||||||
} else {
|
} else {
|
||||||
confdir = virGetUserConfigDirectory();
|
confdir = virGetUserConfigDirectory();
|
||||||
if (confdir) {
|
if (confdir) {
|
||||||
@ -466,8 +464,7 @@ virNetClientPtr virNetClientNewLibSSH2(const char *host,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (privkeyPath) {
|
if (privkeyPath) {
|
||||||
if (VIR_STRDUP(privkey, privkeyPath) < 0)
|
privkey = g_strdup(privkeyPath);
|
||||||
goto cleanup;
|
|
||||||
} else {
|
} else {
|
||||||
homedir = virGetUserDirectory();
|
homedir = virGetUserDirectory();
|
||||||
if (homedir) {
|
if (homedir) {
|
||||||
@ -565,8 +562,7 @@ virNetClientPtr virNetClientNewLibssh(const char *host,
|
|||||||
|
|
||||||
/* Use default paths for known hosts an public keys if not provided */
|
/* Use default paths for known hosts an public keys if not provided */
|
||||||
if (knownHostsPath) {
|
if (knownHostsPath) {
|
||||||
if (VIR_STRDUP(knownhosts, knownHostsPath) < 0)
|
knownhosts = g_strdup(knownHostsPath);
|
||||||
goto cleanup;
|
|
||||||
} else {
|
} else {
|
||||||
confdir = virGetUserConfigDirectory();
|
confdir = virGetUserConfigDirectory();
|
||||||
if (confdir) {
|
if (confdir) {
|
||||||
@ -576,8 +572,7 @@ virNetClientPtr virNetClientNewLibssh(const char *host,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (privkeyPath) {
|
if (privkeyPath) {
|
||||||
if (VIR_STRDUP(privkey, privkeyPath) < 0)
|
privkey = g_strdup(privkeyPath);
|
||||||
goto cleanup;
|
|
||||||
} else {
|
} else {
|
||||||
homedir = virGetUserDirectory();
|
homedir = virGetUserDirectory();
|
||||||
if (homedir) {
|
if (homedir) {
|
||||||
|
@ -1052,11 +1052,8 @@ virNetLibsshSessionAuthAddPrivKeyAuth(virNetLibsshSessionPtr sess,
|
|||||||
|
|
||||||
virObjectLock(sess);
|
virObjectLock(sess);
|
||||||
|
|
||||||
if (VIR_STRDUP(file, keyfile) < 0 ||
|
file = g_strdup(keyfile);
|
||||||
VIR_STRDUP(pass, password) < 0) {
|
pass = g_strdup(password);
|
||||||
ret = -1;
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(auth = virNetLibsshSessionAuthMethodNew(sess))) {
|
if (!(auth = virNetLibsshSessionAuthMethodNew(sess))) {
|
||||||
ret = -1;
|
ret = -1;
|
||||||
@ -1114,8 +1111,7 @@ virNetLibsshSessionSetChannelCommand(virNetLibsshSessionPtr sess,
|
|||||||
|
|
||||||
VIR_FREE(sess->channelCommand);
|
VIR_FREE(sess->channelCommand);
|
||||||
|
|
||||||
if (VIR_STRDUP(sess->channelCommand, command) < 0)
|
sess->channelCommand = g_strdup(command);
|
||||||
ret = -1;
|
|
||||||
|
|
||||||
virObjectUnlock(sess);
|
virObjectUnlock(sess);
|
||||||
return ret;
|
return ret;
|
||||||
@ -1135,8 +1131,7 @@ virNetLibsshSessionSetHostKeyVerification(virNetLibsshSessionPtr sess,
|
|||||||
|
|
||||||
VIR_FREE(sess->hostname);
|
VIR_FREE(sess->hostname);
|
||||||
|
|
||||||
if (VIR_STRDUP(sess->hostname, hostname) < 0)
|
sess->hostname = g_strdup(hostname);
|
||||||
goto error;
|
|
||||||
|
|
||||||
/* set the hostname */
|
/* set the hostname */
|
||||||
if (ssh_options_set(sess->session, SSH_OPTIONS_HOST, sess->hostname) < 0)
|
if (ssh_options_set(sess->session, SSH_OPTIONS_HOST, sess->hostname) < 0)
|
||||||
@ -1156,8 +1151,7 @@ virNetLibsshSessionSetHostKeyVerification(virNetLibsshSessionPtr sess,
|
|||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
VIR_FREE(sess->knownHostsFile);
|
VIR_FREE(sess->knownHostsFile);
|
||||||
if (VIR_STRDUP(sess->knownHostsFile, hostsfile) < 0)
|
sess->knownHostsFile = g_strdup(hostsfile);
|
||||||
goto error;
|
|
||||||
} else {
|
} else {
|
||||||
/* libssh does not support trying no known_host file at all:
|
/* libssh does not support trying no known_host file at all:
|
||||||
* hence use /dev/null here, without storing it as file */
|
* hence use /dev/null here, without storing it as file */
|
||||||
@ -1191,8 +1185,7 @@ virNetLibsshSessionPtr virNetLibsshSessionNew(const char *username)
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_STRDUP(sess->username, username) < 0)
|
sess->username = g_strdup(username);
|
||||||
goto error;
|
|
||||||
|
|
||||||
VIR_DEBUG("virNetLibsshSessionPtr: %p, ssh_session: %p",
|
VIR_DEBUG("virNetLibsshSessionPtr: %p, ssh_session: %p",
|
||||||
sess, sess->session);
|
sess, sess->session);
|
||||||
|
@ -523,28 +523,22 @@ void virNetMessageSaveError(virNetMessageErrorPtr rerr)
|
|||||||
if (verr) {
|
if (verr) {
|
||||||
rerr->code = verr->code;
|
rerr->code = verr->code;
|
||||||
rerr->domain = verr->domain;
|
rerr->domain = verr->domain;
|
||||||
if (verr->message && VIR_ALLOC(rerr->message) == 0 &&
|
if (verr->message && VIR_ALLOC(rerr->message) == 0)
|
||||||
VIR_STRDUP_QUIET(*rerr->message, verr->message) < 0)
|
*rerr->message = g_strdup(verr->message);
|
||||||
VIR_FREE(rerr->message);
|
|
||||||
rerr->level = verr->level;
|
rerr->level = verr->level;
|
||||||
if (verr->str1 && VIR_ALLOC(rerr->str1) == 0 &&
|
if (verr->str1 && VIR_ALLOC(rerr->str1) == 0)
|
||||||
VIR_STRDUP_QUIET(*rerr->str1, verr->str1) < 0)
|
*rerr->str1 = g_strdup(verr->str1);
|
||||||
VIR_FREE(rerr->str1);
|
if (verr->str2 && VIR_ALLOC(rerr->str2) == 0)
|
||||||
if (verr->str2 && VIR_ALLOC(rerr->str2) == 0 &&
|
*rerr->str2 = g_strdup(verr->str2);
|
||||||
VIR_STRDUP_QUIET(*rerr->str2, verr->str2) < 0)
|
if (verr->str3 && VIR_ALLOC(rerr->str3) == 0)
|
||||||
VIR_FREE(rerr->str2);
|
*rerr->str3 = g_strdup(verr->str3);
|
||||||
if (verr->str3 && VIR_ALLOC(rerr->str3) == 0 &&
|
|
||||||
VIR_STRDUP_QUIET(*rerr->str3, verr->str3) < 0)
|
|
||||||
VIR_FREE(rerr->str3);
|
|
||||||
rerr->int1 = verr->int1;
|
rerr->int1 = verr->int1;
|
||||||
rerr->int2 = verr->int2;
|
rerr->int2 = verr->int2;
|
||||||
} else {
|
} else {
|
||||||
rerr->code = VIR_ERR_INTERNAL_ERROR;
|
rerr->code = VIR_ERR_INTERNAL_ERROR;
|
||||||
rerr->domain = VIR_FROM_RPC;
|
rerr->domain = VIR_FROM_RPC;
|
||||||
if (VIR_ALLOC_QUIET(rerr->message) == 0 &&
|
if (VIR_ALLOC_QUIET(rerr->message) == 0)
|
||||||
VIR_STRDUP_QUIET(*rerr->message,
|
*rerr->message = g_strdup(_("Library function returned error but did not set virError"));
|
||||||
_("Library function returned error but did not set virError")) < 0)
|
|
||||||
VIR_FREE(rerr->message);
|
|
||||||
rerr->level = VIR_ERR_ERROR;
|
rerr->level = VIR_ERR_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -365,8 +365,7 @@ virNetServerPtr virNetServerNew(const char *name,
|
|||||||
srv)))
|
srv)))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (VIR_STRDUP(srv->name, name) < 0)
|
srv->name = g_strdup(name);
|
||||||
goto error;
|
|
||||||
|
|
||||||
srv->next_client_id = next_client_id;
|
srv->next_client_id = next_client_id;
|
||||||
srv->nclients_max = max_clients;
|
srv->nclients_max = max_clients;
|
||||||
|
@ -1665,8 +1665,7 @@ virNetServerClientGetInfo(virNetServerClientPtr client,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_STRDUP(*sock_addr, addr) < 0)
|
*sock_addr = g_strdup(addr);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (!client->identity) {
|
if (!client->identity) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
|
@ -999,8 +999,7 @@ virNetSocketNewConnectLibSSH2(const char *host,
|
|||||||
if (virNetSSHSessionSetChannelCommand(sess, command) != 0)
|
if (virNetSSHSessionSetChannelCommand(sess, command) != 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (VIR_STRDUP(authMethodsCopy, authMethods) < 0)
|
authMethodsCopy = g_strdup(authMethods);
|
||||||
goto error;
|
|
||||||
|
|
||||||
authMethodNext = authMethodsCopy;
|
authMethodNext = authMethodsCopy;
|
||||||
|
|
||||||
@ -1134,8 +1133,7 @@ virNetSocketNewConnectLibssh(const char *host,
|
|||||||
if (virNetLibsshSessionSetChannelCommand(sess, command) != 0)
|
if (virNetLibsshSessionSetChannelCommand(sess, command) != 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (VIR_STRDUP(authMethodsCopy, authMethods) < 0)
|
authMethodsCopy = g_strdup(authMethods);
|
||||||
goto error;
|
|
||||||
|
|
||||||
authMethodNext = authMethodsCopy;
|
authMethodNext = authMethodsCopy;
|
||||||
|
|
||||||
@ -1635,8 +1633,7 @@ int virNetSocketGetSELinuxContext(virNetSocketPtr sock,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_STRDUP(*context, seccon) < 0)
|
*context = g_strdup(seccon);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
|
@ -232,10 +232,7 @@ virNetSSHKbIntCb(const char *name G_GNUC_UNUSED,
|
|||||||
/* fill data structures for auth callback */
|
/* fill data structures for auth callback */
|
||||||
for (i = 0; i < num_prompts; i++) {
|
for (i = 0; i < num_prompts; i++) {
|
||||||
char *prompt;
|
char *prompt;
|
||||||
if (VIR_STRDUP(prompt, prompts[i].text) < 0) {
|
prompt = g_strdup(prompts[i].text);
|
||||||
priv->authCbErr = VIR_NET_SSH_AUTHCB_OOM;
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
askcred[i].prompt = prompt;
|
askcred[i].prompt = prompt;
|
||||||
|
|
||||||
/* remove colon and trailing spaces from prompts, as default behavior
|
/* remove colon and trailing spaces from prompts, as default behavior
|
||||||
@ -1018,8 +1015,7 @@ virNetSSHSessionAuthAddPasswordAuth(virNetSSHSessionPtr sess,
|
|||||||
"ssh", NULL, sess->hostname)))
|
"ssh", NULL, sess->hostname)))
|
||||||
goto error;
|
goto error;
|
||||||
} else {
|
} else {
|
||||||
if (VIR_STRDUP(user, username) < 0)
|
user = g_strdup(username);
|
||||||
goto error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virObjectLock(sess);
|
virObjectLock(sess);
|
||||||
@ -1055,8 +1051,7 @@ virNetSSHSessionAuthAddAgentAuth(virNetSSHSessionPtr sess,
|
|||||||
|
|
||||||
virObjectLock(sess);
|
virObjectLock(sess);
|
||||||
|
|
||||||
if (VIR_STRDUP(user, username) < 0)
|
user = g_strdup(username);
|
||||||
goto error;
|
|
||||||
|
|
||||||
if (!(auth = virNetSSHSessionAuthMethodNew(sess)))
|
if (!(auth = virNetSSHSessionAuthMethodNew(sess)))
|
||||||
goto error;
|
goto error;
|
||||||
@ -1094,10 +1089,9 @@ virNetSSHSessionAuthAddPrivKeyAuth(virNetSSHSessionPtr sess,
|
|||||||
|
|
||||||
virObjectLock(sess);
|
virObjectLock(sess);
|
||||||
|
|
||||||
if (VIR_STRDUP(user, username) < 0 ||
|
user = g_strdup(username);
|
||||||
VIR_STRDUP(file, keyfile) < 0 ||
|
file = g_strdup(keyfile);
|
||||||
VIR_STRDUP(pass, password) < 0)
|
pass = g_strdup(password);
|
||||||
goto error;
|
|
||||||
|
|
||||||
if (!(auth = virNetSSHSessionAuthMethodNew(sess)))
|
if (!(auth = virNetSSHSessionAuthMethodNew(sess)))
|
||||||
goto error;
|
goto error;
|
||||||
@ -1135,8 +1129,7 @@ virNetSSHSessionAuthAddKeyboardAuth(virNetSSHSessionPtr sess,
|
|||||||
|
|
||||||
virObjectLock(sess);
|
virObjectLock(sess);
|
||||||
|
|
||||||
if (VIR_STRDUP(user, username) < 0)
|
user = g_strdup(username);
|
||||||
goto error;
|
|
||||||
|
|
||||||
if (!(auth = virNetSSHSessionAuthMethodNew(sess)))
|
if (!(auth = virNetSSHSessionAuthMethodNew(sess)))
|
||||||
goto error;
|
goto error;
|
||||||
@ -1164,8 +1157,7 @@ virNetSSHSessionSetChannelCommand(virNetSSHSessionPtr sess,
|
|||||||
|
|
||||||
VIR_FREE(sess->channelCommand);
|
VIR_FREE(sess->channelCommand);
|
||||||
|
|
||||||
if (VIR_STRDUP(sess->channelCommand, command) < 0)
|
sess->channelCommand = g_strdup(command);
|
||||||
ret = -1;
|
|
||||||
|
|
||||||
virObjectUnlock(sess);
|
virObjectUnlock(sess);
|
||||||
return ret;
|
return ret;
|
||||||
@ -1188,8 +1180,7 @@ virNetSSHSessionSetHostKeyVerification(virNetSSHSessionPtr sess,
|
|||||||
|
|
||||||
VIR_FREE(sess->hostname);
|
VIR_FREE(sess->hostname);
|
||||||
|
|
||||||
if (VIR_STRDUP(sess->hostname, hostname) < 0)
|
sess->hostname = g_strdup(hostname);
|
||||||
goto error;
|
|
||||||
|
|
||||||
/* load the known hosts file */
|
/* load the known hosts file */
|
||||||
if (hostsfile) {
|
if (hostsfile) {
|
||||||
@ -1213,8 +1204,7 @@ virNetSSHSessionSetHostKeyVerification(virNetSSHSessionPtr sess,
|
|||||||
/* set filename only if writing to the known hosts file is requested */
|
/* set filename only if writing to the known hosts file is requested */
|
||||||
if (!(flags & VIR_NET_SSH_HOSTKEY_FILE_READONLY)) {
|
if (!(flags & VIR_NET_SSH_HOSTKEY_FILE_READONLY)) {
|
||||||
VIR_FREE(sess->knownHostsFile);
|
VIR_FREE(sess->knownHostsFile);
|
||||||
if (VIR_STRDUP(sess->knownHostsFile, hostsfile) < 0)
|
sess->knownHostsFile = g_strdup(hostsfile);
|
||||||
goto error;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -702,8 +702,7 @@ static virNetTLSContextPtr virNetTLSContextNew(const char *cacert,
|
|||||||
if (!(ctxt = virObjectLockableNew(virNetTLSContextClass)))
|
if (!(ctxt = virObjectLockableNew(virNetTLSContextClass)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (VIR_STRDUP(ctxt->priority, priority) < 0)
|
ctxt->priority = g_strdup(priority);
|
||||||
goto error;
|
|
||||||
|
|
||||||
err = gnutls_certificate_allocate_credentials(&ctxt->x509cred);
|
err = gnutls_certificate_allocate_credentials(&ctxt->x509cred);
|
||||||
if (err) {
|
if (err) {
|
||||||
@ -863,23 +862,19 @@ static int virNetTLSContextLocateCredentials(const char *pkipath,
|
|||||||
*/
|
*/
|
||||||
if (!*cacert) {
|
if (!*cacert) {
|
||||||
VIR_DEBUG("Using default TLS CA certificate path");
|
VIR_DEBUG("Using default TLS CA certificate path");
|
||||||
if (VIR_STRDUP(*cacert, LIBVIRT_CACERT) < 0)
|
*cacert = g_strdup(LIBVIRT_CACERT);
|
||||||
goto error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!*cacrl) {
|
if (!*cacrl) {
|
||||||
VIR_DEBUG("Using default TLS CA revocation list path");
|
VIR_DEBUG("Using default TLS CA revocation list path");
|
||||||
if (VIR_STRDUP(*cacrl, LIBVIRT_CACRL) < 0)
|
*cacrl = g_strdup(LIBVIRT_CACRL);
|
||||||
goto error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!*key && !*cert) {
|
if (!*key && !*cert) {
|
||||||
VIR_DEBUG("Using default TLS key/certificate path");
|
VIR_DEBUG("Using default TLS key/certificate path");
|
||||||
if (VIR_STRDUP(*key, isServer ? LIBVIRT_SERVERKEY : LIBVIRT_CLIENTKEY) < 0)
|
*key = g_strdup(isServer ? LIBVIRT_SERVERKEY : LIBVIRT_CLIENTKEY);
|
||||||
goto error;
|
|
||||||
|
|
||||||
if (VIR_STRDUP(*cert, isServer ? LIBVIRT_SERVERCERT : LIBVIRT_CLIENTCERT) < 0)
|
*cert = g_strdup(isServer ? LIBVIRT_SERVERCERT : LIBVIRT_CLIENTCERT);
|
||||||
goto error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VIR_FREE(user_pki_path);
|
VIR_FREE(user_pki_path);
|
||||||
@ -1058,8 +1053,7 @@ static int virNetTLSContextValidCertificate(virNetTLSContextPtr ctxt,
|
|||||||
"[session]", gnutls_strerror(ret));
|
"[session]", gnutls_strerror(ret));
|
||||||
goto authfail;
|
goto authfail;
|
||||||
}
|
}
|
||||||
if (VIR_STRDUP(sess->x509dname, dname) < 0)
|
sess->x509dname = g_strdup(dname);
|
||||||
goto authfail;
|
|
||||||
VIR_DEBUG("Peer DN is %s", dname);
|
VIR_DEBUG("Peer DN is %s", dname);
|
||||||
|
|
||||||
if (virNetTLSContextCheckCertDN(cert, "[session]", sess->hostname, dname,
|
if (virNetTLSContextCheckCertDN(cert, "[session]", sess->hostname, dname,
|
||||||
@ -1195,8 +1189,7 @@ virNetTLSSessionPtr virNetTLSSessionNew(virNetTLSContextPtr ctxt,
|
|||||||
if (!(sess = virObjectLockableNew(virNetTLSSessionClass)))
|
if (!(sess = virObjectLockableNew(virNetTLSSessionClass)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (VIR_STRDUP(sess->hostname, hostname) < 0)
|
sess->hostname = g_strdup(hostname);
|
||||||
goto error;
|
|
||||||
|
|
||||||
if ((err = gnutls_init(&sess->session,
|
if ((err = gnutls_init(&sess->session,
|
||||||
ctxt->isServer ? GNUTLS_SERVER : GNUTLS_CLIENT)) != 0) {
|
ctxt->isServer ? GNUTLS_SERVER : GNUTLS_CLIENT)) != 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user