* Change session auth ID while running * * Only a superuser may set auth ID to something other than himself. Note * that in case of multiple SETs in a single session, the original userid's * superuserness is what matters. But we set the GUC variable is_superuser * to indicate whether the *current* session userid is a superuser. * * Note: this is not an especially clean place to do the per
| 858 | * have to push it up into assign_session_authorization. |
| 859 | */ |
| 860 | void |
| 861 | SetSessionAuthorization(Oid userid, bool is_superuser) |
| 862 | { |
| 863 | /* Must have authenticated already, else can't make permission check */ |
| 864 | AssertState(OidIsValid(AuthenticatedUserId)); |
| 865 | |
| 866 | if (userid != AuthenticatedUserId && |
| 867 | !AuthenticatedUserIsSuperuser) |
| 868 | ereport(ERROR, |
| 869 | (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), |
| 870 | errmsg("permission denied to set session authorization"))); |
| 871 | |
| 872 | SetSessionUserId(userid, is_superuser); |
| 873 | |
| 874 | /* If resource scheduling enabled, set the cached queue for the new role.*/ |
| 875 | if ((Gp_role == GP_ROLE_DISPATCH || IS_SINGLENODE() || Gp_role == GP_ROLE_EXECUTE) && IsResQueueEnabled()) |
| 876 | { |
| 877 | SetResQueueId(); |
| 878 | } |
| 879 | |
| 880 | SetConfigOption("is_superuser", |
| 881 | is_superuser ? "on" : "off", |
| 882 | PGC_INTERNAL, PGC_S_OVERRIDE); |
| 883 | } |
| 884 | |
| 885 | /* |
| 886 | * Report current role id |
no test coverage detected