ねら~ITエンジニア雑記

やきうのお兄ちゃんが綴るOracle Databaseメインのブログ

Oracle Datapump の export(expdp) で出力される dmpファイル の OSグループ を制御する。

Oracle Datapump の export(expdp) で出力される ダンプファイル は、
通常 ${ORACLE_HOME}/bin配下の oracleバイナリと同一の owner:group で出力されます。

[oracle@host1 ~]$ . .ayshibat
[oracle@host1 ~]$ ls -la $ORACLE_HOME/bin/oracle
-rwsr-s--x 1 oracle oinstall 228455435 Jul 18  2014 /u01/app/oracle/product/11.2.0/dbhome_1/bin/oracle
                    ^^^^^^^^
[oracle@host1 ~]$
[oracle@host1] expdp AYSHIBAT/******** DIRECTORY=DIR_AYSHIBAT TABLES=TBL_A DUMPFILE=tbl_a.dmp LOGFILE=exp_tbl_a.log REUSE_DUMPFILES=Y
:
[oracle@host1] ls -la
total 407304
drwxr-x---   2 oracle   ayshibat     512 Feb 16 23:30 .
drwxrwxrwx   8 oracle   oinstall    1024 Feb 16 23:25 ..
-rw-r--r--   1 oracle   oinstall    1576 Feb 16 23:30 exp_tbl_a.log
-rw-r-----   1 oracle   oinstall 208420864 Feb 16 23:30 tbl_a.dmp  ★

OSユーザ の oracle以外(例:アプリの OSユーザ)で dmpファイル を参照したい場合、
oinstall(等) のグループを付与する必要がありますが、セキュリティ要件によっては、
oinstall(等)グループを付与したくないケースは、有り得ます。

そのようなケースでは、ディレクトリの setgid(group s-bit) を使用すると
作成される dmpファイル に ディレクトリ の group が継承(上書き)されて、
その group が付与された OSユーザ で参照可能になります。

# ls -la
total 407304
drwxr-x---   2 oracle   ayshibat     512 Feb 16 23:30 .
drwxrwxrwx   8 oracle   oinstall    1024 Feb 16 23:25 ..
# chmod g+s ayshibat ★ group s-bit を付与
# ls -la ayshibat
total 4
drwxr-s---   2 oracle   ayshibat     512 Feb 16 23:33 .
   ^ group s-bitが付与されている。
drwxrwxrwx   8 oracle   oinstall    1024 Feb 16 23:25 ..
:
[oracle@host1] expdp AYSHIBAT/******** DIRECTORY=DIR_AYSHIBAT TABLES=TBL_A DUMPFILE=tbl_a.dmp LOGFILE=exp_tbl_a.log REUSE_DUMPFILES=Y
:
[oracle@host1]# ls -la
total 407304
drwxr-s---   2 oracle   ayshibat     512 Feb 16 23:35 .
drwxrwxrwx   8 oracle   oinstall    1024 Feb 16 23:25 ..
-rw-r--r--   1 oracle   ayshibat    1576 Feb 16 23:35 exp_tbl_a.log
-rw-r-----   1 oracle   ayshibat 208420864 Feb 16 23:35 tbl_a.dmp
             ^^^^^^^^ ディレクトリの group が継承(上書き)されている。

上手く行ってるZe!!!(`・ω・)Ъ

参考にした記事は下記です。
【s-bit, sticky-bit について:id:teramako:20130422:p1】

■キーワード
datapump export expdp dmp 権限 group OS グループ パーミッション permission