Trusted Solaris Developer's Guide

Privileges and Authorizations

Privileges let a process perform security-related tasks normally prohibited by the system security policy. Authorizations let a user perform privileged tasks not allowed to all users. Every authorization maps to a privileged task. Always check a user's authorizations before allowing a privileged task to take place.


Caution - Caution -

The development, testing, and debugging of privileged applications should always be on an isolated development machine to prevent bugs and incomplete code from compromising security policy on the main system.


Privileges distribute security-related powers so a process has enough power to perform a task and no more. Likewise, authorizations distribute security-related powers so each user or role has enough power to perform a task and no more.

The system administrator assigns authorizations to users and roles through an execution profile. The chkauth(3TSOL) routine accepts a valid user name and authorization as parameters and returns true if the authorization is assigned to that user. During development, privileges can be assigned to the executable file and/or inherited from the user's or role's executable profile at run time.

To know if a program performs tasks that require privilege and user authorization checks, ask these questions:

This example checks the process permitted set for the file_downgrade_sl privilege, and the user authorization solaris.label.file.downgrade for user ID zelda before performing a task that involves downgrading the sensitivity label on a file. If the privilege is in the permitted set and if zelda has the authorization, the code turns the file_downgrade_sl privilege on in the effective set (makes the privilege effective) and performs the task. When the task completes, file_downgrade_sl is turned off (is no longer effective).

The example compiles with the following libraries:


-lsecdb -lnsl -lcmd -ltsol

Note -

The permitted set contains the privileges the process can potentially use during execution, and the effective set contains the privileges the process is actually using at a given time. Turning effective privileges on and off is called privilege bracketing and is discussed in Chapter 3, Privileges.


#include <tsol/priv.h>
#include <tsol/auth.h>

main()
{
	char *zelda = "zelda";
	priv_set_t priv_set;

/* Retrieve the permitted privilege set */
	getppriv(PRIV_PERMITTED, &priv_set);

	if(PRIV_ISASSERT(&priv_set, PRIV_FILE_DOWNGRADE_SL) &&
		chkauthattr(solaris.label.file.downgrade, zelda)) {
		set_effective_priv(PRIV_ON, 1, PRIV_FILE_DOWNGRADE_SL);
		/* Downgrade sensitivity label on file*/
		set_effective_priv(PRIV_OFF, 1, PRIV_FILE_DOWNGRADE_SL);
	}
	else {/* Raise Errors */}
}