Can not ALTER TEXT SEARCH DICTIONARY intdict which is default in dict_int

Started by Li EF Zhangover 4 years ago7 messagesgeneral
Jump to latest
#1Li EF Zhang
bjzhangl@cn.ibm.com

<div class="socmaildefaultfont" dir="ltr" style="font-family:Arial, Helvetica, sans-serif;font-size:10pt" ><div dir="ltr" >Hi,</div>
<div dir="ltr" >&nbsp;</div>
<div dir="ltr" >dict_int is trusted extension in pg13. After creating dict_int extension with unprivileged user, ALTER TEXT SEARCH DICTIONARY intdict ((MAXLEN = 7) failed.</div>
<div dir="ltr" >&nbsp;</div>
<div dir="ltr" >admin=&gt; ALTER TEXT SEARCH DICTIONARY intdict (MAXLEN = 7);<br>ERROR:&nbsp; must be owner of text search dictionary intdict</div>
<div dir="ltr" >&nbsp;</div>
<div dir="ltr" >This is by design or a bug? Thanks!</div>
<div dir="ltr" >&nbsp;</div>
<div dir="ltr" >Lily</div></div><BR>
<BR>

#2Laurenz Albe
laurenz.albe@cybertec.at
In reply to: Li EF Zhang (#1)
Re: Can not ALTER TEXT SEARCH DICTIONARY intdict which is default in dict_int

On Tue, 2021-08-24 at 06:21 +0000, Li EF Zhang wrote:

dict_int is trusted extension in pg13. After creating dict_int extension with
unprivileged user, ALTER TEXT SEARCH DICTIONARY intdict ((MAXLEN = 7) failed.
 
admin=> ALTER TEXT SEARCH DICTIONARY intdict (MAXLEN = 7);
ERROR:  must be owner of text search dictionary intdict
 
This is by design or a bug? Thanks!

You must be the owner of an object to ALTER it. That is working as designed.

It is a bad idea to ALTER an object that belongs to an extension.
The next ALTER EXTENSION ... UPDATE may undo the change or fail.

Create your own dictionary with the same template.

Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com

#3Li EF Zhang
bjzhangl@cn.ibm.com
In reply to: Laurenz Albe (#2)
RE: Can not ALTER TEXT SEARCH DICTIONARY intdict which is default in dict_int

<div class="socmaildefaultfont" dir="ltr" style="font-family:Arial, Helvetica, sans-serif;font-size:10pt" ><div dir="ltr" >Thanks for your answer. My doubt is that since an ordinary user creates the extension, shouldn't be this user the owner of the objects created within the extension?</div>
<div dir="ltr" >&nbsp;</div>
<blockquote data-history-content-modified="1" dir="ltr" style="border-left:solid #aaaaaa 2px; margin-left:5px; padding-left:5px; direction:ltr; margin-right:0px" >----- Original message -----<br>From: "Laurenz Albe" &lt;laurenz.albe@cybertec.at&gt;<br>To: "Li EF Zhang" &lt;bjzhangl@cn.ibm.com&gt;, pgsql-general@lists.postgresql.org<br>Cc:<br>Subject: [EXTERNAL] Re: Can not ALTER TEXT SEARCH DICTIONARY intdict which is default in dict_int<br>Date: Tue, Aug 24, 2021 6:23 PM<br>&nbsp;
<div><font size="2" face="Default Monospace,Courier New,Courier,monospace" >On Tue, 2021-08-24 at 06:21 +0000, Li EF Zhang wrote:<br>&gt; dict_int is trusted extension in pg13. After creating dict_int extension with<br>&gt; unprivileged user, ALTER TEXT SEARCH DICTIONARY intdict ((MAXLEN = 7) failed.<br>&gt; &nbsp;<br>&gt; admin=&gt; ALTER TEXT SEARCH DICTIONARY intdict (MAXLEN = 7);<br>&gt; ERROR:&nbsp; must be owner of text search dictionary intdict<br>&gt; &nbsp;<br>&gt; This is by design or a bug? Thanks!<br><br>You must be the owner of an object to ALTER it. &nbsp;That is working as designed.<br><br>It is a bad idea to ALTER an object that belongs to an extension.<br>The next ALTER EXTENSION ... UPDATE may undo the change or fail.<br><br>Create your own dictionary with the same template.<br><br>Yours,<br>Laurenz Albe<br>--<br>Cybertec | <a href="https://www.cybertec-postgresql.com&quot; target="_blank">https://www.cybertec-postgresql.com&lt;/a&gt;&amp;nbsp;&lt;/font&gt;&lt;br&gt;&amp;nbsp;&lt;/div&gt;&lt;/blockquote&gt;
<div dir="ltr" >&nbsp;</div></div><BR>
<BR>

#4David G. Johnston
david.g.johnston@gmail.com
In reply to: Li EF Zhang (#3)
Re: Can not ALTER TEXT SEARCH DICTIONARY intdict which is default in dict_int

On Tue, Aug 24, 2021 at 8:51 PM Li EF Zhang <bjzhangl@cn.ibm.com> wrote:

Thanks for your answer. My doubt is that since an ordinary user creates
the extension, shouldn't be this user the owner of the objects created
within the extension?

While that is a possible implementation choice, that isn't what was chosen.

https://www.postgresql.org/docs/current/sql-createextension.html

"This configuration gives the calling user the right to drop the extension,
but not to modify individual objects within it."

"trust" just solves the "lets not require an actual superuser to install a
superuser requiring extension" problem, if that extension is deemed safe to
use in that manner by its author.

David J.

#5Tom Lane
tgl@sss.pgh.pa.us
In reply to: David G. Johnston (#4)
Re: Can not ALTER TEXT SEARCH DICTIONARY intdict which is default in dict_int

"David G. Johnston" <david.g.johnston@gmail.com> writes:

On Tue, Aug 24, 2021 at 8:51 PM Li EF Zhang <bjzhangl@cn.ibm.com> wrote:

Thanks for your answer. My doubt is that since an ordinary user creates
the extension, shouldn't be this user the owner of the objects created
within the extension?

While that is a possible implementation choice, that isn't what was chosen.

Let's be clear here: that is not some random implementor's decision.
That is *necessary*, else the feature is completely insecure.

The example given at the top of the thread isn't especially
security-relevant, but there are a lot of other possible ALTER commands
that are. For example, an ordinary user granted ownership of a
"C"-language function can easily modify it in a way that allows her to
gain full control of the installation. So we cannot implement trusted
extensions by allowing the user requesting the install to own the
individual objects within the extension.

regards, tom lane

#6David G. Johnston
david.g.johnston@gmail.com
In reply to: Tom Lane (#5)
Re: Can not ALTER TEXT SEARCH DICTIONARY intdict which is default in dict_int

On Tue, Aug 24, 2021 at 9:20 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:

"David G. Johnston" <david.g.johnston@gmail.com> writes:

On Tue, Aug 24, 2021 at 8:51 PM Li EF Zhang <bjzhangl@cn.ibm.com> wrote:

Thanks for your answer. My doubt is that since an ordinary user creates
the extension, shouldn't be this user the owner of the objects created
within the extension?

While that is a possible implementation choice, that isn't what was

chosen.

Let's be clear here: that is not some random implementor's decision.
That is *necessary*, else the feature is completely insecure.

Fair. Additionally, an extension that wishes for ordinary users to perform
limited configuration can always supply a security definer function to
facilitate such a change. Though I'm unsure how/if it would go about
arranging role permissions without requiring a superuser.

David J.

#7Li EF Zhang
bjzhangl@cn.ibm.com
In reply to: David G. Johnston (#6)
RE: Can not ALTER TEXT SEARCH DICTIONARY intdict which is default in dict_int

<div class="socmaildefaultfont" dir="ltr" style="font-family:Arial, Helvetica, sans-serif;font-size:10pt" ><div dir="ltr" >Got it! Thank you all very much!</div>
<div dir="ltr" >&nbsp;</div>
<blockquote data-history-content-modified="1" dir="ltr" style="border-left:solid #aaaaaa 2px; margin-left:5px; padding-left:5px; direction:ltr; margin-right:0px" >----- Original message -----<br>From: "David G. Johnston" &lt;david.g.johnston@gmail.com&gt;<br>To: "Tom Lane" &lt;tgl@sss.pgh.pa.us&gt;<br>Cc: "Li EF Zhang" &lt;bjzhangl@cn.ibm.com&gt;, "Laurenz Albe" &lt;laurenz.albe@cybertec.at&gt;, "pgsql-generallists.postgresql.org" &lt;pgsql-general@lists.postgresql.org&gt;<br>Subject: [EXTERNAL] Re: Can not ALTER TEXT SEARCH DICTIONARY intdict which is default in dict_int<br>Date: Wed, Aug 25, 2021 1:29 PM<br>&nbsp;<br>
<div dir="ltr" ><div dir="ltr" ><div style="font-family:arial,helvetica,sans-serif" ><span style="font-family:Arial,Helvetica,sans-serif" >On Tue, Aug 24, 2021 at 9:20 PM Tom Lane &lt;<a href="mailto:tgl@sss.pgh.pa.us" target="_blank" >tgl@sss.pgh.pa.us</a>&gt; wrote:</span></div></div>
<div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" >"David G. Johnston" &lt;<a href="mailto:david.g.johnston@gmail.com" target="_blank" >david.g.johnston@gmail.com</a>&gt; writes:<br>&gt; On Tue, Aug 24, 2021 at 8:51 PM Li EF Zhang &lt;<a href="mailto:bjzhangl@cn.ibm.com" target="_blank" >bjzhangl@cn.ibm.com</a>&gt; wrote:<br>&gt;&gt; Thanks for your answer. My doubt is that since an ordinary user creates<br>&gt;&gt; the extension, shouldn't be this user the owner of the objects created<br>&gt;&gt; within the extension?<br><br>&gt; While that is a possible implementation choice, that isn't what was chosen.<br><br>Let's be clear here: that is not some random implementor's decision.<br>That is *necessary*, else the feature is completely insecure.<br>&nbsp;</blockquote>
<div>&nbsp;</div>
<div style="font-family:arial,helvetica,sans-serif" >Fair.&nbsp; Additionally, an extension that wishes for ordinary users to perform limited configuration can always supply a security definer function to facilitate such a change.&nbsp; Though I'm unsure how/if it would go about arranging role permissions without requiring a superuser.</div>
<div style="font-family:arial,helvetica,sans-serif" >&nbsp;</div>
<div style="font-family:arial,helvetica,sans-serif" >David J.</div>
<div style="font-family:arial,helvetica,sans-serif" >&nbsp;</div></div></div></blockquote>
<div dir="ltr" >&nbsp;</div></div><BR>
<BR>