for (i= 0, tmp_flag = IDENTITY_INFO_PROP_ID;
tmp_flag < IDENTITY_INFO_PROP_MAX;
tmp_flag <<= 1, i++) {
- if (flags & tmp_flag &&
+ if ((flags & tmp_flag) &&
gsignond_dictionary_contains (src->map, keys[i])) {
gsignond_dictionary_set (dest->map, keys[i],
g_variant_ref (gsignond_dictionary_get (src->map, keys[i])));
return flags;
}
+void
+gsignond_identity_info_remove_owner (GSignondIdentityInfo *info)
+{
+ g_return_if_fail (info && GSIGNOND_IS_IDENTITY_INFO(info));
+
+ gsignond_dictionary_remove (info->map, GSIGNOND_IDENTITY_INFO_OWNER);
+}
+
/**
* gsignond_identity_info_new:
*
g_return_val_if_fail (info && GSIGNOND_IS_IDENTITY_INFO (info), NULL);
GVariant *var = gsignond_dictionary_get (info->map,
- GSIGNOND_IDENTITY_INFO_OWNER);
+ GSIGNOND_IDENTITY_INFO_OWNER);
return var ? gsignond_security_context_from_variant (var) : NULL;
}
gsignond_security_context_compare (current_owner, owner) == 0)
return TRUE;
- return gsignond_dictionary_set (info->map,
- GSIGNOND_IDENTITY_INFO_OWNER,
- gsignond_security_context_to_variant (owner)) &&
- gsignond_identity_info_set_edit_flags (info,
- IDENTITY_INFO_PROP_OWNER);
+ return (gsignond_dictionary_set (info->map,
+ GSIGNOND_IDENTITY_INFO_OWNER,
+ gsignond_security_context_to_variant (owner)) &&
+ gsignond_identity_info_set_edit_flags (info,
+ IDENTITY_INFO_PROP_OWNER));
}
/**
GSignondDaemon *daemon;
guint32 identity_id;
}_StoreCachedTokenCbInfo;
+
static void
_store_cached_token_data (const gchar *method, GSignondAuthSession *session, _StoreCachedTokenCbInfo *data)
{
gsignond_daemon_store_identity_data (data->daemon, data->identity_id, method, token_data);
}
+static long
+_ncstrlen (const gchar *strptr)
+{
+ if (strptr == NULL)
+ return -1;
+ return (long) strlen (strptr);
+}
+
guint32
gsignond_identity_store (GSignondIdentity *identity,
const GVariant *info,
GSignondIdentityPrivate *priv = NULL;
GSignondIdentityInfo *identity_info = NULL;
gboolean was_new_identity = FALSE;
+ GSignondSecurityContext *owner_ctx = NULL;
GSignondSecurityContextList *contexts = NULL;
GSignondIdentityInfoPropFlags flags;
+ GSignondIdentityInfoPropFlags flag_mask;
guint32 id;
if (!(identity && GSIGNOND_IS_IDENTITY (identity))) {
identity_info = gsignond_identity_info_new_from_variant ((GVariant *)info);
+ /* if owner context is non-NULL but empty, remove the dictionary item,
+ * it will get filled up later when actual store happens */
+ owner_ctx = gsignond_identity_info_get_owner (identity_info);
+ if (owner_ctx) {
+ const gchar *sys_ctx =
+ gsignond_security_context_get_system_context (owner_ctx);
+ if (_ncstrlen (sys_ctx) <= 0) {
+ gsignond_identity_info_remove_owner (identity_info);
+ }
+ gsignond_security_context_free (owner_ctx);
+ owner_ctx = NULL;
+ }
+
contexts = gsignond_identity_info_get_access_control_list (identity_info);
if (contexts) {
VALIDATE_IDENTITY_WRITE_ACL (identity, ctx, 0);
flags = gsignond_identity_info_get_edit_flags (identity_info);
/* select only interested field */
- flags &= (IDENTITY_INFO_PROP_USERNAME |
- IDENTITY_INFO_PROP_USERNAME_IS_SECRET |
- IDENTITY_INFO_PROP_SECRET |
- IDENTITY_INFO_PROP_STORE_SECRET |
- IDENTITY_INFO_PROP_CAPTION |
- IDENTITY_INFO_PROP_TYPE |
- IDENTITY_INFO_PROP_METHODS |
- IDENTITY_INFO_PROP_REALMS);
+ flag_mask = (IDENTITY_INFO_PROP_USERNAME |
+ IDENTITY_INFO_PROP_USERNAME_IS_SECRET |
+ IDENTITY_INFO_PROP_SECRET |
+ IDENTITY_INFO_PROP_STORE_SECRET |
+ IDENTITY_INFO_PROP_CAPTION |
+ IDENTITY_INFO_PROP_TYPE |
+ IDENTITY_INFO_PROP_METHODS |
+ IDENTITY_INFO_PROP_REALMS |
+ IDENTITY_INFO_PROP_ACL);
+ if (was_new_identity)
+ flag_mask |= IDENTITY_INFO_PROP_OWNER;
+ flags &= flag_mask;
gsignond_identity_info_selective_copy (priv->info, identity_info, flags);
/* FIXME : either username/secret changed reset the identity