* sepgsql_fmgr_hook * * It switches security label of the client on execution of trusted * procedures. */
| 308 | * procedures. |
| 309 | */ |
| 310 | static void |
| 311 | sepgsql_fmgr_hook(FmgrHookEventType event, |
| 312 | FmgrInfo *flinfo, Datum *private) |
| 313 | { |
| 314 | struct |
| 315 | { |
| 316 | char *old_label; |
| 317 | char *new_label; |
| 318 | Datum next_private; |
| 319 | } *stack; |
| 320 | |
| 321 | switch (event) |
| 322 | { |
| 323 | case FHET_START: |
| 324 | stack = (void *) DatumGetPointer(*private); |
| 325 | if (!stack) |
| 326 | { |
| 327 | MemoryContext oldcxt; |
| 328 | |
| 329 | oldcxt = MemoryContextSwitchTo(flinfo->fn_mcxt); |
| 330 | stack = palloc(sizeof(*stack)); |
| 331 | stack->old_label = NULL; |
| 332 | stack->new_label = sepgsql_avc_trusted_proc(flinfo->fn_oid); |
| 333 | stack->next_private = 0; |
| 334 | |
| 335 | MemoryContextSwitchTo(oldcxt); |
| 336 | |
| 337 | /* |
| 338 | * process:transition permission between old and new label, |
| 339 | * when user tries to switch security label of the client on |
| 340 | * execution of trusted procedure. |
| 341 | * |
| 342 | * Also, db_procedure:entrypoint permission should be checked |
| 343 | * whether this procedure can perform as an entrypoint of the |
| 344 | * trusted procedure, or not. Note that db_procedure:execute |
| 345 | * permission shall be checked individually. |
| 346 | */ |
| 347 | if (stack->new_label) |
| 348 | { |
| 349 | ObjectAddress object; |
| 350 | |
| 351 | object.classId = ProcedureRelationId; |
| 352 | object.objectId = flinfo->fn_oid; |
| 353 | object.objectSubId = 0; |
| 354 | sepgsql_avc_check_perms(&object, |
| 355 | SEPG_CLASS_DB_PROCEDURE, |
| 356 | SEPG_DB_PROCEDURE__ENTRYPOINT, |
| 357 | getObjectDescription(&object, false), |
| 358 | true); |
| 359 | |
| 360 | sepgsql_avc_check_perms_label(stack->new_label, |
| 361 | SEPG_CLASS_PROCESS, |
| 362 | SEPG_PROCESS__TRANSITION, |
| 363 | NULL, true); |
| 364 | } |
| 365 | *private = PointerGetDatum(stack); |
| 366 | } |
| 367 | Assert(!stack->old_label); |
nothing calls this directly
no test coverage detected