Security-Enhanced PostgreSQL開発

元々3連休のところにもう一日休暇を追加して、明日まで4連休にした(Yeah!)。もちろん、SE-PgSQLの開発に充てるためなので、自室にヒキコモっているわけなのだが。

とりあえずアクセス制御機能を云々する前に、DBオブジェクトにセキュリティコンテキストを付与する機能がないと話にならないので、まずはそこから始めることにした。

現在までに、以下の箇所の実装が終わっている。


  • データベースにセキュリティコンテキストを付与する機能

  • テーブルにセキュリティコンテキストを付与する機能

  • カラムにセキュリティコンテキストを付与する機能

  • タプルにセキュリティコンテキストを付与する機能


で、中途半端に手を加えたこのSE-PgSQLに繋いでごにょごにょしたのが、以下の図。CREATE TABLEした時に、勝手にsecurity_context行が作られ、行をINSERTした時に、勝手にsecurity_contextが付与される(まだ不十分だけど)。

互換性の観点から、SELECT * ...した時にsecurity_context列が見えてはいけないのだけども、ここにはまだ手を加えていないので、このように表示される。まぁご愛嬌。

[kaigai@masu sepgsql-kg]$ psql postgres
Welcome to psql 8.1.4, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help with psql commands
       \g or terminate with semicolon to execute query
       \q to quit

postgres=# create table mytest(
postgres(#     id serial primary key,
postgres(#     name varchar(128),
postgres(#     price integer
postgres(# );
NOTICE:  CREATE TABLE will create implicit sequence
    "mytest_id_seq" for serial column "mytest.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create
    implicit index "mytest_pkey" for table "mytest"
CREATE TABLE
postgres=# insert into mytest(name, price) values('coke', 120);
INSERT 0 1
postgres=# insert into mytest(name, price) values('juice', 120);
INSERT 0 1
postgres=# insert into mytest(name, price) values('beer', 240);
INSERT 0 1
postgres=# select * from mytest;
 id | name  | price |        security_context
----+-------+-------+---------------------------------
  1 | coke  |   120 | user_u:object_r:unconfined_t:s0
  2 | juice |   120 | user_u:object_r:unconfined_t:s0
  3 | beer  |   240 | user_u:object_r:unconfined_t:s0
(3 rows)

postgres=#

10月28日に日本電子専門学校で行われるオープンソースカンファレンス2006 Tokyo/Fallに参加するので、PostgreSQLユーザ会の人に見せてデモれる程度まで形にしたいな。