From: Daniel Wagner <daniel.wag...@bmw-carit.de> ident is not shared anymore between the session policy and the file policy. Let's make this clear be renaming this member. --- plugins/session_policy_local.c | 44 +++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 22 deletions(-)
diff --git a/plugins/session_policy_local.c b/plugins/session_policy_local.c index 90c6f1a..a46f1b3 100644 --- a/plugins/session_policy_local.c +++ b/plugins/session_policy_local.c @@ -58,7 +58,7 @@ struct create_data { struct policy_data { int refcount; - char *ident; + char *filename; struct connman_session *session; struct connman_session_config *config; @@ -71,7 +71,7 @@ static void free_policy(gpointer user_data) if (policy->config != NULL) g_slist_free(policy->config->allowed_bearers); - g_free(policy->ident); + g_free(policy->filename); g_free(policy->config); g_free(policy); } @@ -126,7 +126,7 @@ static struct policy_data *create_policy(void) static struct policy_data *policy_ref(struct policy_data *policy) { - DBG("%p %s ref %d", policy, policy->ident, policy->refcount + 1); + DBG("%p %s ref %d", policy, policy->filename, policy->refcount + 1); __sync_fetch_and_add(&policy->refcount, 1); @@ -135,7 +135,7 @@ static struct policy_data *policy_ref(struct policy_data *policy) static void policy_unref(struct policy_data *policy) { - DBG(" %p %s ref %d", policy, policy->ident, policy->refcount - 1); + DBG(" %p %s ref %d", policy, policy->filename, policy->refcount - 1); if (__sync_fetch_and_sub(&policy->refcount, 1) != 1) return; @@ -170,7 +170,7 @@ static void selinux_context_reply(const unsigned char *context, void *user_data, policy = g_hash_table_lookup(file_hash, ident); if (policy == NULL) { policy = create_policy(); - policy->ident = g_strdup(ident); + policy->filename = g_strdup(ident); } else policy_ref(policy); policy->session = data->session; @@ -276,7 +276,7 @@ static int load_policy(struct policy_data *policy) char *str, **tokens; int i, err = 0; - pathname = g_strdup_printf("%s/%s", POLICYDIR, policy->ident); + pathname = g_strdup_printf("%s/%s", POLICYDIR, policy->filename); err = load_keyfile(pathname, &keyfile); if (err < 0) { @@ -357,7 +357,7 @@ static void remove_policy(struct policy_data *policy) if (policy->session != NULL) update = TRUE; - g_hash_table_remove(file_hash, policy->ident); + g_hash_table_remove(file_hash, policy->filename); policy_unref(policy); if (update == FALSE) @@ -367,7 +367,7 @@ static void remove_policy(struct policy_data *policy) update_session(policy->session); } -static struct policy_data *find_policy(const char *ident) +static struct policy_data *find_policy(const char *filename) { GSList *list; struct policy_data *policy; @@ -375,7 +375,7 @@ static struct policy_data *find_policy(const char *ident) for (list = policy_list; list != NULL; list = list->next) { policy = list->data; - if (g_strcmp0(policy->ident, ident) != 0) + if (g_strcmp0(policy->filename, filename) != 0) continue; return policy; @@ -385,61 +385,61 @@ static struct policy_data *find_policy(const char *ident) } static void notify_handler(struct inotify_event *event, - const char *ident) + const char *filename) { struct policy_data *policy; int err; - DBG("event %x file %s", event->mask, ident); + DBG("event %x file %s", event->mask, filename); - if (ident == NULL) + if (filename == NULL) return; - policy = g_hash_table_lookup(file_hash, ident); + policy = g_hash_table_lookup(file_hash, filename); if (event->mask & (IN_CREATE | IN_MOVED_TO)) { - connman_info("Policy added for '%s'", ident); + connman_info("Policy added for '%s'", filename); /* policy != NULL can happen if the file is overwritten */ if (policy == NULL) { - policy = find_policy(ident); + policy = find_policy(filename); if (policy == NULL) policy = create_policy(); else policy_ref(policy); - policy->ident = g_strdup(ident); + policy->filename = g_strdup(filename); } err = load_policy(policy); if (err < 0) { connman_warn("Loading policy file '%s' failed with %s", - ident, strerror(-err)); + filename, strerror(-err)); policy_unref(policy); return; } g_hash_table_replace(file_hash, - g_strdup(ident), policy); + g_strdup(filename), policy); } if (policy == NULL) return; if (event->mask & IN_MODIFY) { - connman_info("Policy modifed for '%s'", ident); + connman_info("Policy modifed for '%s'", filename); err = load_policy(policy); if (err < 0) { connman_warn("Loading policy file '%s' failed with %s", - ident, strerror(-err)); + filename, strerror(-err)); remove_policy(policy); return; } } if (event->mask & (IN_DELETE | IN_MOVED_FROM)) { - connman_info("Policy deleted for '%s'", ident); + connman_info("Policy deleted for '%s'", filename); remove_policy(policy); return; @@ -464,7 +464,7 @@ static void read_policies(void) struct policy_data *policy; policy = create_policy(); - policy->ident = g_strdup(file); + policy->filename = g_strdup(file); err = load_policy(policy); if (err < 0) { connman_warn("Loading policy file '%s' failed with %s", -- 1.8.1.3.566.gaa39828 _______________________________________________ connman mailing list connman@connman.net http://lists.connman.net/listinfo/connman