From: Marcel Holtmann Date: Wed, 13 Aug 2008 00:22:38 +0000 (+0200) Subject: Add security access policy framework X-Git-Tag: accepted/2.0alpha-wayland/20121110.002834~4744 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6d183c9e8bbce62b4bcb3f26be3176b981615222;p=profile%2Fivi%2Fconnman.git Add security access policy framework --- diff --git a/include/Makefile.am b/include/Makefile.am index 89c5aa5..76057be 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 0000000..104ca7c --- /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 + +#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 9518f28..ea4a21d 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 22616f5..fde2bd3 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 + #include #include diff --git a/src/security.c b/src/security.c new file mode 100644 index 0000000..4539ba1 --- /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 +#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); +}