Simon Riggs <simon@2ndQuadrant.com> writes:
> It looks to me like the correct fix would be to use
> GetUserIdAndContext() instead, though I would suggest inventing
> GetUserIdIfAny() which would skip the assertion test for use in
> superuser().
You are thinking at the wrong abstraction level. Even to ask if
the user is superuser is inappropriate in the postmaster, since
there is no user. So I think the bug is that GetConfigOption
is calling superuser() when it is now possible for it to be used
in the postmaster.
The quick & dirty fix would be to add IsUnderPostmaster to the
check in GetConfigOption. Or we could refactor things so that
the GUC_SUPERUSER_ONLY check is applied at some higher level;
but that's probably more work than it's worth.
It looks to me like the pstrdup that was added in guc-file.l
represents a permanent memory leak in the postmaster, too :-(
regards, tom lane