Beispiel #1
0
static security_class_t string_to_security_class_compat(const char *s)
{
	unsigned int val;

	if (isdigit(s[0])) {
		val = atoi(s);
		if (val > 0 && val < NCLASSES)
			return map_class(val);
	} else {
		for (val = 0; val < NCLASSES; val++) {
			if (strcmp(s, (class_to_string_data.str
				       + class_to_string[val])) == 0)
				return map_class(val);
		}
	}

	errno = EINVAL;
	return 0;
}
Beispiel #2
0
security_class_t string_to_security_class(const char *s)
{
	struct discover_class_node *node;

	node = get_class_cache_entry_name(s);
	if (node == NULL) {
		node = discover_class(s);

		if (node == NULL) {
			errno = EINVAL;
			return 0;
		}
	}

	return map_class(node->value);
}