Skip to content

Commit

Permalink
Handle errors in add_feed_role_permissions
Browse files Browse the repository at this point in the history
If there are error responses from the create_permission_internal calls,
they will now be handled by logging appropriate warning messages.

(cherry picked from commit adb51f6)
  • Loading branch information
timopollmeier authored and mergify-bot committed Jul 28, 2021
1 parent 5afdfc6 commit 09fb87a
Showing 1 changed file with 56 additions and 9 deletions.
65 changes: 56 additions & 9 deletions src/manage_sql.c
Original file line number Diff line number Diff line change
Expand Up @@ -44072,15 +44072,62 @@ add_feed_role_permissions (const char *type,
permission_name = g_strdup_printf ("get_%ss", type);

current_credentials.uuid = user_uuid (owner);
create_permission_internal (0,
permission_name,
"Automatically created by"
" --optimize",
type,
permission_resource_id,
"role",
*role,
NULL);
switch (create_permission_internal
(0,
permission_name,
"Automatically created by"
" --optimize",
type,
permission_resource_id,
"role",
*role,
NULL))
{
case 0:
// success
break;
case 2:
g_warning ("%s: failed to find role %s for permission",
__func__, *role);
break;
case 3:
g_warning ("%s: failed to find %s %s for permission",
__func__, type_cap, permission_resource_id);
break;
case 5:
g_warning ("%s: error in resource when creating permission"
" for %s %s",
__func__, type_cap, permission_resource_id);
break;
case 6:
g_warning ("%s: error in subject (Role %s)",
__func__, *role);
break;
case 7:
g_warning ("%s: error in name %s",
__func__, permission_name);
break;
case 8:
g_warning ("%s: permission on permission", __func__);
break;
case 9:
g_warning ("%s: permission %s does not accept resource",
__func__, permission_name);
break;
case 99:
g_warning ("%s: permission denied to create %s permission"
" for role %s on %s %s",
__func__, permission_name, *role, type_cap,
permission_resource_id);
break;
default:
g_warning ("%s: internal error creating %s permission"
" for role %s on %s %s",
__func__, permission_name, *role, type_cap,
permission_resource_id);
break;
}

free (current_credentials.uuid);
current_credentials.uuid = NULL;
}
Expand Down

0 comments on commit 09fb87a

Please sign in to comment.