Trusted Solaris Developer's Guide

Test Label Relationships

If your application accesses data at different sensitivity labels, you can perform checks in your code to be sure the process label has the correct relationship to the data label before you allow an access operation to take place. You check the sensitivity label to find out if access will be allowed by the system or if privilege is required to override access restrictions.

These examples show how to test two sensitivity labels for equality, dominance, and strict dominance. The Trusted Solaris environment checks the process clearance when the process changes the sensitivity label on any object or writes to an object of a higher sensitivity label. "Find Relationships Between Two Levels" describes how to test for the relationship between a clearance and a sensitivity label.

Find Relationship Between Two Levels

A level is a classification and set of compartments for a sensitivity label or clearance; and is represented by the data type blevel_t. Two levels can be equal, one can dominate the other, or one can strictly dominate the other.

This example tests the process sensitivity label against a file's sensitivity label. The code for getting the process and file CMW label and extracting the sensitivity label portion is not shown. See "Get Process CMW Label" and "Get File CMW Label" for example code to perform these operations.

In this example, the process sensitivity label is Confidential and the file sensitivity label is Confidential. The labels are equal, the process label dominates the file label, but does not strictly dominate the file label.

#include <tsol/label.h>

main()
{
	int equal, dominate, strictdom, retval;
	bslabel_t *plabel, *filelabel;
	bclabel_t fileCMWlabel, pCMWlabel;

/* Get file and process CMW labels */
	retval = getcmwlabel("/export/home/zelda/afile", &fileCMWlabel);
	retval = getcmwplabel(&pCMWlabel);

/* Get sensitivity labels */
	plabel = bcltosl(&plabel);
	filelabel = bcltosl(&filelabel);

/* Once have both labels, test for equality */
	equal = blequal(plabel, filelabel);
	printf("Process label equals file label? %d\n", equal);

/* Test for dominance */
	dominate = bldominates(plabel, filelabel);
	printf("Process label dominates file label? %d\n", dominate);

/* Test for strict dominance */
	strictdom = blstrictdom(plabel, filelabel);
	printf("Process label strictly dominates file label? %d\n", strictdom);
}

The printf statement prints the following where any value greater than zero is true and zero is false.


Process label equals file label? 1
Process label dominates file label? 1
Process label strictly dominates file label? 0