Solaris Trusted Extensions Developer's Guide

Using the label_to_str() Function

After obtaining the credential and remote host label, an application can call label_to_str() to convert the label data structure into a string. The string form of the label data structure can be used by the application.

Note that in the Trusted Extensions printing service, the label is returned as a string. The get_peer_label() function returns the string that is obtained by calling label_to_str() on the m_label_t data structure. This string value is returned in the slabel parameter of the get_peer_label() function, char** slabel.

The following code excerpt shows how the label_to_str() function is used:

sl = ucred_getlabel(uc);
if (label_to_str(sl, &pslabel, M_INTERNAL, DEF_NAMES) != 0)
	syslog(LOG_WARNING, "label_to_str(): %m");

if (pslabel != NULL) {
	syslog(LOG_DEBUG, "get_peer_label(%d, %s): becomes %s",
		fd, (*slabel ? *slabel : "NULL"), pslabel);
	if (*slabel != NULL)
	*slabel = strdup(pslabel);

See get_peer_label() Label-Aware Function to view the source of the entire get_peer_label() routine.