You can get the process CMW label and perform operations on it as a unit, or extract the sensitivity label portion and perform independent operations on it. This example gets the process CMW label, extracts the sensitivity label portion, translates the process CMW label to a text string, and prints the process CMW label.
#include <tsol/label.h> main() { int retval, length = 0; bclabel_t pCMWlabel; bslabel_t psenslabel; char *string; /* Get process CMW label */ retval = getcmwplabel(&pCMWlabel); /* Get sensitivity label portion */ getcsl(&psenslabel, &pCMWlabel); /* Translate the process CMW label to text and print */ retval = bcltos(&pCMWlabel, &string, length, LONG_CLASSIFICATION); printf("Process CMW label = %s\n", string); }
The printf statement prints the following where ADMIN_LOW
is the information label and [C] is the sensitivity label. This CMW label means the process is running at a sensitivity level of Confidential ([C]) with an
information label of ADMIN_LOW
. The CMW label is inherited from the workspace in which the program is run.
Process CMW label = ADMIN_LOW [C] |
The text output depends on the flag parameter to bcltos(3TSOL) and specifications in label_encodings(4). See "Binary to Text Label Translation Routines" for information on flag parameter values.