Trusted Solaris Developer's Guide

Sensitivity and Information Labels

The text forms of sensitivity labels and information labels output by interfaces are separated by spaces and formatted as follows where the curly brackets indicate optional items and the ellipses indicate repeated words. In a sensitivity label, words represent compartments, and in an information label words represent compartments and markings.

CLASSIFICATION {WORD}...

The following code example translates a binary sensitivity label to text using different flags. The process runs at TS A B and needs the sys_trans_label privilege for the translation after the call to bslhigh(3TSOL). The code comments indicate where privilege bracketing as described in Chapter 3, Privileges should take place.

#include <tsol/label.h>
main()
{
	int retval, length = 0;
	char *string1 = (char *)0, *string2 = (char *)0,
		*string3 = (char *)0, *string4 = (char *)0,
		*string5 = (char *)0, *string6 = (char *)0,
		*string7 = (char *)0;
	bclabel_t cmwlabel;
	bslabel_t senslabel;

	retval = getcmwplabel(&cmwlabel);
	getcsl(&senslabel, &cmwlabel);

	retval = bsltos(&senslabel, &string1, length, LONG_WORDS);
	printf("Retval1 = %d Long Words = %s\n", retval, string1);

	retval = bsltos(&senslabel, &string2, length, SHORT_WORDS);
	printf("Retval2 = %d Short Words = %s\n", retval, string2);

	retval = bsltos(&senslabel, &string3, length, LONG_CLASSIFICATION);
	printf("Retval3 = %d Long Classifications = %s\n", retval, string3);

	retval = bsltos(&senslabel, &string4, length, SHORT_CLASSIFICATION);
	printf("Retval4 = %d Short Classifications = %s\n", retval, string4);

	retval = bsltos(&senslabel, &string5, length, NO_CLASSIFICATION);
	printf("Retval5 = %d No Classification = %s\n", retval, string5);

	bslhigh(&senslabel);
/* Turn sys_trans_label on in the effective set */
	retval = bsltos(&senslabel, &string6, length, VIEW_INTERNAL);
/* sys_trans_label off. */
	printf("Retval6 = %d View Internal = %s\n", retval, string6);

	retval = bsltos(&senslabel, &string7, length, VIEW_EXTERNAL);
	printf("Retval7 = %d View External = %s\n", retval, string7);
}

The printf statements print the following.


Long Words = TS A B
Short Words = TS A B
Long Classifications = TOP SECRET A B
Short Classifications = TS A B
No Classification = A B
View Internal = ADMIN_HIGH
View External = TS A B SA SB CC