#include "virstring.h"
#include "virauth.h"
#include "virbuffer.h"
+#include "virsecureerase.h"
#define VIR_FROM_THIS VIR_FROM_LIBSSH
/* Try the authenticating the set amount of times. The server breaks the
* connection if maximum number of bad auth tries is exceeded */
while (true) {
- VIR_AUTODISPOSE_STR password = NULL;
+ g_autofree char *password = NULL;
if (!(password = virAuthGetPasswordPath(sess->authPath, sess->cred,
"ssh", sess->username,
return SSH_AUTH_ERROR;
/* tunnelled password authentication */
- if ((rc = ssh_userauth_password(sess->session, NULL,
- password)) == 0)
- return SSH_AUTH_SUCCESS;
+ rc = ssh_userauth_password(sess->session, NULL, password);
+ virSecureEraseString(password);
- if (rc != SSH_AUTH_DENIED)
+ if (rc == 0)
+ return SSH_AUTH_SUCCESS;
+ else if (rc != SSH_AUTH_DENIED)
break;
}
}