diff options
author | Thomas Haller <thaller@redhat.com> | 2020-09-24 19:11:40 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-09-28 22:28:26 +0200 |
commit | 913d175621878158b0381ef3525cd511b2aaa681 (patch) | |
tree | f967ce0a34c51eacd4cf752cfeb32b36832c08bc | |
parent | 2bc3588c1d4531e69e7ab6547a6d7947019d3a2c (diff) | |
download | NetworkManager-913d175621878158b0381ef3525cd511b2aaa681.tar.gz |
core: add nm_auth_is_invocation_in_acl_set_error() helper
-rw-r--r-- | src/nm-auth-utils.c | 27 | ||||
-rw-r--r-- | src/nm-auth-utils.h | 7 |
2 files changed, 34 insertions, 0 deletions
diff --git a/src/nm-auth-utils.c b/src/nm-auth-utils.c index 9d10d56510..fb54952068 100644 --- a/src/nm-auth-utils.c +++ b/src/nm-auth-utils.c @@ -13,6 +13,7 @@ #include "nm-auth-manager.h" #include "nm-session-monitor.h" #include "nm-dbus-manager.h" +#include "nm-core-utils.h" /*****************************************************************************/ @@ -667,3 +668,29 @@ nm_auth_is_subject_in_acl_set_error(NMConnection * connection, g_free(error_desc); return FALSE; } + +gboolean +nm_auth_is_invocation_in_acl_set_error(NMConnection * connection, + GDBusMethodInvocation *invocation, + GQuark err_domain, + int err_code, + NMAuthSubject ** out_subject, + GError ** error) +{ + gs_unref_object NMAuthSubject *subject = NULL; + gboolean success; + + nm_assert(!out_subject || !*out_subject); + + subject = nm_dbus_manager_new_auth_subject_from_context(invocation); + if (!subject) { + g_set_error_literal(error, err_domain, err_code, NM_UTILS_ERROR_MSG_REQ_UID_UKNOWN); + return FALSE; + } + + success = nm_auth_is_subject_in_acl_set_error(connection, subject, err_domain, err_code, error); + + NM_SET_OUT(out_subject, g_steal_pointer(&subject)); + + return success; +} diff --git a/src/nm-auth-utils.h b/src/nm-auth-utils.h index b9aa90ce54..8f44692982 100644 --- a/src/nm-auth-utils.h +++ b/src/nm-auth-utils.h @@ -85,4 +85,11 @@ gboolean nm_auth_is_subject_in_acl_set_error(NMConnection * connection, int err_code, GError ** error); +gboolean nm_auth_is_invocation_in_acl_set_error(NMConnection * connection, + GDBusMethodInvocation *invocation, + GQuark err_domain, + int err_code, + NMAuthSubject ** out_subject, + GError ** error); + #endif /* __NETWORKMANAGER_MANAGER_AUTH_H__ */ |