filemon: fix watch IDs to avoid potential wraparound issues
[qemu/ar7.git] / include / authz / listfile.h
blob0d618c903c3a19f7d0b4dd130c89aa16585b225b
1 /*
2 * QEMU list file authorization driver
4 * Copyright (c) 2018 Red Hat, Inc.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
21 #ifndef QAUTHZ_LIST_FILE_H__
22 #define QAUTHZ_LIST_FILE_H__
24 #include "authz/list.h"
25 #include "qapi/qapi-types-authz.h"
26 #include "qemu/filemonitor.h"
28 #define TYPE_QAUTHZ_LIST_FILE "authz-list-file"
30 #define QAUTHZ_LIST_FILE_CLASS(klass) \
31 OBJECT_CLASS_CHECK(QAuthZListFileClass, (klass), \
32 TYPE_QAUTHZ_LIST_FILE)
33 #define QAUTHZ_LIST_FILE_GET_CLASS(obj) \
34 OBJECT_GET_CLASS(QAuthZListFileClass, (obj), \
35 TYPE_QAUTHZ_LIST_FILE)
36 #define QAUTHZ_LIST_FILE(obj) \
37 OBJECT_CHECK(QAuthZListFile, (obj), \
38 TYPE_QAUTHZ_LIST_FILE)
40 typedef struct QAuthZListFile QAuthZListFile;
41 typedef struct QAuthZListFileClass QAuthZListFileClass;
44 /**
45 * QAuthZListFile:
47 * This authorization driver provides a file mechanism
48 * for granting access by matching user names against a
49 * file of globs. Each match rule has an associated policy
50 * and a catch all policy applies if no rule matches
52 * To create an instance of this class via QMP:
54 * {
55 * "execute": "object-add",
56 * "arguments": {
57 * "qom-type": "authz-list-file",
58 * "id": "authz0",
59 * "props": {
60 * "filename": "/etc/qemu/myvm-vnc.acl",
61 * "refresh": true
62 * }
63 * }
64 * }
66 * If 'refresh' is 'yes', inotify is used to monitor for changes
67 * to the file and auto-reload the rules.
69 * The myvm-vnc.acl file should contain the parameters for
70 * the QAuthZList object in JSON format:
72 * {
73 * "rules": [
74 * { "match": "fred", "policy": "allow", "format": "exact" },
75 * { "match": "bob", "policy": "allow", "format": "exact" },
76 * { "match": "danb", "policy": "deny", "format": "exact" },
77 * { "match": "dan*", "policy": "allow", "format": "glob" }
78 * ],
79 * "policy": "deny"
80 * }
82 * The object can be created on the command line using
84 * -object authz-list-file,id=authz0,\
85 * filename=/etc/qemu/myvm-vnc.acl,refresh=yes
88 struct QAuthZListFile {
89 QAuthZ parent_obj;
91 QAuthZ *list;
92 char *filename;
93 bool refresh;
94 QFileMonitor *file_monitor;
95 int64_t file_watch;
99 struct QAuthZListFileClass {
100 QAuthZClass parent_class;
104 QAuthZListFile *qauthz_list_file_new(const char *id,
105 const char *filename,
106 bool refresh,
107 Error **errp);
110 #endif /* QAUTHZ_LIST_FILE_H__ */