rv = snprintf(pidbuf, sizeof pidbuf, "%d", callerPid);
if (rv < 0 || rv >= sizeof pidbuf) {
VIR_ERROR(_("Caller PID was too large %d"), callerPid);
- goto authfail;
+ goto authfail;
}
if (virRun(NULL, pkcheck, &status) < 0) {
VIR_ERROR(_("Cannot invoke %s"), PKCHECK_PATH);
- goto authfail;
+ goto authfail;
}
if (status != 0) {
VIR_ERROR(_("Policy kit denied action %s from pid %d, uid %d, result: %d\n"),
#if HAVE_POLKIT
+#if HAVE_POLKIT1
+static int
+remoteAuthPolkit (virConnectPtr conn, struct private_data *priv, int in_open,
+ virConnectAuthPtr auth ATTRIBUTE_UNUSED)
+{
+ remote_auth_polkit_ret ret;
+ DEBUG0("Client initialize PolicyKit-1 authentication");
+
+ memset (&ret, 0, sizeof ret);
+ if (call (conn, priv, in_open, REMOTE_PROC_AUTH_POLKIT,
+ (xdrproc_t) xdr_void, (char *)NULL,
+ (xdrproc_t) xdr_remote_auth_polkit_ret, (char *) &ret) != 0) {
+ return -1; /* virError already set by call */
+ }
+
+ DEBUG0("PolicyKit-1 authentication complete");
+ return 0;
+}
+#elif HAVE_POLKIT0
/* Perform the PolicyKit authentication process
*/
static int
virConnectAuthPtr auth)
{
remote_auth_polkit_ret ret;
-#if HAVE_POLKIT0
int i, allowcb = 0;
virConnectCredential cred = {
VIR_CRED_EXTERNAL,
NULL,
0,
};
-#endif
- DEBUG0("Client initialize PolicyKit authentication");
+ DEBUG0("Client initialize PolicyKit-0 authentication");
-#if HAVE_POLKIT0
if (auth && auth->cb) {
/* Check if the necessary credential type for PolicyKit is supported */
for (i = 0 ; i < auth->ncredtype ; i++) {
} else {
DEBUG0("No auth callback provided");
}
-#else
- DEBUG0("No auth callback required for PolicyKit-1");
-#endif
memset (&ret, 0, sizeof ret);
if (call (conn, priv, in_open, REMOTE_PROC_AUTH_POLKIT,
return -1; /* virError already set by call */
}
- DEBUG0("PolicyKit authentication complete");
+ DEBUG0("PolicyKit-0 authentication complete");
return 0;
}
+#endif /* HAVE_POLKIT0 */
#endif /* HAVE_POLKIT */
/*----------------------------------------------------------------------*/