Пример #1
0
static int validate_handler(
	const semanage_fcontext_t* fcon,
	void* varg) {

	char* str;

	/* Unpack varg */
	struct validate_handler_arg* arg =
		(struct validate_handler_arg*) varg;
	semanage_handle_t* handle = arg->handle;
	const sepol_policydb_t* policydb = arg->policydb;

	/* Unpack fcontext */
	const char* expr = semanage_fcontext_get_expr(fcon);
	int type = semanage_fcontext_get_type(fcon);
	const char* type_str = semanage_fcontext_get_type_str(type);
	semanage_context_t* con = semanage_fcontext_get_con(fcon);

	if (con && sepol_context_check(handle->sepolh, policydb, con) < 0)
		goto invalid;

	return 0;

	invalid:
	if (semanage_context_to_string(handle, con, &str) >= 0) {
		ERR(handle, "invalid context %s specified for %s [%s]", 
			str, expr, type_str);
		free(str);
	} else
		ERR(handle, "invalid context specified for %s [%s]", 
			expr, type_str);
	return -1;
}
Пример #2
0
int semanage_fcontext_key_extract(semanage_handle_t * handle,
				  const semanage_fcontext_t * fcontext,
				  semanage_fcontext_key_t ** key_ptr)
{

	if (semanage_fcontext_key_create(handle, fcontext->expr,
					 fcontext->type, key_ptr) < 0) {
		ERR(handle, "could not extract key from "
		    "file context %s (%s)", fcontext->expr,
		    semanage_fcontext_get_type_str(fcontext->type));
		return STATUS_ERR;
	}

	return STATUS_SUCCESS;
}