diff -ru a/src/remote_internal.c b/src/remote_internal.c --- a/src/remote_internal.c 2007-12-17 14:51:09.000000000 -0700 +++ b/src/remote_internal.c 2008-04-09 15:56:59.000000000 -0600 @@ -3054,8 +3054,12 @@ if ((remoteAddr = addrToString(&sa, salen)) == NULL) goto cleanup; - if ((saslcb = remoteAuthMakeCallbacks(auth->credtype, auth->ncredtype)) == NULL) - goto cleanup; + if (auth) { + if ((saslcb = remoteAuthMakeCallbacks(auth->credtype, auth->ncredtype)) == NULL) + goto cleanup; + } else { + saslcb = NULL; + } /* Setup a handle for being a client */ err = sasl_client_new("libvirt", @@ -3168,15 +3172,21 @@ goto cleanup; } /* Run the authentication callback */ - if ((*(auth->cb))(cred, ncred, auth->cbdata) < 0) { + if (auth && auth->cb) { + if ((*(auth->cb))(cred, ncred, auth->cbdata) < 0) { + __virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, + VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, + "Failed to collect auth credentials"); + goto cleanup; + } + remoteAuthFillInteract(cred, interact); + goto restart; + } else { __virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, - "Failed to collect auth credentials"); + "No authentication callback available"); goto cleanup; - return -1; } - remoteAuthFillInteract(cred, interact); - goto restart; } free(iret.mechlist); @@ -3240,15 +3250,22 @@ return -1; } /* Run the authentication callback */ - if ((*(auth->cb))(cred, ncred, auth->cbdata) < 0) { + if (auth && auth->cb) { + if ((*(auth->cb))(cred, ncred, auth->cbdata) < 0) { + __virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, + VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, + "Failed to collect auth credentials"); + goto cleanup; + return -1; + } + remoteAuthFillInteract(cred, interact); + goto restep; + } else { __virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, - "Failed to collect auth credentials"); + "No authentication callback available"); goto cleanup; - return -1; } - remoteAuthFillInteract(cred, interact); - goto restep; } if (serverin) { @@ -3319,7 +3336,8 @@ if (remoteAddr) free(remoteAddr); if (serverin) free(serverin); - free(saslcb); + if (saslcb) + free(saslcb); remoteAuthFreeCredentials(cred, ncred); if (ret != 0 && saslconn) sasl_dispose(&saslconn); @@ -3347,24 +3365,26 @@ }; remoteDebug(priv, "Client initialize PolicyKit authentication"); - for (i = 0 ; i < auth->ncredtype ; i++) { - if (auth->credtype[i] == VIR_CRED_EXTERNAL) - allowcb = 1; - } + if (auth && auth->cb) { + /* Check if the neccessary credential type for PolicyKit is supported */ + for (i = 0 ; i < auth->ncredtype ; i++) { + if (auth->credtype[i] == VIR_CRED_EXTERNAL) + allowcb = 1; + } - /* Run the authentication callback */ - if (allowcb) { - if (auth && auth->cb && - (*(auth->cb))(&cred, 1, auth->cbdata) < 0) { - __virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, - VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, - "Failed to collect auth credentials"); - return -1; + if (allowcb) { + /* Run the authentication callback */ + if ((*(auth->cb))(&cred, 1, auth->cbdata) < 0) { + __virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, + VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, + "Failed to collect auth credentials"); + return -1; + } } else { - remoteDebug(priv, "No auth callback provided for PolicyKit"); + remoteDebug(priv, "Client auth callback does not support PolicyKit"); } } else { - remoteDebug(priv, "Client auth callback does not support PolicyKit"); + remoteDebug(priv, "No auth callback provided"); } memset (&ret, 0, sizeof ret);