[pgsql-jp: 35164] Re: CREATE TABLESPACEについての質問

上野 弘太 ueno @ crosstech.co.jp
2005年 4月 2日 (土) 17:13:06 JST


上野と申します。

> pgqr=# CREATE TABLESPACE reb OWNER postgres LOCATION '/var/lib/pgsql/data2';
> と行うと
> ERROR:  could not set permissions on directory "/var/lib/pgsql/data2": 許可がありません
> と表示されます。

ソースコードを検索すると、エラーの該当箇所が見つけられます。
(たとえば、 grep "could not set permissions on directory" -r .  (-r が指定できない grep も有りますが、、) )

./src/backend/commands/tablespace.c
================================================================================
void
CreateTableSpace(CreateTableSpaceStmt *stmt)
{

   *** 中略 ***

    /*
     * Attempt to coerce target directory to safe permissions.  If this
     * fails, it doesn't exist or has the wrong owner.
     */
    if (chmod(location, 0700) != 0)
        ereport(ERROR,
                (errcode_for_file_access(),
              errmsg("could not set permissions on directory \"%s\": %m",
                     location)));
================================================================================

バックエンド側で chmod が失敗していますよね。

ソースコードのコメントにも、エラーの原因が記述されていますけど、
エラーメッセージに「許可がありません」とありますから、chmod のエラーコードは、

       EPERM  実効 UID がファイルの所有者と一致せず、 スー パー・
              ユーザーでもない。
   ( man 2 chmod で調べました)

と予想されます。

上記のソースコードがエラーメッセージを表示するなら、
下記のコマンドをpostmasterが動作しているサーバーで実行すると、失敗するはずなのですが、、

su -l postgres -s /bin/sh -c "chmod 0700 /var/lib/pgsql/data2"


しかし、「許可が無い」というのもおかしいですよね。。。

> /var/lib/pgsql/data2のパーミッションは
> drwx------  2 postgres postgres      4096  3月 31 09:23 data2

上記のパーミッションは、本当に postmasterが動作しているサーバーの状態なのでしょうか?
あるいは、 postgres で、 postmasterが動作していないとか?(そんなことはないと思いますが、)




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