46 #define G_LOG_DOMAIN "md manage"
59 gchar *quoted_operation;
67 if (
sql_int (
"SELECT user_can_everything ('%s');",
82 g_free (quoted_operation);
97 gchar *quoted_role_id;
99 if (
sql_int (
" SELECT EXISTS (SELECT * FROM permissions"
100 " WHERE name = 'Super'"
102 " AND (resource = 0)"
103 " AND subject_location"
105 " AND (subject_type = 'role'"
109 " WHERE uuid = '%s')));",
112 g_free (quoted_role_id);
115 g_free (quoted_role_id);
132 if (
sql_int (
" SELECT EXISTS (SELECT * FROM permissions"
133 " WHERE name = 'Super'"
135 " AND (resource = 0)"
136 " AND subject_location"
138 " AND ((subject_type = 'user'"
140 " = (SELECT id FROM users"
141 " WHERE users.uuid = '%s'))"
142 " OR (subject_type = 'group'"
144 " IN (SELECT DISTINCT \"group\""
151 " OR (subject_type = 'role'"
153 " IN (SELECT DISTINCT role"
164 g_free (quoted_uuid);
167 g_free (quoted_uuid);
181 gchar *quoted_user_id;
185 ret =
sql_int (
"SELECT count(*) > 0 FROM permissions"
186 " WHERE resource = 0"
187 " AND subject_location"
189 " AND ((subject_type = 'user'"
191 " = (SELECT id FROM users"
192 " WHERE users.uuid = '%s'))"
193 " OR (subject_type = 'group'"
195 " IN (SELECT DISTINCT \"group\""
197 " WHERE \"user\" = (SELECT id"
201 " OR (subject_type = 'role'"
203 " IN (SELECT DISTINCT role"
205 " WHERE \"user\" = (SELECT id"
209 " AND name = 'Everything';",
213 g_free (quoted_user_id);
228 gchar *quoted_super_user_id;
230 quoted_super_user_id =
sql_quote (super_user_id);
231 if (
sql_int (
" SELECT EXISTS (SELECT * FROM permissions"
232 " WHERE name = 'Super'"
234 " AND ((resource = 0)"
236 " OR ((resource_type = 'user')"
237 " AND (resource = %llu))"
239 " OR ((resource_type = 'role')"
241 " IN (SELECT DISTINCT role"
243 " WHERE \"user\" = %llu)))"
245 " OR ((resource_type = 'group')"
247 " IN (SELECT DISTINCT \"group\""
249 " WHERE \"user\" = %llu))))"
250 " AND subject_location"
252 " AND ((subject_type = 'user'"
254 " = (SELECT id FROM users"
255 " WHERE users.uuid = '%s'))"
256 " OR (subject_type = 'group'"
258 " IN (SELECT DISTINCT \"group\""
265 " OR (subject_type = 'role'"
267 " IN (SELECT DISTINCT role"
281 g_free (quoted_super_user_id);
284 g_free (quoted_super_user_id);
302 ret =
sql_int (
"SELECT count (*) FROM role_users"
303 " WHERE role = (SELECT id FROM roles"
305 " AND \"user\" = (SELECT id FROM users WHERE uuid = '%s');",
307 g_free (quoted_uuid);
325 ret =
sql_int (
"SELECT count (*) FROM role_users"
326 " WHERE role = (SELECT id FROM roles"
328 " AND \"user\" = (SELECT id FROM users WHERE uuid = '%s');",
330 g_free (quoted_uuid);
348 ret =
sql_int (
"SELECT count (*) FROM role_users"
349 " WHERE role = (SELECT id FROM roles"
351 " AND \"user\" = (SELECT id FROM users WHERE uuid = '%s');",
353 g_free (quoted_uuid);
371 ret =
sql_int (
"SELECT count (*) FROM role_users"
372 " WHERE role = (SELECT id FROM roles"
374 " AND \"user\" = (SELECT id FROM users WHERE uuid = '%s');",
376 g_free (quoted_uuid);
385 #define ACL_SUPER_CLAUSE(format) \
388 " AND ((resource = 0)" \
390 " OR ((resource_type = 'user')" \
391 " AND (resource = (SELECT %ss%s.owner" \
393 " WHERE %s = " format ")))" \
395 " OR ((resource_type = 'role')" \
397 " IN (SELECT DISTINCT role" \
400 " = (SELECT %ss%s.owner" \
403 " = " format "))))" \
405 " OR ((resource_type = 'group')" \
407 " IN (SELECT DISTINCT \"group\"" \
408 " FROM group_users" \
410 " = (SELECT %ss%s.owner" \
412 " WHERE %s = " format ")))))" \
413 " AND subject_location = " G_STRINGIFY (LOCATION_TABLE) \
414 " AND ((subject_type = 'user'" \
416 " = (SELECT id FROM users" \
417 " WHERE users.uuid = '%s'))" \
418 " OR (subject_type = 'group'" \
420 " IN (SELECT DISTINCT \"group\"" \
421 " FROM group_users" \
425 " WHERE users.uuid" \
427 " OR (subject_type = 'role'" \
429 " IN (SELECT DISTINCT role" \
434 " WHERE users.uuid" \
446 #define ACL_SUPER_CLAUSE_ARGS(type, field, value, user_id, trash) \
448 trash ? (strcasecmp (type, "task") ? "_trash" : "") : "", \
450 trash ? (strcasecmp (type, "task") ? "_trash" : "") : "", \
454 trash ? (strcasecmp (type, "task") ? "_trash" : "") : "", \
456 trash ? (strcasecmp (type, "task") ? "_trash" : "") : "", \
460 trash ? (strcasecmp (type, "task") ? "_trash" : "") : "", \
462 trash ? (strcasecmp (type, "task") ? "_trash" : "") : "", \
485 if (
sql_int (
"SELECT EXISTS (SELECT * FROM permissions"
490 g_free (quoted_value);
493 g_free (quoted_value);
511 if (
sql_int (
"SELECT EXISTS (SELECT * FROM permissions"
537 assert (type && strcmp (type,
"result"));
539 if ((strcmp (type,
"nvt") == 0)
540 || (strcmp (type,
"cve") == 0)
541 || (strcmp (type,
"cpe") == 0)
542 || (strcmp (type,
"ovaldef") == 0)
543 || (strcmp (type,
"cert_bund_adv") == 0)
544 || (strcmp (type,
"dfn_cert_adv") == 0))
551 ret =
sql_int (
"SELECT count(*) FROM %ss"
553 " AND ((owner IS NULL)"
554 " OR (owner = (SELECT users.id FROM users"
555 " WHERE users.uuid = '%s')));",
559 g_free (quoted_value);
580 quoted_uuid = g_strdup (uuid);
581 ret =
sql_int (
"SELECT count(*) FROM %ss"
583 " AND owner = (SELECT users.id FROM users"
584 " WHERE users.uuid = '%s');",
588 g_free (quoted_uuid);
613 if ((strcmp (type,
"nvt") == 0)
614 || (strcmp (type,
"cve") == 0)
615 || (strcmp (type,
"cpe") == 0)
616 || (strcmp (type,
"ovaldef") == 0)
617 || (strcmp (type,
"cert_bund_adv") == 0)
618 || (strcmp (type,
"dfn_cert_adv") == 0))
625 if (strcmp (type,
"result") == 0)
626 ret =
sql_int (
"SELECT count(*) FROM results, reports"
627 " WHERE results.uuid = '%s'"
628 " AND results.report = reports.id"
629 " AND ((reports.owner IS NULL)"
630 " OR (reports.owner = (SELECT users.id FROM users"
631 " WHERE users.uuid = '%s')));",
635 ret =
sql_int (
"SELECT count(*) FROM %ss%s"
638 " AND ((owner IS NULL)"
639 " OR (owner = (SELECT users.id FROM users"
640 " WHERE users.uuid = '%s')));",
642 (strcmp (type,
"task") && trash) ?
"_trash" :
"",
644 (strcmp (type,
"task")
646 : (trash ?
" AND hidden = 2" :
" AND hidden < 2")),
648 g_free (quoted_uuid);
672 if ((strcmp (type,
"nvt") == 0)
673 || (strcmp (type,
"cve") == 0)
674 || (strcmp (type,
"cpe") == 0)
675 || (strcmp (type,
"ovaldef") == 0)
676 || (strcmp (type,
"cert_bund_adv") == 0)
677 || (strcmp (type,
"dfn_cert_adv") == 0))
683 if (strcmp (type,
"result") == 0)
684 ret =
sql_int (
"SELECT count(*) FROM results, reports"
685 " WHERE results.id = %llu"
686 " AND results.report = reports.id"
687 " AND ((reports.owner IS NULL)"
688 " OR (reports.owner = (SELECT users.id FROM users"
689 " WHERE users.uuid = '%s')));",
693 ret =
sql_int (
"SELECT count(*) FROM %ss%s"
696 " AND ((owner IS NULL)"
697 " OR (owner = (SELECT users.id FROM users"
698 " WHERE users.uuid = '%s')));",
700 (strcmp (type,
"task") && trash) ?
"_trash" :
"",
702 (strcmp (type,
"task")
704 : (trash ?
" AND hidden = 2" :
" AND hidden < 2")),
728 assert (type && strcmp (type,
"task"));
734 ret =
sql_int (
"SELECT count(*) FROM %ss_trash"
736 " AND ((owner IS NULL)"
737 " OR (owner = (SELECT users.id FROM users"
738 " WHERE users.uuid = '%s')));",
742 g_free (quoted_uuid);
759 const char *permission,
int trash)
763 gchar *quoted_permission, *quoted_uuid;
783 if (strcasecmp (type,
"report") == 0)
789 "SELECT id FROM reports WHERE uuid = '%s';",
795 g_free (quoted_uuid);
801 g_free (quoted_uuid);
809 g_free (quoted_uuid);
814 else if (strcasecmp (type,
"result") == 0)
819 "SELECT task FROM results WHERE uuid = '%s';",
825 g_free (quoted_uuid);
831 g_free (quoted_uuid);
841 if ((strcmp (type,
"permission") == 0)
842 && ((permission == NULL)
843 || (strlen (permission) > 3 && strncmp (permission,
"get", 3) == 0)))
845 ret =
sql_int (
"SELECT count(*) FROM permissions"
847 " WHERE (resource_uuid = '%s'"
851 " AND ((subject_type = 'user'"
853 " = (SELECT id FROM users"
854 " WHERE users.uuid = '%s'))"
855 " OR (subject_type = 'group'"
857 " IN (SELECT DISTINCT \"group\""
859 " WHERE \"user\" = (SELECT id"
863 " OR (subject_type = 'role'"
865 " IN (SELECT DISTINCT role"
867 " WHERE \"user\" = (SELECT id"
871 uuid_task ? uuid_task : quoted_uuid,
872 uuid_task ? uuid_task : quoted_uuid,
877 g_free (quoted_uuid);
880 else if (strcmp (type,
"permission") == 0)
886 g_free (quoted_uuid);
890 get = (permission == NULL
891 || (strlen (permission) > 3 && strncmp (permission,
"get", 3) == 0));
892 quoted_permission =
sql_quote (permission ? permission :
"");
894 ret =
sql_int (
"SELECT count(*) FROM permissions"
895 " WHERE resource_uuid = '%s'"
897 " AND ((subject_type = 'user'"
899 " = (SELECT id FROM users"
900 " WHERE users.uuid = '%s'))"
901 " OR (subject_type = 'group'"
903 " IN (SELECT DISTINCT \"group\""
905 " WHERE \"user\" = (SELECT id"
909 " OR (subject_type = 'role'"
911 " IN (SELECT DISTINCT role"
913 " WHERE \"user\" = (SELECT id"
918 uuid_task ? uuid_task : quoted_uuid,
922 (
get ?
"" :
"AND name = '"),
923 (
get ?
"" : quoted_permission),
927 g_free (quoted_permission);
928 g_free (quoted_uuid);
949 const char *type,
const get_data_t *
get,
int owned,
950 const gchar *owner_filter,
resource_t resource,
951 array_t *permissions)
957 gchar *permission_clause, *filter_owned_clause;
958 GString *permission_or;
959 int table_trash, permissions_include_get;
962 permissions_include_get = 0;
963 permission_or = g_string_new (
"");
965 if (permissions == NULL || permissions->len == 0)
968 permission_or = g_string_new (
"t ()");
970 permissions_include_get = 1;
972 else if (permissions)
973 for (; index < permissions->len; index++)
975 gchar *permission, *quoted;
976 permission = (gchar*) g_ptr_array_index (permissions, index);
977 if (strcasecmp (permission,
"any") == 0)
979 g_string_free (permission_or, TRUE);
980 permission_or = g_string_new (
"t ()");
982 permissions_include_get = 1;
985 if (g_str_has_prefix (permission,
"get_"))
986 permissions_include_get = 1;
989 g_string_append_printf (permission_or,
"name = '%s'", quoted);
991 g_string_append_printf (permission_or,
" OR name = '%s'",
996 permissions_include_get = 1;
1000 permission_clause = NULL;
1001 if (user_id && index)
1005 = g_strdup_printf (
"OR EXISTS"
1006 " (SELECT id FROM permissions"
1007 " WHERE resource = %ss%s.id"
1008 " AND resource_type = '%s'"
1009 " AND resource_location = %i"
1010 " AND subject_location"
1012 " AND ((subject_type = 'user'"
1015 " OR (subject_type = 'group'"
1017 " IN (SELECT DISTINCT \"group\""
1021 " OR (subject_type = 'role'"
1023 " IN (SELECT DISTINCT role"
1029 get->trash && strcmp (type,
"task") ?
"_trash" :
"",
1035 permission_or->str);
1037 if (strcmp (type,
"report") == 0)
1039 = g_strdup_printf (
"%s"
1041 " (SELECT id FROM permissions"
1042 " WHERE resource = reports%s.task"
1043 " AND resource_type = 'task'"
1044 " AND subject_location"
1045 " = " G_STRINGIFY (LOCATION_TABLE)
1046 " AND ((subject_type = 'user'"
1049 " OR (subject_type = 'group'"
1051 " IN (SELECT DISTINCT \"group\""
1055 " OR (subject_type = 'role'"
1057 " IN (SELECT DISTINCT role"
1063 get->trash ?
"_trash" :
"",
1067 permission_or->str);
1068 else if (strcmp (type,
"result") == 0)
1070 = g_strdup_printf (
"%s"
1072 " (SELECT id FROM permissions"
1073 " WHERE resource = results%s.task"
1074 " AND resource_type = 'task'"
1075 " AND subject_location"
1076 " = " G_STRINGIFY (LOCATION_TABLE)
1077 " AND ((subject_type = 'user'"
1080 " OR (subject_type = 'group'"
1082 " IN (SELECT DISTINCT \"group\""
1086 " OR (subject_type = 'role'"
1088 " IN (SELECT DISTINCT role"
1094 get->trash ?
"_trash" :
"",
1098 permission_or->str);
1100 if ((strcmp (type,
"report") == 0)
1101 || (strcmp (type,
"result") == 0))
1104 permission_clause = clause;
1107 g_string_free (permission_or, TRUE);
1109 table_trash =
get->trash && strcasecmp (type,
"task");
1110 if (resource || (user_id == NULL))
1112 = g_strdup (
" (t ())");
1113 else if (strcmp (type,
"permission") == 0)
1116 assert (strcmp (user_id,
""));
1122 " ((permissions%s.owner = (%s))"
1127 " AND (permissions%s.subject_type = 'user'"
1128 " AND permissions%s.subject_location"
1130 " AND permissions%s.subject"
1134 " AND (permissions%s.subject_type = 'group'"
1135 " AND permissions%s.subject_location"
1137 " AND permissions%s.subject"
1138 " IN (SELECT DISTINCT \"group\""
1140 " WHERE \"user\" = (%s))))"
1143 " AND (permissions%s.subject_type = 'role'"
1144 " AND permissions%s.subject_location"
1146 " AND permissions%s.subject"
1147 " IN (SELECT DISTINCT role"
1149 " WHERE \"user\" = (%s))))"
1151 " OR EXISTS (SELECT * FROM permissions AS inside"
1152 " WHERE name = 'Super'"
1154 " AND ((inside.resource = 0)"
1156 " OR ((inside.resource_type = 'user')"
1157 " AND (inside.resource = permissions%s.owner))"
1159 " OR ((inside.resource_type = 'role')"
1160 " AND (inside.resource"
1161 " IN (SELECT DISTINCT role"
1164 " = permissions%s.owner)))"
1166 " OR ((inside.resource_type = 'group')"
1167 " AND (inside.resource"
1168 " IN (SELECT DISTINCT \"group\""
1171 " = permissions%s.owner))))"
1172 " AND subject_location"
1174 " AND ((inside.subject_type = 'user'"
1175 " AND inside.subject"
1177 " OR (inside.subject_type = 'group'"
1178 " AND inside.subject"
1179 " IN (SELECT DISTINCT \"group\""
1183 " OR (inside.subject_type = 'role'"
1184 " AND inside.subject"
1185 " IN (SELECT DISTINCT role"
1190 get->trash ?
"_trash" :
"",
1194 ?
"OR (permissions_trash.owner IS NULL)"
1195 :
"OR (permissions.owner IS NULL)")
1198 table_trash ?
"_trash" :
"",
1199 table_trash ?
"_trash" :
"",
1200 table_trash ?
"_trash" :
"",
1203 table_trash ?
"_trash" :
"",
1204 table_trash ?
"_trash" :
"",
1205 table_trash ?
"_trash" :
"",
1208 table_trash ?
"_trash" :
"",
1209 table_trash ?
"_trash" :
"",
1210 table_trash ?
"_trash" :
"",
1212 table_trash ?
"_trash" :
"",
1213 table_trash ?
"_trash" :
"",
1214 table_trash ?
"_trash" :
"",
1218 permission_clause ? permission_clause :
"");
1234 " OR EXISTS (SELECT * FROM permissions"
1235 " WHERE name = 'Super'"
1237 " AND ((resource = 0)"
1239 " OR ((resource_type = 'user')"
1240 " AND (resource = %ss%s.owner))"
1242 " OR ((resource_type = 'role')"
1244 " IN (SELECT DISTINCT role"
1249 " OR ((resource_type = 'group')"
1251 " IN (SELECT DISTINCT \"group\""
1254 " = %ss%s.owner))))"
1255 " AND subject_location"
1257 " AND ((subject_type = 'user'"
1260 " OR (subject_type = 'group'"
1262 " IN (SELECT DISTINCT \"group\""
1266 " OR (subject_type = 'role'"
1268 " IN (SELECT DISTINCT role"
1273 permissions_include_get ?
"(" :
"",
1274 permissions_include_get ? type :
"",
1275 permissions_include_get ?
"s" :
"",
1276 permissions_include_get && table_trash
1279 permissions_include_get ?
".owner IS NULL)" :
"",
1280 permissions_include_get ?
"OR" :
"",
1282 table_trash ?
"_trash" :
"",
1285 table_trash ?
"_trash" :
"",
1287 table_trash ?
"_trash" :
"",
1289 table_trash ?
"_trash" :
"",
1293 permission_clause ? permission_clause :
"");
1295 g_free (permission_clause);
1297 if (get->trash && (strcasecmp (type,
"task") == 0))
1300 new = g_strdup_printf (
" (%ss.hidden = 2"
1304 g_free (owned_clause);
1308 if (owner_filter == NULL
1309 || (owner_filter && (strcmp (owner_filter,
"any") == 0)))
1310 filter_owned_clause = g_strdup (owned_clause);
1311 else if (owner_filter && strcmp (owner_filter,
""))
1315 filter_owned_clause = g_strdup_printf (
"(owner = (SELECT id"
1317 " WHERE name = '%s')"
1324 filter_owned_clause = g_strdup_printf (
"((owner = (%s)"
1325 " OR owner IS NULL)"
1330 g_free (owned_clause);
1331 owned_clause = filter_owned_clause;
1334 owned_clause = g_strdup (
" t ()");
1336 return owned_clause;
1353 const gchar *owner_filter,
resource_t resource,
1354 array_t *permissions)
1356 gchar *ret, *user_sql;
1358 user_sql = g_strdup_printf (
"SELECT id FROM users WHERE users.uuid = '%s'",
1363 owned, owner_filter, resource, permissions);
1380 gchar *owned_clause;
1382 array_t *permissions;
1383 gchar *user_sql_new;
1386 user_sql_new = g_strdup (user_sql);
1388 user_sql_new = g_strdup_printf (
"SELECT id FROM users WHERE users.uuid = '%s'",
1391 user_sql_new = NULL;
1394 permissions = make_array ();
1395 array_add (permissions, g_strdup_printf (
"get_%ss", type));
1407 array_free (permissions);
1408 g_free (user_sql_new);
1410 return owned_clause;
1425 const char *users_where)
1427 GString *users_string;
1428 int users_count = 0;
1429 gchar *old_user_id, *command;
1433 init_iterator (&users,
"SELECT id, uuid FROM users WHERE %s;",
1434 users_where ? users_where :
"t()");
1436 users_string = g_string_new (
"(VALUES ");
1438 command = g_strdup_printf (
"get_%ss", type);
1440 while (
next (&users))
1447 g_string_append (users_string,
1450 g_string_append_printf (users_string,
1457 g_string_append(users_string,
")");
1465 if (users_count == 0)
1467 g_string_free (users_string, TRUE);
1471 return g_string_free (users_string, FALSE);
1488 const char *users_where,
const char* user_expr)
1490 gchar *values, *ret;
1494 ret = g_strdup_printf (
"%s IN %s", user_expr, values);
1496 ret = g_strdup (
"NOT t()");
int acl_user_is_user(const char *uuid)
Check whether a user has the User role.
#define LOCATION_TRASH
Location of a constituent of a trashcan resource.
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 sql_int(char *sql,...)
Get a particular cell from a SQL query, as an int.
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.
int sql_int64(long long int *ret, char *sql,...)
Get a particular cell from a SQL query, as an int64.
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 task_uuid(task_t, char **)
Return the UUID of a task.
gboolean report_task(report_t, task_t *)
Return the task of a report.
int acl_user_owns_trash_uuid(const char *type, const char *uuid)
Test whether a user effectively owns a resource.
#define ROLE_UUID_USER
Predefined role UUID.
#define ROLE_UUID_SUPER_ADMIN
Predefined role UUID.
#define ACL_SUPER_CLAUSE(format)
Super clause.
gchar * sql_quote(const char *string)
Quotes a string to be passed to sql statements.
Command data for a get command.
#define ROLE_UUID_OBSERVER
Predefined role UUID.
int acl_user_is_observer(const char *uuid)
Check whether a user is an Observer.
void manage_session_init(const char *uuid)
Setup session.
int acl_user_has_super_on(const char *type, const char *field, const char *value, int trash)
Test whether a user has Super permission on a resource.
int acl_user_can_everything(const char *user_id)
Test whether a user may perform any operation.
int acl_user_has_super_on_resource(const char *type, const char *field, resource_t resource, int trash)
Test whether a user has Super permission on a resource.
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 valid_omp_command(const char *name)
Check whether a command name is valid.
#define ACL_USER_MAY(resource)
Generate SQL for user permission check.
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.
void cleanup_iterator(iterator_t *)
Cleanup an iterator.
int acl_user_may(const char *operation)
Test whether a user may perform an operation.
credentials_t current_credentials
Current credentials during any OMP command.
const char * iterator_string(iterator_t *iterator, int col)
Get a string column from an iterator.
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 user_is_super_admin(const char *)
Check whether a user is a Super Admin.
#define ROLE_UUID_ADMIN
Predefined role UUID.
#define ACL_SUPER_CLAUSE_ARGS(type, field, value, user_id, trash)
Super clause arguments.
gboolean next(iterator_t *)
Increment an iterator.
#define LOCATION_TABLE
Location of a constituent of a trashcan resource.
void init_iterator(iterator_t *iterator, const char *sql,...)
Initialise an iterator.
long long int iterator_int64(iterator_t *iterator, int col)
Get an integer column from an iterator.
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.