authz: add QAuthZListFile object type for a file access control list
commit55d869846de802a16af1a50584c51737bd664387
authorDaniel P. Berrangé <berrange@redhat.com>
Fri, 11 May 2018 11:19:59 +0000 (11 12:19 +0100)
committerDaniel P. Berrangé <berrange@redhat.com>
Tue, 26 Feb 2019 15:32:18 +0000 (26 15:32 +0000)
tree31264ae5ec064fdc4c5cde1d5914f3c1e546ef87
parentc8c99887d119197e9f670e786db5b045c0470542
authz: add QAuthZListFile object type for a file access control list

Add a QAuthZListFile object type that implements the QAuthZ interface. This
built-in implementation is a proxy around the QAuthZList object type,
initializing it from an external file, and optionally, automatically
reloading it whenever it changes.

To create an instance of this object via the QMP monitor, the syntax
used would be:

      {
        "execute": "object-add",
        "arguments": {
          "qom-type": "authz-list-file",
          "id": "authz0",
          "props": {
            "filename": "/etc/qemu/vnc.acl",
    "refresh": true
          }
        }
      }

If "refresh" is "yes", inotify is used to monitor the file,
automatically reloading changes. If an error occurs during reloading,
all authorizations will fail until the file is next successfully
loaded.

The /etc/qemu/vnc.acl file would contain a JSON representation of a
QAuthZList object

    {
      "rules": [
         { "match": "fred", "policy": "allow", "format": "exact" },
         { "match": "bob", "policy": "allow", "format": "exact" },
         { "match": "danb", "policy": "deny", "format": "glob" },
         { "match": "dan*", "policy": "allow", "format": "exact" },
      ],
      "policy": "deny"
    }

This sets up an authorization rule that allows 'fred', 'bob' and anyone
whose name starts with 'dan', except for 'danb'. Everyone unmatched is
denied.

The object can be loaded on the comand line using

   -object authz-list-file,id=authz0,filename=/etc/qemu/vnc.acl,refresh=yes

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
authz/Makefile.objs
authz/listfile.c [new file with mode: 0644]
authz/trace-events
include/authz/listfile.h [new file with mode: 0644]
qemu-options.hx
tests/Makefile.include
tests/test-authz-listfile.c [new file with mode: 0644]