Skip Navigation Links | |
Exit Print View | |
Trusted Extensions Developer's Guide Oracle Solaris 11.1 Information Library |
1. Trusted Extensions APIs and Security Policy
Setting a File Sensitivity Label
Determining the Relationship Between Two Labels
Obtaining the Color Names of Labels
4. Interprocess Communications
7. Trusted Web Guard Prototype
8. Experimental Java Bindings for the Solaris Trusted Extensions Label APIs
You can obtain a file's sensitivity label and perform operations on that label.
This code example uses the getlabel() routine to obtain the file's label. The fgetlabel() routine can be used in the same way, but it operates on a file descriptor.
#include <tsol/label.h> main() { m_label_t* docLabel; const char* path = "/zone/restricted/documents/designdoc.odt"; int retval; char* label_string; /* allocate label and get the file label specified by path */ docLabel = m_label_alloc(MAC_LABEL); retval = getlabel(path, docLabel); /* translate the file's label to a string and print the string */ retval = label_to_str(docLabel, &label_string, M_LABEL, LONG_NAMES); printf("The file's label = %s\n", label_string); /* free allocated memory */ m_label_free(docLabel); free(label_string); }
When you run this program, the output might look similar to this:
The file's label = CONFIDENTIAL : INTERNAL USE ONLY