Content-type: text/html Man page of getprfient


Section: C Library Functions (3)
Index Return to Main Contents


getprfient, getprfinam, putprfinam - Manipulate file control database entry (Enhanced Security)  


Security Library (libsecurity.a)  


#include <sys/types.h> #include <sys/security.h> #include <prot.h>

struct pr_file *getprfient(void);

struct pr_file *getprfinam(        char *name);

void setprfient(void);

void endprfient(void);

int putprfinam(        char *name,
       struct pr_file *pr);



Specifies a file control database entry name. Specifies a file control database entry structure.  


The getprfient() and getprfinam() functions each return a pointer to an object with the following structure containing the separated-out fields of a line in the file control database. Each line in the database contains a pr_file structure, declared in the prot.h header file as follows: struct f_field {
        char    *fd_name;       /* Holds full pathname */
        ushort  fd_uid;         /* uid of owner */
        ushort  fd_gid;         /* gid of group */
        ushort  fd_mode;        /* permissions */
        char    fd_type[2];     /* file type (one of r,b,c,d,f,s) */
         acle_t  *fd_acl;        /* access control list for file */
         int     fd_acllen;      /* number of entries in fd_acl */ };

struct f_flag {
        unsigned short
                fg_name:1,      /* Is fd_name set? */
                fg_uid:1,       /* Is fd_uid set? */
                fg_gid:1,       /* Is fd_gid set? */
                fg_mode:1,      /* Is fd_mode set? */
                fg_type:1,      /* Is fd_type set? */
                 fg_acl:1,       /* Is fd_acl set? */ };

struct pr_file {
        struct f_field ufld;
        struct f_flag uflg; };

The getprfient() function when first called returns a pointer to the first pr_file structure in the database; thereafter, it returns a pointer to the next pr_file structure in the database, so successive calls can be used to search the database. The getprfinam() function searches from the beginning of the database until a file name matching name is found, and returns a pointer to the particular structure in which it was found. If an end-of-file or an error is encountered on reading, these functions return a null pointer.

A call to the setprfient() function has the effect of rewinding the file control database to allow repeated searches. The endprfient() function can be called to close the file control database when processing is complete.

The putprfinam() function puts a new or replaced file control entry pr with key name into the database. If the uflg.fg_name field is a 0 (zero), the requested entry is deleted from the file control database. The putprfinam() function locks the database for all update operations, and performs a endprfient() after the update or failed attempt.

The file control database stores a list of entries for security relevant files. This database is used by the setfiles program to assign and maintain the security attributes of system files.

The fd_name pointer refers to the file name, which can be an absolute pathname or a pathname whose last component is an * (asterisk), which is treated as a wildcard entry. Entries that refer to a specific file in a directory supersede the wildcard entry if the absolute pathname precedes the wildcard entry in the database. The fd_uid and fd_gid fields are the numeric owner and group of the file. The fd_mode field is the mode word, including owner, group, and other permissions, as well as the SUID and SGID bits. The fd_type field contains a one-character file type indicator: r (regular), b (block-special), c (character-special), d (directory), f (FIFO), s (symbolic link), The fd_acl field references the internal representation of the file's access control list. The fd_acllen field is the number of entries on that list.  


Programs using these functions must be compiled with -lsecurity.  


The value returned by getprfinam() and getprfient() refers to a structure that is overwritten by calls to these functions. To retrieve an entry, modify it, and replace it in the database, you must copy the entry using structure assignment and supply the modified buffer to putprfinam().  


The getprfient() and getprfinam() functions return null pointers on EOF or an error. The putprfinam() function returns a value of 0 (zero) if it cannot add or upgrade the entry.


Description file of directories, devices, control, and commands modified for security. General security databases file. delim off




This document was created by man2html, using the manual pages.
Time: 02:40:53 GMT, October 02, 2010