#include #include #include #include #include #include int main(int argc, char *argv[]) { security_context_t context; struct selabel_handle *hnd; const char *typename; const char *keyword; int type; if (!argv[1] || !argv[2]) { fprintf(stderr, "usage: %s \n", argv[0]); return 1; } typename = argv[1]; keyword = argv[2]; if (!strcmp(typename, "database")) type = SELABEL_DB_DATABASE; else if (!strcmp(typename, "catalog")) type = SELABEL_DB_CATALOG; else if (!strcmp(typename, "schema")) type = SELABEL_DB_SCHEMA; else if (!strcmp(typename, "table")) type = SELABEL_DB_TABLE; else if (!strcmp(typename, "column")) type = SELABEL_DB_COLUMN; else if (!strcmp(typename, "procedure")) type = SELABEL_DB_PROCEDURE; else if (!strcmp(typename, "sequence")) type = SELABEL_DB_SEQUENCE; else { fprintf(stderr, "invalid object type: %s\n", argv[1]); return 1; } hnd = selabel_open(SELABEL_CTX_DB, NULL, 0); if (!hnd) { fprintf(stderr, "selabel_open failed : %s\n", strerror(errno)); return 1; } if (selabel_lookup(hnd, &context, keyword, type) < 0) printf("No valid context for (%s,%s)\n", typename, keyword); else printf("lookup: %s for (%s,%s)\n", context, typename, keyword); selabel_close(hnd); }