Re: Granting SET and ALTER SYSTE privileges for GUCs - Mailing list pgsql-hackers
From | Joshua Brindle |
---|---|
Subject | Re: Granting SET and ALTER SYSTE privileges for GUCs |
Date | |
Msg-id | CAGB+Vh58bbGZy1Pf4FHctqw-eSjQM_1wv66wX_WzJ1VaF7brEQ@mail.gmail.com Whole thread Raw |
In response to | Re: Granting SET and ALTER SYSTE privileges for GUCs (Robert Haas <robertmhaas@gmail.com>) |
Responses |
Re: Granting SET and ALTER SYSTE privileges for GUCs
Re: Granting SET and ALTER SYSTE privileges for GUCs |
List | pgsql-hackers |
On Thu, Mar 17, 2022 at 12:04 PM Robert Haas <robertmhaas@gmail.com> wrote: > > On Thu, Mar 17, 2022 at 9:25 AM Joshua Brindle > <joshua.brindle@crunchydata.com> wrote: > > <snip> > > > > > I remain of the opinion that this > > > patch should not concern itself with that, though. > > > > So you are saying that people can add new object types to PG with DAC > > permissions and not concern themselves with MAC capable hooks? Is that > > an official PG community stance? > > I don't know that the community has an official position on that > topic, but I do not think it's reasonable to expect everyone who > tinkers with MAC permissions to try to make a corresponding equivalent > for DAC. The number of people using PostgreSQL with DAC is relatively > small, and the topic is extremely complicated, and a lot of hackers > don't really understand it well enough to be sure that whatever they > might do is right. I think it's reasonable to expect people who > understand DAC and care about it to put some energy into the topic, > and not just in terms of telling other people how they have to write > their patches. > > I *don't* think it's appropriate for a patch that touches MAC to > deliberately sabotage the existing support we have for DAC or to just > ignore it where the right thing to do is obvious. But maintaining a > million lines of code is a lot of work, and I can't think of any > reason why the burden of maintaining relatively little-used features > should fall entirely on people who don't care about them. I agree with this view, outside of the mixup between MAC and DAC (DAC is in-core, MAC is via hooks) So there should be some committers or contributors that keep an eye out and make sure new objects have appropriate hooks, and since an Oid based hook for GUCs is inappropriate, I hope this patch can be rolled into the contribution from Mark. The attached patch adds a set of hooks for strings, and changes the GUC patch from Mark to use it, I tested with this code: void set_user_object_access_str(ObjectAccessType access, Oid classId, const char *objName, int subId, void *arg) { if (next_object_access_hook_str) { (*next_object_access_hook_str)(access, classId, objName, subId, arg); } switch (access) { case OAT_POST_ALTER: if (classId == SettingAclRelationId) { Oid userid = GetUserId(); bool is_superuser = superuser_arg(userid); char *username = GETUSERNAMEFROMID(GetUserId()); const char *setting = "setting value"; const char *altering = "altering system"; const char *unknown = "unknown"; const char *action; if (subId && ACL_SET_VALUE) action = setting; else if (subId && ACL_ALTER_SYSTEM) action = altering; else action = unknown; elog(WARNING, "%s is %s %s (%d)", username, action, objName, is_superuser); if (strcmp(objName, "log_statement") == 0) { ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), errmsg("Setting %s blocked", objName))); } } default: break; } } static void set_user_object_access (ObjectAccessType access, Oid classId, Oid objectId, int subId, void *arg) { if (next_object_access_hook) { (*next_object_access_hook)(access, classId, objectId, subId, arg); } switch (access) { case OAT_FUNCTION_EXECUTE: { /* Update the `set_config` Oid cache if necessary. */ set_user_cache_proc(InvalidOid); /* Now see if this function is blocked */ set_user_block_set_config(objectId); break; } /* fallthrough */ case OAT_POST_CREATE: { if (classId == ProcedureRelationId) { set_user_cache_proc(objectId); } break; } default: break; } }
Attachment
pgsql-hackers by date: