26 #ifndef OPENVAS_MANAGER_MANAGE_ACL_H
27 #define OPENVAS_MANAGER_MANAGE_ACL_H
37 #define ACL_USER_MAY(resource) \
38 "SELECT count(*) > 0 FROM permissions" \
39 " WHERE resource = " resource \
40 " AND subject_location = " G_STRINGIFY (LOCATION_TABLE) \
41 " AND ((subject_type = 'user'" \
43 " = (SELECT id FROM users" \
44 " WHERE users.uuid = '%s'))" \
45 " OR (subject_type = 'group'" \
47 " IN (SELECT DISTINCT \"group\"" \
49 " WHERE \"user\" = (SELECT id" \
53 " OR (subject_type = 'role'" \
55 " IN (SELECT DISTINCT role" \
57 " WHERE \"user\" = (SELECT id" \
62 " AND ((lower (substr ('%s', 1, 3)) = 'get'" \
63 " AND name LIKE '%%'" \
64 " || lower (substr ('%s'," \
66 " length ('%s') - 5)))" \
67 " OR name = lower ('%s'))"
74 #define ACL_IS_GLOBAL() \
85 #define ACL_USER_OWNS() \
86 " ((" ACL_IS_GLOBAL () ")" \
87 " OR (owner = (SELECT users.id FROM users" \
88 " WHERE users.uuid = '%s')))"
int acl_user_is_user(const char *uuid)
Check whether a user has the User role.
int acl_user_is_owner(const char *type, const char *uuid)
Test whether a user is the actual owner of a resource.
int acl_user_owns_name(const char *type, const char *value)
Test whether a user effectively owns a resource.
int acl_user_owns_uuid(const char *type, const char *uuid, int trash)
Test whether a user effectively owns a resource.
int acl_user_has_super(const char *super_user_id, user_t other_user)
Test whether a user has super permission on another user.
int acl_role_can_super_everyone(const char *role_id)
Check whether a role has Super Admin capability.
int acl_user_has_access_uuid(const char *type, const char *uuid, const char *permission, int trash)
Test whether the user may access a resource.
gchar * acl_where_owned_for_get(const char *type, const char *user_sql)
Generate ownership part of WHERE, for getting a type of resource.
int acl_user_owns_trash_uuid(const char *type, const char *uuid)
Test whether a user effectively owns a resource.
Command data for a get command.
int acl_user_is_observer(const char *uuid)
Check whether a user is an Observer.
int acl_user_can_everything(const char *user_id)
Test whether a user may perform any operation.
gchar * acl_where_owned_user(const char *user_id, const char *user_sql, const char *type, const get_data_t *get, int owned, const gchar *owner_filter, resource_t resource, array_t *permissions)
Generate the ownership part of an SQL WHERE clause for a given user.
int acl_user_is_admin(const char *uuid)
Check whether a user is an Admin.
gchar * acl_where_owned(const char *type, const get_data_t *get, int owned, const gchar *owner_filter, resource_t resource, array_t *permissions)
Generate the ownership part of an SQL WHERE clause.
int acl_user_may(const char *operation)
Test whether a user may perform an operation.
gchar * acl_users_with_access_where(const char *type, const char *resource_id, const char *users_where, const char *user_expr)
Get a static SQL condition selecting users that can get a resource.
int acl_user_can_super_everyone(const char *uuid)
Check whether a user is a Super Admin.
int acl_user_is_super_admin(const char *)
int acl_user_owns(const char *type, resource_t resource, int trash)
Test whether a user effectively owns a resource.
long long int resource_t
A resource, like a task or target.
gchar * acl_users_with_access_sql(const char *type, const char *resource_id, const char *users_where)
Get an SQL values expression of users that can get a resource.