getdevattr Subroutine

Purpose

Retrieves the device security information in the privileged device database.

Library

Security Library (libc.a)

Syntax

#include <usersec.h>

int getdevattr (Device, Attribute, Value, Type)
    char *Device;
    char *Attribute;
    void *Value;
    int Type;

Description

The getdevattr subroutine reads a specified attribute from the device database. If the database is not open, this subroutine does an implicit open for reading. For attributes of the SEC_CHAR and SEC_LIST types, the getdevattr subroutine returns the value to the allocated memory. Caller needs to free this memory.

Parameters

Item Description
Device Specifies the device name. The value should be the full path to the device on the system. This parameter must be specified unless the Type parameter is SEC_COMMIT.
Attribute Specifies the attribute that is read. The following possible attributes are defined in the usersec.h file:
S_READPRIVS
Privileges required to read from the device. Eight privileges can be defined. A process with any of the read privileges is allowed to read from the device. The attribute type is SEC_LIST.
S_WRITEPRIVS
Privileges required to write to the device. Eight privileges can be defined. A process with any of the write privileges is allowed to write to the device.
Value Specifies a pointer or a pointer to a pointer according to the Attribute array and the Type parameters. See the Type parameter for more details.
Type Specifies the type of attribute. The following valid types are defined in the usersec.h file:
SEC_INT
The format of the attribute is an integer. For the getdevattr subroutine, the user should supply a pointer to a defined integer variable.
SEC_CHAR
The format of the attribute is a null-terminated character string. For the getdevattr subroutine, the user should supply a pointer to a defined character pointer variable. The value is returned as allocated memory for the getdevattr subroutine. Caller need to free this memory.
SEC_LIST
The format of the attribute is a series of concatenated strings, each of which is null-terminated. The last string in the series is terminated by two successive null characters. For the getdevattr subroutine, the user should supply a pointer to a defined character pointer variable. Caller need to free this memory.

Security

Files Accessed:
File Mode
/etc/security/privdevs rw

Return Values

On successful completion, the getdevattr subroutine returns a value of zero. Otherwise, a value of -1 is returned and the errno global value is set to indicate the error.

Error Codes

If the getdevattr subroutine fails, one of the following errno values is set:

Item Description
EINVAL The Device parameter is NULL or default.
EINVAL The Attribute or Type parameter is NULL or does not contain one of the defined values.
EINVAL The Attribute parameter is S_PRIVDEVS, but the Device parameter is not ALL.
ENOENT The device specified in the Device parameter does not exist.
ENOATTR The attribute specified in the Attribute parameter is valid, but no value is defined for the device.
EPERM The operation is not permitted.