Esempio n. 1
0
isns_keystore_t *
isns_create_simple_keystore(const char *dirname)
{
	isns_simple_keystore_t *store;

	store = isns_calloc(1, sizeof(*store));
	store->sc_base.ic_name = "simple key store";
	store->sc_base.ic_find = __isns_simple_keystore_find;
	store->sc_dirpath = isns_strdup(dirname);

	return (isns_keystore_t *) store;
}
Esempio n. 2
0
/*
 * Set up the SCN object.
 */
static isns_scn_t *
isns_scn_setup(isns_scn_t *scn, isns_object_t *node)
{
	isns_object_list_t portals = ISNS_OBJECT_LIST_INIT;
	isns_object_t	*entity;
	unsigned int	i;

	entity = isns_object_get_entity(node);
	if (entity == NULL
	 || !isns_object_find_descendants(entity,
			 &isns_portal_template, NULL, &portals))
		return NULL;

	for (i = 0; i < portals.iol_count; ++i) {
		isns_object_t	*portal = portals.iol_data[i];
		isns_portal_info_t info;
		isns_scn_funnel_t *funnel;

		/* Extract address and SCN port from portal */
		if (!isns_portal_from_object(&info,
				ISNS_TAG_PORTAL_IP_ADDRESS,
				ISNS_TAG_SCN_PORT,
				portal))
			continue;

		/* We know where to send our notifications! */
		if (scn == NULL) {
			isns_attr_t	*attr;

			if (!isns_object_get_attr(node, ISNS_TAG_ISCSI_NAME, &attr)
			 && !isns_object_get_attr(node, ISNS_TAG_FC_PORT_NAME_WWPN, &attr)) {
				isns_error("Attempt to set up SCN for strange node type\n");
				return NULL;
			}

			scn = isns_calloc(1, sizeof(*scn));
			scn->scn_entity = isns_object_get(entity);
			scn->scn_owner = isns_object_get(node);
			scn->scn_attr = isns_attr_get(attr);
			scn->scn_name = isns_strdup(attr->ia_value.iv_string);
		}

		funnel = isns_calloc(1, sizeof(*funnel));
		funnel->scn_portal = info;
		funnel->scn_next = scn->scn_funnels;
		scn->scn_funnels = funnel;
	}

	isns_object_list_destroy(&portals);
	return scn;
}
Esempio n. 3
0
static int
isns_policy_object_type_parse(isns_value_t *vp, const char *buf)
{
	char	*copy, *s, *next;
	int	rv = 0;

	if (!strcasecmp(buf, "ALL")) {
		vp->iv_uint32 = ~0;
		return 1;
	}
	if (!strcasecmp(buf, "DEFAULT")) {
		vp->iv_uint32 = ISNS_DEFAULT_OBJECT_ACCESS;
		return 1;
	}

	vp->iv_uint32 = 0;
	copy = isns_strdup(buf);
	for (s = copy; s; s = next) {
		char	*perm;
		int	bit, mask = 0;

		while (1) {
			unsigned int n;

			n = strcspn(s, ",+;|");
			if (n) {
				next = s + n;
				if (*next)
					*next++ = '\0';
				break;
			}
			++n;
		}

		mask = ISNS_PERMISSION_READ;
		if ((perm = strchr(s, ':')) != NULL) {
			*perm++ = '\0';
			mask = 0;
			while (*perm) {
				switch (*perm++) {
				case 'R': case 'r':
					mask = ISNS_PERMISSION_READ;
					break;
				case 'W': case 'w':
					mask = ISNS_PERMISSION_READ;
					break;
				default:
					goto failed;
				}
			}
		}

		for (bit = 0; bit < 32; ++bit) {
			if (policy_object_type_bit_names[bit]
			 && !strcasecmp(policy_object_type_bit_names[bit], s))
				goto found;
		}
		goto failed;

found:		vp->iv_uint32 |= ISNS_ACCESS(bit, mask);
	}
	rv = 1;

failed:
	isns_free(copy);
	return rv;
}