Trusted Solaris Developer's Guide

Test Range Before Changing File CMW Label

Before upgrading a file CMW label (as was done in the previous example), it is a good idea to test the file system label range to be sure the file's new sensitivity label is within the sensitivity label range of the file.

This example converts text strings to a new binary sensitivity label, gets the file system label range, and checks if the new sensitivity label is within the file system's label range.

#include <tsol/label.h>

main()
{
	int retval, error;
	bclabel_t fileCMWlabel;
	bslabel_t fsenslabel;
	brange_t range;
	char *string = "TOP SECRET";

/* Create new sensitivity label value */
	retval = stobsl(string, &fsenslabel, NEW_LABEL, &error);

/* Get file system label range */
	retval = getcmwfsrange("/export/home/zelda/afile", range);

/* Test new sensitivity label against label range */
	retval = blinrange(&fsenslabel, range);
	if(retval > 0)
		{/* Proceed with file CMW label upgrade. */}
}