From 50553d0bc4e0ad0a882440b816c64dfe6d0fdb71 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Wed, 13 Aug 2008 06:45:07 +0200 Subject: [PATCH] Add hook for privileges check --- src/connman.h | 2 ++ src/security.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/connman.h b/src/connman.h index fde2bd3..19322fa 100644 --- a/src/connman.h +++ b/src/connman.h @@ -56,6 +56,8 @@ void __connman_plugin_cleanup(void); #include +int __connman_security_check_privileges(DBusMessage *message); + #include #include diff --git a/src/security.c b/src/security.c index 4539ba1..cf4ae7a 100644 --- a/src/security.c +++ b/src/security.c @@ -60,3 +60,32 @@ void connman_security_unregister(struct connman_security *security) g_static_rw_lock_writer_unlock(&security_lock); } + +int __connman_security_check_privileges(DBusMessage *message) +{ + GSList *list; + const char *sender; + int err = -EPERM; + + DBG("message %p", message); + + sender = dbus_message_get_sender(message); + + g_static_rw_lock_reader_lock(&security_lock); + + for (list = security_list; list; list = list->next) { + struct connman_security *security = list->data; + int err; + + DBG("%s", security->name); + + if (security->authorize_sender) { + err = security->authorize_sender(sender); + break; + } + } + + g_static_rw_lock_reader_unlock(&security_lock); + + return err; +} -- 2.7.4