Take reference when network is connected and assigned to device
[connman] / src / security.c
index c7c3ccf..9b27423 100644 (file)
@@ -2,7 +2,7 @@
  *
  *  Connection Manager
  *
- *  Copyright (C) 2007-2008  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2007-2009  Intel Corporation. All rights reserved.
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License version 2 as
@@ -25,7 +25,6 @@
 
 #include "connman.h"
 
-static GStaticRWLock security_lock = G_STATIC_RW_LOCK_INIT;
 static GSList *security_list = NULL;
 
 static gint compare_priority(gconstpointer a, gconstpointer b)
@@ -48,13 +47,9 @@ int connman_security_register(struct connman_security *security)
 {
        DBG("security %p name %s", security, security->name);
 
-       g_static_rw_lock_writer_lock(&security_lock);
-
        security_list = g_slist_insert_sorted(security_list, security,
                                                        compare_priority);
 
-       g_static_rw_lock_writer_unlock(&security_lock);
-
        return 0;
 }
 
@@ -68,14 +63,11 @@ void connman_security_unregister(struct connman_security *security)
 {
        DBG("security %p name %s", security, security->name);
 
-       g_static_rw_lock_writer_lock(&security_lock);
-
        security_list = g_slist_remove(security_list, security);
-
-       g_static_rw_lock_writer_unlock(&security_lock);
 }
 
-int __connman_security_check_privileges(DBusMessage *message)
+int __connman_security_check_privilege(DBusMessage *message,
+                               enum connman_security_privilege privilege)
 {
        GSList *list;
        const char *sender;
@@ -85,20 +77,16 @@ int __connman_security_check_privileges(DBusMessage *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;
 
                DBG("%s", security->name);
 
                if (security->authorize_sender) {
-                       err = security->authorize_sender(sender);
+                       err = security->authorize_sender(sender, privilege);
                        break;
                }
        }
 
-       g_static_rw_lock_reader_unlock(&security_lock);
-
        return err;
 }