Remove obsolete file.
[connman] / src / security.c
1 /*
2  *
3  *  Connection Manager
4  *
5  *  Copyright (C) 2007-2009  Intel Corporation. All rights reserved.
6  *
7  *  This program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License version 2 as
9  *  published by the Free Software Foundation.
10  *
11  *  This program 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
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  *
20  */
21
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
25
26 #include "connman.h"
27
28 static GSList *security_list = NULL;
29
30 static gint compare_priority(gconstpointer a, gconstpointer b)
31 {
32         const struct connman_security *security1 = a;
33         const struct connman_security *security2 = b;
34
35         return security2->priority - security1->priority;
36 }
37
38 /**
39  * connman_security_register:
40  * @security: security module
41  *
42  * Register a new security module
43  *
44  * Returns: %0 on success
45  */
46 int connman_security_register(struct connman_security *security)
47 {
48         DBG("security %p name %s", security, security->name);
49
50         security_list = g_slist_insert_sorted(security_list, security,
51                                                         compare_priority);
52
53         return 0;
54 }
55
56 /**
57  * connman_security_unregister:
58  * @security: security module
59  *
60  * Remove a previously registered security module
61  */
62 void connman_security_unregister(struct connman_security *security)
63 {
64         DBG("security %p name %s", security, security->name);
65
66         security_list = g_slist_remove(security_list, security);
67 }
68
69 int __connman_security_check_privilege(DBusMessage *message,
70                                 enum connman_security_privilege privilege)
71 {
72         GSList *list;
73         const char *sender;
74         int err = 0;
75
76         DBG("message %p", message);
77
78         sender = dbus_message_get_sender(message);
79
80         for (list = security_list; list; list = list->next) {
81                 struct connman_security *security = list->data;
82
83                 DBG("%s", security->name);
84
85                 if (security->authorize_sender) {
86                         err = security->authorize_sender(sender, privilege);
87                         break;
88                 }
89         }
90
91         return err;
92 }