mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-21 19:02:25 +00:00
virNetSSHSessionAuthAddPrivKeyAuth: Refactor cleanup
With g_strdup not failing we can remove all of the 'error' section. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
This commit is contained in:
parent
7f6b632b73
commit
3267ce58cf
@ -1060,9 +1060,6 @@ virNetSSHSessionAuthAddPrivKeyAuth(virNetSSHSession *sess,
|
||||
{
|
||||
virNetSSHAuthMethod *auth;
|
||||
|
||||
char *user = NULL;
|
||||
char *file = NULL;
|
||||
|
||||
if (!username || !keyfile) {
|
||||
virReportError(VIR_ERR_SSH, "%s",
|
||||
_("Username and key file path must be provided "
|
||||
@ -1072,24 +1069,17 @@ virNetSSHSessionAuthAddPrivKeyAuth(virNetSSHSession *sess,
|
||||
|
||||
virObjectLock(sess);
|
||||
|
||||
user = g_strdup(username);
|
||||
file = g_strdup(keyfile);
|
||||
if (!(auth = virNetSSHSessionAuthMethodNew(sess))) {
|
||||
virObjectUnlock(sess);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!(auth = virNetSSHSessionAuthMethodNew(sess)))
|
||||
goto error;
|
||||
|
||||
auth->username = user;
|
||||
auth->filename = file;
|
||||
auth->username = g_strdup(username);
|
||||
auth->filename = g_strdup(keyfile);
|
||||
auth->method = VIR_NET_SSH_AUTH_PRIVKEY;
|
||||
|
||||
virObjectUnlock(sess);
|
||||
return 0;
|
||||
|
||||
error:
|
||||
VIR_FREE(user);
|
||||
VIR_FREE(file);
|
||||
virObjectUnlock(sess);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
|
Loading…
x
Reference in New Issue
Block a user