summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2008-08-13 02:22:38 +0200
committerMarcel Holtmann <marcel@holtmann.org>2008-08-13 02:22:38 +0200
commit6d183c9e8bbce62b4bcb3f26be3176b981615222 (patch)
tree758753de7f75086f09eb66f1c50048907af49ecb
parent495ba1eff89bd0a466c07c35c57c65cdb7aee39e (diff)
downloadconnman-6d183c9e8bbce62b4bcb3f26be3176b981615222.tar.gz
connman-6d183c9e8bbce62b4bcb3f26be3176b981615222.tar.bz2
connman-6d183c9e8bbce62b4bcb3f26be3176b981615222.zip
Add security access policy framework
-rw-r--r--include/Makefile.am3
-rw-r--r--include/security.h48
-rw-r--r--src/Makefile.am2
-rw-r--r--src/connman.h2
-rw-r--r--src/security.c62
5 files changed, 115 insertions, 2 deletions
diff --git a/include/Makefile.am b/include/Makefile.am
index 89c5aa51..76057be1 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -1,7 +1,8 @@
includedir = @includedir@/connman
-include_HEADERS = log.h plugin.h driver.h element.h property.h rtnl.h dbus.h
+include_HEADERS = log.h plugin.h security.h driver.h element.h property.h \
+ rtnl.h dbus.h
MAINTAINERCLEANFILES = Makefile.in
diff --git a/include/security.h b/include/security.h
new file mode 100644
index 00000000..104ca7cf
--- /dev/null
+++ b/include/security.h
@@ -0,0 +1,48 @@
+/*
+ *
+ * Connection Manager
+ *
+ * Copyright (C) 2007-2008 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
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifndef __CONNMAN_SECURITY_H
+#define __CONNMAN_SECURITY_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <connman/element.h>
+
+#define CONNMAN_SECURITY_PRIORITY_LOW -100
+#define CONNMAN_SECURITY_PRIORITY_DEFAULT 0
+#define CONNMAN_SECURITY_PRIORITY_HIGH 100
+
+struct connman_security {
+ const char *name;
+ int priority;
+ int (*authorize_sender) (const char *sender);
+};
+
+extern int connman_security_register(struct connman_security *security);
+extern void connman_security_unregister(struct connman_security *security);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __CONNMAN_SECURITY_H */
diff --git a/src/Makefile.am b/src/Makefile.am
index 9518f28d..ea4a21d5 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -12,7 +12,7 @@ DISTCLEANFILES = $(service_DATA)
sbin_PROGRAMS = connmand
connmand_SOURCES = main.c connman.h log.c plugin.c profile.c element.c \
- storage.c manager.c agent.c rtnl.c
+ security.c storage.c manager.c agent.c rtnl.c
connmand_LDADD = @GDBUS_LIBS@ @GLIB_LIBS@ @GMODULE_LIBS@ @GTHREAD_LIBS@
diff --git a/src/connman.h b/src/connman.h
index 22616f52..fde2bd33 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -54,6 +54,8 @@ void __connman_log_cleanup(void);
int __connman_plugin_init(void);
void __connman_plugin_cleanup(void);
+#include <connman/security.h>
+
#include <connman/driver.h>
#include <connman/element.h>
diff --git a/src/security.c b/src/security.c
new file mode 100644
index 00000000..4539ba1f
--- /dev/null
+++ b/src/security.c
@@ -0,0 +1,62 @@
+/*
+ *
+ * Connection Manager
+ *
+ * Copyright (C) 2007-2008 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
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#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)
+{
+ const struct connman_security *security1 = a;
+ const struct connman_security *security2 = b;
+
+ return security2->priority - security1->priority;
+}
+
+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;
+}
+
+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);
+}