labelsession Subroutine

Purpose

Determines user access to system by validating the user security labels against the system labels.

Library

Trusted AIX® Library ( libmls.a )

Syntax

#include <mls/mls.h>

int labelsession (Name, Mode, TTY, EffSL, EffTL, Msg [, Flag])
char *Name;
intMode;
char *TTY;
char *EffSL;
char *EffTL;
char **Msg;
int Flag;

Description

The labelsession subroutine determines whether the user specified by the Name parameter is allowed to access the system based on the sensitivity and the integrity clearances of the user. The Mode parameter gives the mode of the account usage and the TTY parameter defines the terminal that is used for access. The EffSL and EffTL parameters specify the effective sensitivity label and the effective integrity label for the session respectively. The Msg parameter returns an information message that explains the reason that the subroutine fails.

The labelsession subroutine fails under the following circumstances:
  • The Mode parameter is not S_SU and user ID of the user is less than 128. Any user with a user ID (uid) less than 128 is only allowed to login with the su command.
  • Either the sensitivity labels or the integrity labels, or both labels are not properly dominated.
  • The specified effective SL is not within the user's clearance range and the user does not have the aix.mls.label.outsideaccred authority.
  • The effective SL of the user is not in the TTY's label range.
  • The specified effective TL is not in the user's clearance range.
  • If the TTY has a TL set, the specified effective TL is not equal to the TTY's TL.
  • The Flag parameter is not specified for S_SU and the current user's label does not dominate those of the new users.
Restriction: This subroutine is applicable only on a Trusted AIX system.

Parameters

Item Description
Name Specifies the user login name.
Mode Specifies the mode to use. The Mode parameter contains one of the following valid values that are defined in the login.h file:
S_LOGIN
Local login
S_RLOGIN
Remote login using the rlogind and telnetd commands
S_SU
Login in using the su command
S_FTP
FTP based login
TTY Specifies the terminal of the originating activity. If this parameter is a null pointer or a null string, no TTY checking is done.
EffSL Specifies the effective SL that the session requires.
EffTL Specifies the effective TL that the session requires.
Msg Returns a message to the user interface that explains the reason why the subroutine fails. The returned value is either a pointer to a valid string within memory allocated storage or a null value.
Flag When the Flag parameter is set to 1, the current user labels do not need to dominate those of the new user to allow access. This parameter is valid only for the S_SU mode. This parameter is ignored for all other session types.

Security

Access Control: The calling process must have access to the account information in the user database and the port information in the port database. The calling process must also have the privileges that are required by the subroutines that this subroutine invokes.

File Accessed

Mode File
r /etc/security/enc/LabelEncodings
r /etc/security/user

Return Values

If the session labels are valid for the specified usage, the labelsession subroutine returns a value of zero. Otherwise, the subroutine returns a value of -1, sets the errno global value and the Msg parameter returns the error information.

Error Codes

If the subroutine fails, it returns one of the following error codes:

Item Description
EINVAL Error in label encodings file or error in the label dominance
EINVAL The specified effective SL is not valid on the system
ENOATTR The clearance attributes for the user do not exist
ENOMEM Memory cannot be allocated to store the returned value
EPERM No permission to complete the operation