@@ -43,15 +43,13 @@ ____________________________________________________________________________-->
43
43
CREATE EXTENSION [ IF NOT EXISTS ] <replaceable class="parameter">extension_name</replaceable>
44
44
[ WITH ] [ SCHEMA <replaceable class="parameter">schema_name</replaceable> ]
45
45
[ VERSION <replaceable class="parameter">version</replaceable> ]
46
- [ FROM <replaceable class="parameter">old_version</replaceable> ]
47
46
[ CASCADE ]
48
47
</synopsis>
49
48
____________________________________________________________________________-->
50
49
<synopsis>
51
50
CREATE EXTENSION [ IF NOT EXISTS ] <replaceable class="parameter">extension_name</replaceable>
52
51
[ WITH ] [ SCHEMA <replaceable class="parameter">schema_name</replaceable> ]
53
52
[ VERSION <replaceable class="parameter">version</replaceable> ]
54
- [ FROM <replaceable class="parameter">old_version</replaceable> ]
55
53
[ CASCADE ]
56
54
</synopsis>
57
55
</refsynopsisdiv>
@@ -93,19 +91,37 @@ ____________________________________________________________________________-->
93
91
94
92
<!--==========================orignal english content==========================
95
93
<para>
96
- Loading an extension requires the same privileges that would be
97
- required to create its component objects. For most extensions this
98
- means superuser or database owner privileges are needed.
99
94
The user who runs <command>CREATE EXTENSION</command> becomes the
100
- owner of the extension for purposes of later privilege checks, as well
101
- as the owner of any objects created by the extension's script.
95
+ owner of the extension for purposes of later privilege checks, and
96
+ normally also becomes the owner of any objects created by the
97
+ extension's script.
102
98
</para>
103
99
____________________________________________________________________________-->
104
100
<para>
105
- 载入一个扩展要求创建其组件对象所要求的特权。对于大部分扩展这意味
106
- 这需要超级用户或者数据库拥有者的特权。为了以后特权检察的目的,运行
107
- <command>CREATE EXTENSION</command>的用户会成为该扩展的
108
- 拥有者以及由该扩展的脚本创建的任何对象的拥有者。
101
+ 运行<command>CREATE EXTENSION</command>的用户成为扩展的所有者,
102
+ 以进行以后的特权检查,并且通常也成为由扩展的脚本创建的任何对象的所有者。
103
+ </para>
104
+ <!--==========================orignal english content==========================
105
+ <para>
106
+ Loading an extension ordinarily requires the same privileges that would
107
+ be required to create its component objects. For many extensions this
108
+ means superuser privileges are needed.
109
+ However, if the extension is marked <firstterm>trusted</firstterm> in
110
+ its control file, then it can be installed by any user who has
111
+ <literal>CREATE</literal> privilege on the current database.
112
+ In this case the extension object itself will be owned by the calling
113
+ user, but the contained objects will be owned by the bootstrap superuser
114
+ (unless the extension's script explicitly assigns them to the calling
115
+ user). This configuration gives the calling user the right to drop the
116
+ extension, but not to modify individual objects within it.
117
+ </para>
118
+ ____________________________________________________________________________-->
119
+ <para>
120
+ 通常,加载扩展需要与创建扩展组件对象所需的特权相同的特权。 对于许多扩展,这意味着需要超级用户特权。
121
+ 但是,如果扩展名在其控制文件中标记为<firstterm>trusted</firstterm>,则该扩展名可以由对当前
122
+ 数据库具有<literal>CREATE</literal>特权的任何用户安装。
123
+ 在这种情况下,扩展对象本身将由主叫用户拥有,但是包含的对象将由引导超级用户拥有(除非扩展的脚本将其明确分配给主叫用户)。
124
+ 此配置使呼叫用户有权删除该扩展名,但不能修改其中的单个对象。
109
125
</para>
110
126
111
127
</refsect1>
@@ -245,59 +261,6 @@ ____________________________________________________________________________-->
245
261
</listitem>
246
262
</varlistentry>
247
263
248
- <varlistentry>
249
- <!--==========================orignal english content==========================
250
- <term><replaceable class="parameter">old_version</replaceable></term>
251
- ____________________________________________________________________________-->
252
- <term><replaceable class="parameter">old_version</replaceable></term>
253
- <listitem>
254
- <!--==========================orignal english content==========================
255
- <para>
256
- <literal>FROM</literal> <replaceable class="parameter">old_version</replaceable>
257
- must be specified when, and only when, you are attempting to install
258
- an extension that replaces an <quote>old style</quote> module that is just
259
- a collection of objects not packaged into an extension. This option
260
- causes <command>CREATE EXTENSION</command> to run an alternative installation
261
- script that absorbs the existing objects into the extension, instead
262
- of creating new objects. Be careful that <literal>SCHEMA</literal> specifies
263
- the schema containing these pre-existing objects.
264
- </para>
265
- ____________________________________________________________________________-->
266
- <para>
267
- 当且仅当尝试要安装一个扩展来替代一个<quote>老式</quote>
268
- 的模块(它只是一组没有被打包成扩展的对象的集合)时,
269
- 才必须指定
270
- <literal>FROM</literal> <replaceable class="parameter">old_version</replaceable>。
271
- 这个选项导致<command>CREATE EXTENSION</command>运行
272
- 另一个安装脚本把现有的对象吸收到该扩展中,而不是创建
273
- 新对象。当心<literal>SCHEMA</literal>指定的是包含已经存在
274
- 对象的模式。
275
- </para>
276
-
277
- <!--==========================orignal english content==========================
278
- <para>
279
- The value to use for <replaceable
280
- class="parameter">old_version</replaceable> is determined by the
281
- extension's author, and might vary if there is more than one version
282
- of the old-style module that can be upgraded into an extension.
283
- For the standard additional modules supplied with pre-9.1
284
- <productname>PostgreSQL</productname>, use <literal>unpackaged</literal>
285
- for <replaceable class="parameter">old_version</replaceable> when
286
- updating a module to extension style.
287
- </para>
288
- ____________________________________________________________________________-->
289
- <para>
290
- 用于<replaceable
291
- class="parameter">old_version</replaceable>的值由扩展的作者决定,
292
- 且如果有多于一种版本的老式模块可以被升级到扩展,该值还可能变化。
293
- 对于 9.1 之前的<productname>PostgreSQL</productname>提供的
294
- 标准附加模块,在升级模块到扩展风格时要为
295
- <replaceable class="parameter">old_version</replaceable>使用
296
- <literal>unpackaged</literal>。
297
- </para>
298
- </listitem>
299
- </varlistentry>
300
-
301
264
<varlistentry>
302
265
<!--==========================orignal english content==========================
303
266
<term><literal>CASCADE</literal></term>
@@ -365,6 +328,53 @@ ____________________________________________________________________________-->
365
328
中看到。
366
329
</para>
367
330
331
+ <caution>
332
+ <!--==========================orignal english content==========================
333
+ <para>
334
+ Installing an extension as superuser requires trusting that the
335
+ extension's author wrote the extension installation script in a secure
336
+ fashion. It is not terribly difficult for a malicious user to create
337
+ trojan-horse objects that will compromise later execution of a
338
+ carelessly-written extension script, allowing that user to acquire
339
+ superuser privileges. However, trojan-horse objects are only hazardous
340
+ if they are in the <varname>search_path</varname> during script
341
+ execution, meaning that they are in the extension's installation target
342
+ schema or in the schema of some extension it depends on. Therefore, a
343
+ good rule of thumb when dealing with extensions whose scripts have not
344
+ been carefully vetted is to install them only into schemas for which
345
+ CREATE privilege has not been and will not be granted to any untrusted
346
+ users. Likewise for any extensions they depend on.
347
+ </para>
348
+ ____________________________________________________________________________-->
349
+ <para>
350
+ 以超级用户身份安装扩展程序需要相信扩展程序的作者以安全的方式编写了扩展程序安装脚本。
351
+ 对于恶意用户而言,创建特洛伊木马对象并不困难,而这些特洛伊木马对象会损害以后粗心编写
352
+ 的扩展脚本的执行,从而使该用户获得超级用户特权。但是,仅当木马对象在脚本执行期间位于
353
+ <varname>search_path</varname>中时,它们才是危险的,这意味着它们位于扩展的安装
354
+ 目标模式或它依赖的某些扩展的模式中。因此,在处理未经仔细审查其脚本的扩展时,一个好的
355
+ 经验法则是仅将其安装到尚未具有CREATE特权且不会授予任何不可信用户的模式中。
356
+ 对它们依赖的任何扩展也是一样。
357
+ </para>
358
+
359
+ <!--==========================orignal english content==========================
360
+ <para>
361
+ The extensions supplied with <productname>PostgreSQL</productname> are
362
+ believed to be secure against installation-time attacks of this sort,
363
+ except for a few that depend on other extensions. As stated in the
364
+ documentation for those extensions, they should be installed into secure
365
+ schemas, or installed into the same schemas as the extensions they
366
+ depend on, or both.
367
+ </para>
368
+ ____________________________________________________________________________-->
369
+ <para>
370
+ 针对此类安装时攻击,<productname>PostgreSQL</productname>提供的插件可以认为是
371
+ 针对这种安装时攻击的安全,除了少数插件依赖于其它的扩展。如这些扩展的文档中所述,应将
372
+ 它们安装到安全模式中,或与它们所依赖的扩展安装在相同的模式中,或拓展和其依赖都安装到
373
+ 安全模式。
374
+ </para>
375
+
376
+ </caution>
377
+
368
378
<!--==========================orignal english content==========================
369
379
<para>
370
380
For information about writing new extensions, see
@@ -385,37 +395,30 @@ ____________________________________________________________________________-->
385
395
<!--==========================orignal english content==========================
386
396
<para>
387
397
Install the <link linkend="hstore">hstore</link> extension into the
388
- current database:
398
+ current database, placing its objects in schema <literal>addons</literal> :
389
399
<programlisting>
390
- CREATE EXTENSION hstore;
400
+ CREATE EXTENSION hstore SCHEMA addons ;
391
401
</programlisting>
392
- </para>
393
- ____________________________________________________________________________-->
394
- <para>
395
- 安装<link linkend="hstore">hstore</link>扩展到当前数据库中:
402
+ Another way to accomplish the same thing:
396
403
<programlisting>
404
+ SET search_path = addons;
397
405
CREATE EXTENSION hstore;
398
406
</programlisting>
399
407
</para>
400
-
401
- <!--==========================orignal english content==========================
408
+ ____________________________________________________________________________-->
402
409
<para>
403
- Update a pre-9.1 installation of <literal >hstore</literal> into
404
- extension style:
410
+ 安装<link linkend="hstore" >hstore</link>扩展到当前数据库中,将其对象放置在
411
+ <literal>addons</literal>模式中:
405
412
<programlisting>
406
- CREATE EXTENSION hstore SCHEMA public FROM unpackaged ;
413
+ CREATE EXTENSION hstore SCHEMA addons ;
407
414
</programlisting>
408
- Be careful to specify the schema in which you installed the existing
409
- <literal>hstore</literal> objects.
410
- </para>
411
- ____________________________________________________________________________-->
412
- <para>
413
- 升级一个 9.1 之前的<literal>hstore</literal>安装成为扩展:
415
+ 另一种方法:
414
416
<programlisting>
415
- CREATE EXTENSION hstore SCHEMA public FROM unpackaged;
417
+ SET search_path = addons;
418
+ CREATE EXTENSION hstore;
416
419
</programlisting>
417
- 要小心地指定安装现有<literal>hstore</literal>对象的模式。
418
420
</para>
421
+
419
422
</refsect1>
420
423
421
424
<refsect1>
0 commit comments