NAME
secdsc: get_secdsc_ent(), set_secdsc(), end_secdsc() — get security attribute description entry from /etc/security.dsc
SYNOPSIS
#include <prot.h>
ssize_t get_secdsc_ent(FILE **stream, struct secdsc_ent *attr,
char *sbuf, const size_t length)
int set_secdsc(FILE **stream)
void end_secdsc(FILE **stream)
DESCRIPTION
get_secdsc_ent()
obtains security attribute description entries from the
/etc/security.dsc
file.
The security attribute description entries are returned in the
secdsc_ent
structure.
The
secdsc_ent
structure is defined in
<prot.h>
and includes the following members:
char *attribute; /* attribute name */
int minvalue; /* minimum value for attribute */
int maxvalue; /* maximum value for attribute */
char *defvalue; /* default value */
int flag; /* flag bits (see /etc/security.dsc) */
char *desc; /* attribute description */
When first called,
get_secdsc_ent()
returns the structure corresponding to the first entry in the
/etc/security.dsc
file.
Thereafter, it returns the structure for the next entry in
/etc/security.dsc.
get_secdsc_ent()
expects to be passed four parameters:
- 1.
A pointer to a
(FILE *)
variable into which will
be stored the result of an
fopen()
call on the
/etc/security.dsc
file.
This allows threads to independently scan through
/etc/security.dsc.
Note that the
(FILE *)
variable must be initialized to NULL the first time it is passed to
get_secdsc_ent().
Thereafter it should not be modified in any way.
- 2.
The address of a
secdsc_ent
structure where the result will be stored.
- 3.
A buffer in which to store character strings,
such as the attribute name.
Fields in the
secdsc_ent
structure will point into this buffer.
- 4.
The length of the user-supplied buffer.
A buffer length of 1024 is recommended.
set_secdsc()
opens or rewinds
/etc/security.dsc.
end_secdsc()
is called when
/etc/security.dsc
processing is complete, to close the file and
release memory associated with the opened file.
RETURN VALUE
get_secdsc_ent()
returns 0 if the end-of-file is reached.
If an error is encountered, -1 is returned.
If the operation is successful, the number of bytes read is returned.
set_secdsc()
returns -1 if an error is encountered while trying
to open or rewind the
/etc/security.dsc
file. If the operation is successful, 0 is returned.
EXAMPLES
The following code excerpt counts the number of entries in
/etc/security.dsc:
int count = 0;
struct secdsc_ent secbuf;
char buffer[1024];
FILE *secf = NULL;
while (get_secdsc_ent(&secf, &secbuf, buffer, 1024L) > 0)
count++;
end_secdsc(&secf);
FILES
- /etc/security.dsc
security attributes description file