From: KaiGai Kohei <kaigai@ak.jp.nec.com>
To: Eamon Walsh <ewalsh@tycho.nsa.gov>
Cc: selinux@tycho.nsa.gov, Joshua Brindle <method@manicmethod.com>
Subject: Re: [PATCH] libselinux: selabel_*() support for database objects
Date: Tue, 09 Mar 2010 09:40:17 +0900 [thread overview]
Message-ID: <4B9598F1.50309@ak.jp.nec.com> (raw)
In-Reply-To: <4B9584A3.1070603@tycho.nsa.gov>
[-- Attachment #1: Type: text/plain, Size: 1812 bytes --]
(2010/03/09 8:13), Eamon Walsh wrote:
> On 03/01/2010 09:53 PM, KaiGai Kohei wrote:
>>
>> What is the current status of the patch?
>>
>> Thanks,
>>
>
>
> Can you send me a sample sepgsql_contexts file so I can test this?
>
The attached selabel-test.conf is an example specfile, and the selabel-test.c
is a sample program to lookup an expected security context for the given name.
$ gcc selabel-test.c -o selabel-test -lselinux \
-I repo/selinux/libselinux/include/ \
-L repo/selinux/libselinux/src/
$ ./selabel-test selabel-test.conf db_table postgres.pg_catalog.pg_class
"postgres.pg_catalog.pg_class" => "system_u:object_r:sepgsql_sysobj_t:s0"
$ ./selabel-test selabel-test.conf db_table postgres.pg_public.my_table
"postgres.pg_public.my_table" => "system_u:object_r:sepgsql_table_t:s0"
$ ./selabel-test selabel-test.conf db_table foovarbaz
failed to lookup : "foovarbaz" (No such file or directory)
In PostgreSQL, its namespace has the following structure:
<database>.<schema>.(<table>|<view>|<procedure>|...)
So, the example specfile defines the following lines:
db_table *.pg_catalog.* system_u:object_r:sepgsql_sysobj_t:s0
It informs all tables under the "pg_catalog" schema should be labeled as
"system_u:object_r:sepgsql_sysobj_t:s0".
Andy, in rubix, the specfile should be described as follows:
db_table *.*.*.* system_u:object_r:rubix_table_t:s0
The library just does pattern matching without any assumption of database
architecture.
I also noticed the previous patch allows to lookup an expected security
context for the db_tuple object class, but tuples don't have their name
basically, so I removed it.
And, it didn't support an upcoming db_view object class, I added it instead.
Thanks,
--
KaiGai Kohei <kaigai@ak.jp.nec.com>
[-- Attachment #2: libselinux-selabel-sepgsql.2.patch --]
[-- Type: application/octect-stream, Size: 6655 bytes --]
[-- Attachment #3: selabel-test.c --]
[-- Type: text/plain, Size: 1659 bytes --]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <selinux/selinux.h>
#include <selinux/label.h>
int main(int argc, char *argv[])
{
struct selabel_handle *handle;
struct selinux_opt options[1];
security_context_t context;
int tclass;
if (argc != 4)
{
fprintf(stderr, "usage: %s <sepc file> <tclass> <name>\n", argv[0]);
return 1;
}
/* config file to be parsed */
options[0].type = SELABEL_OPT_PATH;
options[0].value = argv[1];
handle = selabel_open(SELABEL_CTX_DB, options, 1);
if (!handle)
{
fprintf(stderr, "selabel_open() failed : %s\n", strerror(errno));
return 1;
}
/* tclass name to type value */
if (strcmp(argv[2], "db_database") == 0)
tclass = SELABEL_DB_DATABASE;
else if (strcmp(argv[2], "db_schema") == 0)
tclass = SELABEL_DB_SCHEMA;
else if (strcmp(argv[2], "db_table") == 0)
tclass = SELABEL_DB_TABLE;
else if (strcmp(argv[2], "db_column") == 0)
tclass = SELABEL_DB_COLUMN;
else if (strcmp(argv[2], "db_sequence") == 0)
tclass = SELABEL_DB_SEQUENCE;
else if (strcmp(argv[2], "db_view") == 0)
tclass = SELABEL_DB_VIEW;
else if (strcmp(argv[2], "db_procedure") == 0)
tclass = SELABEL_DB_PROCEDURE;
else if (strcmp(argv[2], "db_blob") == 0)
tclass = SELABEL_DB_BLOB;
else
{
fprintf(stderr, "unknown object class : %s\n", argv[2]);
return 1;
}
/* looking up spec file */
if (selabel_lookup(handle, &context, argv[3], tclass) < 0)
{
fprintf(stderr, "failed to lookup : \"%s\" (%s)\n",
argv[3], strerror(errno));
return 1;
}
printf("\"%s\" => \"%s\"\n", argv[3], context);
freecon(context);
selabel_close(handle);
return 0;
}
[-- Attachment #4: selabel-test.conf --]
[-- Type: text/plain, Size: 958 bytes --]
#
# The specfile for database objects
# (for SE-PostgreSQL)
#
# <object class> <object name> <security context>
#
db_database * system_u:object_r:sepgsql_db_t:s0
db_schema *.pg_catalog system_u:obejct_r:sepgsql_sys_schema_t:s0
db_schema *.* system_u:object_r:sepgsql_schema_t:s0
db_table *.pg_catalog.* system_u:object_r:sepgsql_sysobj_t:s0
db_table *.*.* system_u:object_r:sepgsql_table_t:s0
db_column *.pg_catalog.*.* system_u:object_r:sepgsql_sysobj_t:s0
db_column *.*.*.* system_u:object_r:sepgsql_table_t:s0
db_sequence *.*.* system_u:object_r:sepgsql_sequence_t:s0
db_view *.*.* system_u:object_r:sepgsql_view_t:s0
db_procedure *.pg_catalog.* system_u:object_r:sepgsql_proc_t:s0
db_procedure *.*.* system_u:object_r:sepgsql_user_proc_t:s0
db_blob *.* system_u:object_r:sepgsql_blob_t:s0
next prev parent reply other threads:[~2010-03-09 0:40 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-19 8:21 [PATCH] libselinux: selabel_*() support for database objects KaiGai Kohei
2009-11-21 3:01 ` Eamon Walsh
2009-11-21 14:16 ` KaiGai Kohei
2009-11-25 23:29 ` KaiGai Kohei
2009-11-30 21:30 ` Eamon Walsh
2010-03-02 2:53 ` KaiGai Kohei
2010-03-08 23:13 ` Eamon Walsh
2010-03-08 23:26 ` Andy Warner
2010-03-08 23:34 ` KaiGai Kohei
2010-03-09 0:40 ` KaiGai Kohei [this message]
2010-03-09 1:22 ` Eamon Walsh
2010-03-09 1:42 ` KaiGai Kohei
2010-03-09 20:08 ` Eamon Walsh
2010-03-09 22:16 ` KaiGai Kohei
2010-03-10 17:11 ` Eamon Walsh
2010-03-10 18:04 ` Andy Warner
2010-03-11 4:28 ` KaiGai Kohei
2010-03-12 1:05 ` KaiGai Kohei
2010-03-15 23:13 ` Eamon Walsh
2010-03-16 0:01 ` KaiGai Kohei
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4B9598F1.50309@ak.jp.nec.com \
--to=kaigai@ak.jp.nec.com \
--cc=ewalsh@tycho.nsa.gov \
--cc=method@manicmethod.com \
--cc=selinux@tycho.nsa.gov \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.