[pgsql-jp: 35810] Re: create table権限の取り上げ

Yukitaka Ohmura oomura_yukitaka @ intec.co.jp
2005年 8月 9日 (火) 09:48:26 JST


大村です。
石田@苫小牧市さん、回答ありがとうございます。

> データベースに対するCREATE権限は、そのデータベースに対して、
> スキーマを作成できるかどうかの権限です。
> テーブル等のデータベースオブジェクトの作成を許可するか
> どうかは、
> 
> GRANT CREATE ON SCHEMA schemaname TO ...
> 
> のようにスキーマに対するCREATE権限で設定します。

なるほど。
調べてみると以下にも詳しく書いてありました。
http://www.postgresql.jp/document/pg746doc/html/ddl-schemas.html#DDL-SCHEMAS-PRIV

ユーザ専用のスキーマを作ると想定どおりの動きになりました。

% psql -U postgres webdb
webdb=# CREATE SCHEMA webuser;
CREATE SCHEMA
webdb=# GRANT ALL on schema webuser to webuser;
GRANT
webdb=# revoke create on schema webuser from webuser;
REVOKE

% psql -U webuser webdb
webdb=> CREATE TABLE newtbl(id int, nm char(2));
ERROR:  permission denied for schema webuser


ところがpublicスキーマに対しては、
思ったように制限が出来ませんでした。
publicスキーマに対して全ユーザ(public)に対する制限はできるのですが、
特定ユーザに対する制限ができません。
これはこういったものなのでしょうか?

% psql -U postgres webdb
webdb=# GRANT all on schema public to public;
GRANT
webdb=# REVOKE create on schema public from public ;
REVOKE

% psql -U webuser webdb
webdb=> CREATE TABLE newtbl(id int, nm char(2));
ERROR:  permission denied for schema public
webdb=> select * from pg_namespace ;
      nspname       | nspowner |                nspacl
--------------------+----------+--------------------------------------
 pg_toast           |        1 |
 pg_temp_1          |        1 |
 pg_catalog         |        1 | {postgres=U*C*/postgres,=U/postgres}
 information_schema |        1 | {postgres=U*C*/postgres,=U/postgres}
 public             |        1 | {postgres=U*C*/postgres,=U/postgres}
(5 rows)

% psql -U postgres webdb
webdb=# GRANT all on schema public to public;
GRANT
webdb=# REVOKE create on schema public from webuser ;
REVOKE

% psql -U webuser webdb
webdb=> CREATE TABLE newtbl(id int, nm char(2));
CREATE TABLE					←テーブルが作れてしまう
webdb=> select * from pg_namespace ;
      nspname       | nspowner |                nspacl
--------------------+----------+---------------------------------------
 pg_toast           |        1 |
 pg_temp_1          |        1 |
 pg_catalog         |        1 | {postgres=U*C*/postgres,=U/postgres}
 information_schema |        1 | {postgres=U*C*/postgres,=U/postgres}
 public             |        1 | {postgres=U*C*/postgres,=UC/postgres}
(5 rows)



大村幸敬 (Yukitaka Ohmura)
(株) インテック
ビジネスソリューション事業本部
CRMソリューション第一部 Linux推進チーム
Phone: 045-451-2410  Fax: 045-451-2357
E-mail: oomura_yukitaka @ intec.co.jp



pgsql-jp メーリングリストの案内