|
NAMEcap_getpwent , cap_getpwnam ,
cap_getpwuid , cap_getpwent_r ,
cap_getpwnam_r ,
cap_getpwuid_r ,
cap_setpassent , cap_setpwent ,
cap_endpwent ,
cap_pwd_limit_cmds ,
cap_pwd_limit_fields ,
cap_pwd_limit_users —
library for password database operations in capability
mode
LIBRARYlibrary “libcap_pwd”SYNOPSIS#include <libcasper.h>
#include <casper/cap_pwd.h>
struct passwd *
struct passwd *
struct passwd *
int
int
int
int
void
void
int
int
int
DESCRIPTIONThe functionscap_getpwent (),
cap_getpwnam (),
cap_getpwuid (),
cap_getpwent_r (),
cap_getpwnam_r (),
cap_getpwuid_r (),
cap_setpassent (),
cap_setpwent (), and
cap_endpwent () are respectively equivalent to
getpwent(3),
getpwnam(3),
getpwuid(3),
getpwent_r(3),
getpwnam_r(3),
getpwuid_r(3),
setpassent(3),
setpwent(3),
and
cap_endpwent(3)
except that the connection to the system.pwd service
needs to be provided.
The The The EXAMPLESThe following example first opens a capability to casper and then uses this capability to create thesystem.pwd casper service and
uses it to get a user name.
cap_channel_t *capcas, *cappwd; const char *cmds[] = { "getpwuid" }; const char *fields[] = { "pw_name" }; uid_t uid[] = { 1 }; struct passwd *passwd; /* Open capability to Casper. */ capcas = cap_init(); if (capcas == NULL) err(1, "Unable to contact Casper"); /* Enter capability mode sandbox. */ if (cap_enter() < 0 && errno != ENOSYS) err(1, "Unable to enter capability mode"); /* Use Casper capability to create capability to the system.pwd service. */ cappwd = cap_service_open(capcas, "system.pwd"); if (cappwd == NULL) err(1, "Unable to open system.pwd service"); /* Close Casper capability, we don't need it anymore. */ cap_close(capcas); /* Limit service to one single function. */ if (cap_pwd_limit_cmds(cappwd, cmds, nitems(cmds))) err(1, "Unable to limit access to system.pwd service"); /* Limit service to one field as we only need name of the user. */ if (cap_pwd_limit_fields(cappwd, fields, nitems(fields))) err(1, "Unable to limit access to system.pwd service"); /* Limit service to one uid. */ if (cap_pwd_limit_users(cappwd, NULL, 0, uid, nitems(uid))) err(1, "Unable to limit access to system.pwd service"); passwd = cap_getpwuid(cappwd, uid[0]); if (passwd == NULL) err(1, "Unable to get name of user"); printf("UID %d is associated with name %s.\n", uid[0], passwd->pw_name); cap_close(cappwd); SEE ALSOcap_enter(2), endpwent(3), err(3), getpwent(3), getpwent_r(3), getpwnam(3), getpwnam_r(3), getpwuid(3), getpwuid_r(3), setpassent(3), setpwent(3), capsicum(4), nv(9)HISTORYThecap_pwd service first appeared in
FreeBSD 10.3.
AUTHORSThecap_pwd service was implemented by
Pawel Jakub Dawidek
<pawel@dawidek.net>
under sponsorship from the FreeBSD Foundation.
This manual page was written by
Visit the GSP FreeBSD Man Page Interface. |