table of contents
nfs4_uid_to_name(3) | Library Functions Manual | nfs4_uid_to_name(3) |
NAME¶
nfs4_uid_to_name, nfs4_gid_to_name, nfs4_name_to_uid, nfs4_name_to_gid,nfs4_init_name_mapping, nfs4_get_default_domain,nfs4_gss_princ_to_ids, nfs4_gss_princ_to_grouplist,nfs4_gss_princ_to_ids_ex,nfs4_gss_princ_to_grouplist_ex,nfs4_set_debug - ID mapping routines used for NFSv4
SYNOPSIS¶
#include <nfs4_idmap.h>
int nfs4_init_name_mapping(char *conffile);
int nfs4_get_default_domain(char *server, char *domain, size_t len);
int nfs4_uid_to_name(uid_t uid, char *domain, char *name, size_t len);
int nfs4_uid_to_owner(uid_t uid, char *domain, char *name, size_t len);
int nfs4_gid_to_name(gid_t gid, char *domain, char *name, size_t len);
int nfs4_gid_to_owner(gid_t gid, char *domain, char *name, size_t len);
int nfs4_name_to_uid(char *name, uid_t *uid);
int nfs4_name_to_gid(char *name, gid_t *gid);
int nfs4_owner_to_uid(char *name, uid_t *uid);
int nfs4_owner_to_gid(char *name, gid_t *gid);
int nfs4_gss_princ_to_ids(char *secname, char *princ, uid_t *uid, gid_t *gid);
int nfs4_gss_princ_to_grouplist(char *secname, char *princ, gid_t *groups, int *ngroups);
int nfs4_gss_princ_to_ids_ex(char *secname, char *princ, uid_t *uid, gid_t *gid, extra_mapping_params **ex);
int nfs4_gss_princ_to_grouplist_ex(char *secname, char *princ, gid_t *groups, int *ngroups, extra_mapping_params **ex);
void nfs4_set_debug(int dbg_level, void (*logger)(const char *, ...));
DESCRIPTION¶
NFSv4 uses names of the formuser@domain.To write code that helps the kernel map uid's (asrpc.idmapddoes) or that processes NFSv4 ACLs, you need to be able to convert betweenNFSv4 names and local uids and gids.
Thenfs4_uid_to_name()andnfs4_gid_to_name()functions, givenuidorgidanddomain(as a null-terminated string),write the corresponding nfsv4 name into the buffer provided inname,which must be of length at leastlen.
Thenfs4_uid_to_owner()andnfs4_gid_to_group_owner()functions, givenuidorgidanddomain(as a null-terminated string),write the corresponding nfsv4 name into the buffer provided inname,which must be of length at leastlen.If there is no valid mapping fromuidorgidtoname,then the numerical string representing uid or gid is returned instead.
Thenfs4_name_to_uid()andnfs4_name_to_gid()functions, givenname(as a null-terminated string), return the corresponding uid or gid inthe second parameter.
Thenfs4_owner_to_uid()andnfs4_group_owner_to_gid()functions, givenname(as a null-terminated string), return the corresponding uid or gid inthe second parameter.If there is no valid mapping fromnametouidorgidthe value for the user or group "nobody" will be returned instead.
Thenfs4_init_name_mapping()function must be called before using any of these functions. It readsdefaults from the configuration file at the provided path, usually"etc/idmapd.conf".
Thedomainargument to the id-to-name functions is there to provide a hint to the namemapper in the case where an id might be mapped to names in multiple domains.In most cases, this argument should just be the name returned in thedomainargument tonfs4_get_default_domain()which should be called withserverset to NULL. Thedomainshould be a buffer of lengthlen.The constant NFS4_MAX_DOMAIN_LEN may be used to determine a reasonablevalue for that length.
The functionnfs4_get_grouplist(),given aname,fills the provided arraygroupswith up to*ngroupsgroup IDs corresponding to which the usernamebelongs to, setting*ngroupsto the actual number of such groups. If the user belongs to more than*ngroupsgroups, then an error is returned and the actual number of groups is stored in*ngroups.
Functionsnfs4_gss_princ_to_ids(),nfs4_gss_princ_to_grouplist(),nfs4_gss_princ_to_ids_ex(),andnfs4_gss_princ_to_grouplist_ex()are used to convert from a gss principal name (as returned bygss_display_name())to a uid and gid, or list of gids.
Finally,nfs4_set_debug()allows the application to set a debugging level to produce extradebugging information from within the library. The optionalloggerfunction specifies an alternative logging function to call forthe debug messages rather than the default internal functionwithin the library.
RETURNVALUE¶
All functions return 0 or, in the case of error, -ERRNO.
2004-08-05 |