]> xenbits.xensource.com Git - libvirt.git/commitdiff
Refactor policycode auth code to avoid compiler warnings
authorDaniel P. Berrange <berrange@redhat.com>
Tue, 25 Aug 2009 16:18:27 +0000 (17:18 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Tue, 25 Aug 2009 16:24:12 +0000 (17:24 +0100)
* src/remote_internal.c: Split remoteAuthPolkit into separate
  impls for v0 and v1 to avoid compile warnings due to unused
  variables/params
* qemud/remote.c: Remove accidental tabs

qemud/remote.c
src/remote_internal.c

index 490a807bb50b79c297eca8408d0a8c3066be3104..b29d5d8ffba0133330ae4461484dba44f18cd4bf 100644 (file)
@@ -3154,12 +3154,12 @@ remoteDispatchAuthPolkit (struct qemud_server *server,
     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"),
index a5577a5d2856bc119213c3b86436e786376bd049..26425c2039e646850152fe56bd0bd3340a1dae8e 100644 (file)
@@ -6194,6 +6194,25 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open,
 
 
 #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
@@ -6201,7 +6220,6 @@ remoteAuthPolkit (virConnectPtr conn, struct private_data *priv, int in_open,
                   virConnectAuthPtr auth)
 {
     remote_auth_polkit_ret ret;
-#if HAVE_POLKIT0
     int i, allowcb = 0;
     virConnectCredential cred = {
         VIR_CRED_EXTERNAL,
@@ -6211,10 +6229,8 @@ remoteAuthPolkit (virConnectPtr conn, struct private_data *priv, int in_open,
         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++) {
@@ -6237,9 +6253,6 @@ remoteAuthPolkit (virConnectPtr conn, struct private_data *priv, int in_open,
     } 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,
@@ -6248,9 +6261,10 @@ remoteAuthPolkit (virConnectPtr conn, struct private_data *priv, int in_open,
         return -1; /* virError already set by call */
     }
 
-    DEBUG0("PolicyKit authentication complete");
+    DEBUG0("PolicyKit-0 authentication complete");
     return 0;
 }
+#endif /* HAVE_POLKIT0 */
 #endif /* HAVE_POLKIT */
 /*----------------------------------------------------------------------*/