list.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * QEMU list authorization driver
  3. *
  4. * Copyright (c) 2018 Red Hat, Inc.
  5. *
  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.1 of the License, or (at your option) any later version.
  10. *
  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.
  15. *
  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/>.
  18. *
  19. */
  20. #ifndef QAUTHZ_LIST_H
  21. #define QAUTHZ_LIST_H
  22. #include "authz/base.h"
  23. #include "qapi/qapi-types-authz.h"
  24. #include "qom/object.h"
  25. #define TYPE_QAUTHZ_LIST "authz-list"
  26. OBJECT_DECLARE_SIMPLE_TYPE(QAuthZList,
  27. QAUTHZ_LIST)
  28. /**
  29. * QAuthZList:
  30. *
  31. * This authorization driver provides a list mechanism
  32. * for granting access by matching user names against a
  33. * list of globs. Each match rule has an associated policy
  34. * and a catch all policy applies if no rule matches
  35. *
  36. * To create an instance of this class via QMP:
  37. *
  38. * {
  39. * "execute": "object-add",
  40. * "arguments": {
  41. * "qom-type": "authz-list",
  42. * "id": "authz0",
  43. * "props": {
  44. * "rules": [
  45. * { "match": "fred", "policy": "allow", "format": "exact" },
  46. * { "match": "bob", "policy": "allow", "format": "exact" },
  47. * { "match": "danb", "policy": "deny", "format": "exact" },
  48. * { "match": "dan*", "policy": "allow", "format": "glob" }
  49. * ],
  50. * "policy": "deny"
  51. * }
  52. * }
  53. * }
  54. *
  55. */
  56. struct QAuthZList {
  57. QAuthZ parent_obj;
  58. QAuthZListPolicy policy;
  59. QAuthZListRuleList *rules;
  60. };
  61. QAuthZList *qauthz_list_new(const char *id,
  62. QAuthZListPolicy policy,
  63. Error **errp);
  64. ssize_t qauthz_list_append_rule(QAuthZList *auth,
  65. const char *match,
  66. QAuthZListPolicy policy,
  67. QAuthZListFormat format,
  68. Error **errp);
  69. ssize_t qauthz_list_insert_rule(QAuthZList *auth,
  70. const char *match,
  71. QAuthZListPolicy policy,
  72. QAuthZListFormat format,
  73. size_t index,
  74. Error **errp);
  75. ssize_t qauthz_list_delete_rule(QAuthZList *auth,
  76. const char *match);
  77. #endif /* QAUTHZ_LIST_H */