]> git.proxmox.com Git - mirror_qemu.git/commitdiff
authz-simple: Check that 'identity' property is set
authorKevin Wolf <kwolf@redhat.com>
Tue, 17 Nov 2020 16:30:45 +0000 (17:30 +0100)
committerDaniel P. Berrangé <berrange@redhat.com>
Wed, 18 Nov 2020 10:51:35 +0000 (10:51 +0000)
If the 'identify' property is not set, we'll pass a NULL pointer to
g_str_equal() and crash. Catch the error condition during the creation
of the object.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
authz/simple.c

index 18db0355f4081961a9cfd22a67411563c1976ad9..0597dcd8ea5a3a2ad3611a37df11177a24d9d490 100644 (file)
@@ -65,11 +65,25 @@ qauthz_simple_finalize(Object *obj)
 }
 
 
+static void
+qauthz_simple_complete(UserCreatable *uc, Error **errp)
+{
+    QAuthZSimple *sauthz = QAUTHZ_SIMPLE(uc);
+
+    if (!sauthz->identity) {
+        error_setg(errp, "The 'identity' property must be set");
+        return;
+    }
+}
+
+
 static void
 qauthz_simple_class_init(ObjectClass *oc, void *data)
 {
     QAuthZClass *authz = QAUTHZ_CLASS(oc);
+    UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc);
 
+    ucc->complete = qauthz_simple_complete;
     authz->is_allowed = qauthz_simple_is_allowed;
 
     object_class_property_add_str(oc, "identity",