priv_getbynum(3) Library Functions Manual priv_getbynum(3)NAME
priv_getbynum() - convert privilege ID to privilege name
SYNOPSIS
Parameters
priv_id The internal (numeric) representation of a privilege to be converted to the external (string) representation.
DESCRIPTION
converts the internal privilege representation of the privilege ID to the external string representation.
RETURN VALUE
returns the following values:
pointer Successful completion. A non-null pointer to the privilege name is returned. The returned string is a pointer to shared
data, and must not be modified or freed.
NULL pointer
Function failed. is set to indicate the error.
ERRORS
If fails, is set to one of the following values:
Invalid privilege ID.
EXAMPLES
#include <stdio.h>
#include <sys/privileges.h>
#include <sys/types.h>
main()
{
priv_t priv_id=PRIV_SYSNFS;
const char *priv_name;
priv_name = priv_getbynum(priv_id);
if (priv_name == NULL) {
printf("Error getting privilege name
");
} else {
/* priv_name is constant static data
may not be modified or freed */
printf("Privilege Name : %s
",priv_name);
}
}
SEE ALSO priv_getbyname(3), priv_set_to_str(3), priv_str_to_set(3), privileges(5).
priv_getbynum(3)
Check Out this Related Man Page
priv_str_to_set(3) Library Functions Manual priv_str_to_set(3)NAME
priv_str_to_set(), priv_set_to_str() - privilege name to set conversion function
SYNOPSIS
Parameters
priv_list The list of privilege names, passed as a string, separated by one or more characters from delimiter. It may also
contain the compound privileges (basic, basicroot, and policy).
delimiter Separates the privileges in priv_list.
index_ptr If an error occurs while parsing the list of privilege names, the pointer pointed to by index_ptr is set to point to
the remainder of the string after the error occurred, so long as index_ptr is not a NULL pointer.
delimiter Separates the individual privilege names by any of the specified characters. If delimiter is a NULL character, the
default delimiter of comma is used.
flag Bit mask with the following bit positions defined: Exactly one of the two flags must be passed. When flag is the
resulting string uses the compound privileges and to arrive at a short representation.
priv_vec Specifies privilege set.
DESCRIPTION
priv_str_to_set Conversion
converts a list of privilege names to a privilege set.
priv_list is a string consisting of privilege names and/or compound privileges. The individual elements in the string are separated by one
or more characters of delimiter .
Any privilege in the list priv_list can be optionally preceded by an exclamation mark to be interpreted as removal. For example, means all
privileges in the compound privilege except the privilege.
The string is case-insensitive. prefix is optional to a privilege name. For example, and all have the same meaning.
priv_list is interpreted left to right, so the string is the same as an empty list of privileges, while is the same as
For a list of valid privileges (both individual privileges and compound privileges), see privileges(5).
priv_set_to_str Conversion
converts a privilege set to a string of privilege names separated by the character specified by delimiter .
RETURN VALUE
and return the following values:
pointer Successful completions. Returns a non-null pointer. The caller of is responsible for freeing the result using the The
caller of is responsible for freeing the result using the
NULL pointer
Function failed. Returns a null pointer and sets to indicate the error .
ERRORS
If any of the following conditions occur, the functions fail and set
Cannot allocate enough memory for the given data.
One or more arguments are invalid.
EXAMPLES
#include <stdio.h>
#include <sys/types.h>
#include <sys/privileges.h>
#define priv_list "PRIV_CHOWN,PRIV_CHROOT,PRIV_DACREAD"
main()
{
char *index;
priv_set_t * priv_vector;
if ( (priv_vector = priv_str_to_set( priv_list,
NULL,
&index)) == NULL )
{
perror("priv_str_to_set Failed");
if (index)
printf("Invalid privilege name starting at %s
", index);
exit(1);
}
printf("The privileges in the given privilege vector are %s
",
priv_set_to_str( priv_vector, NULL, PRIV_STR_SHORT) );
}
DEPENDENCIES
and are both part of the library.
SEE ALSO privset_free(3), privileges(5).
priv_str_to_set(3)