cmd = virCommandNewArgList(POLKIT_AUTH, "--obtain", privilege, NULL);
if (virCommandRun(cmd, &status) < 0 ||
- status > 1)
+ status > 0)
goto cleanup;
ret = 0;
};
VIR_DEBUG("Client initialize PolicyKit-0 authentication");
+ /* Check auth first and if it succeeds we are done. */
+ memset (&ret, 0, sizeof ret);
+ if (call (conn, priv, 0, REMOTE_PROC_AUTH_POLKIT,
+ (xdrproc_t) xdr_void, (char *)NULL,
+ (xdrproc_t) xdr_remote_auth_polkit_ret, (char *) &ret) == 0)
+ goto out;
+
+ /* Auth failed. Ask client to obtain it and check again. */
if (auth && auth->cb) {
/* Check if the necessary credential type for PolicyKit is supported */
for (i = 0 ; i < auth->ncredtype ; i++) {
}
} else {
VIR_DEBUG("Client auth callback does not support PolicyKit");
+ return -1;
}
} else {
VIR_DEBUG("No auth callback provided");
+ return -1;
}
memset (&ret, 0, sizeof ret);
return -1; /* virError already set by call */
}
+out:
VIR_DEBUG("PolicyKit-0 authentication complete");
return 0;
}