| 1 |
.TH nfs4_uid_to_name 3 2004-08-05 |
| 2 |
.SH NAME |
| 3 |
nfs4_uid_to_name, nfs4_gid_to_name, nfs4_name_to_uid, nfs4_name_to_gid, |
| 4 |
nfs4_init_name_mapping, nfs4_get_default_domain, |
| 5 |
nfs4_gss_princ_to_ids, nfs4_gss_princ_to_grouplist, |
| 6 |
nfs4_gss_princ_to_ids_ex, |
| 7 |
nfs4_gss_princ_to_grouplist_ex, |
| 8 |
nfs4_set_debug \- ID mapping routines used for NFSv4 |
| 9 |
.SH SYNOPSIS |
| 10 |
.B #include <nfs4_idmap.h> |
| 11 |
.sp |
| 12 |
.BI "int nfs4_init_name_mapping(char *conffile);" |
| 13 |
.sp |
| 14 |
.BI "int nfs4_get_default_domain(char *server, char *domain, size_t len);" |
| 15 |
.sp |
| 16 |
.BI "int nfs4_uid_to_name(uid_t uid, char *domain, char *name, size_t len);" |
| 17 |
.sp |
| 18 |
.BI "int nfs4_uid_to_owner(uid_t uid, char *domain, char *name, size_t len);" |
| 19 |
.sp |
| 20 |
.BI "int nfs4_gid_to_name(gid_t gid, char *domain, char *name, size_t len);" |
| 21 |
.sp |
| 22 |
.BI "int nfs4_gid_to_owner(gid_t gid, char *domain, char *name, size_t len);" |
| 23 |
.sp |
| 24 |
.BI "int nfs4_name_to_uid(char *name, uid_t *uid);" |
| 25 |
.sp |
| 26 |
.BI "int nfs4_name_to_gid(char *name, gid_t *gid);" |
| 27 |
.sp |
| 28 |
.BI "int nfs4_owner_to_uid(char *name, uid_t *uid);" |
| 29 |
.sp |
| 30 |
.BI "int nfs4_owner_to_gid(char *name, gid_t *gid);" |
| 31 |
.sp |
| 32 |
.BI "int nfs4_gss_princ_to_ids(char *secname, char *princ, uid_t *uid, gid_t *gid);" |
| 33 |
.sp |
| 34 |
.BI "int nfs4_gss_princ_to_grouplist(char *secname, char *princ, gid_t *groups, int *ngroups);" |
| 35 |
.sp |
| 36 |
.BI "int nfs4_gss_princ_to_ids_ex(char *secname, char *princ, uid_t *uid, gid_t *gid, extra_mapping_params **ex);" |
| 37 |
.sp |
| 38 |
.BI "int nfs4_gss_princ_to_grouplist_ex(char *secname, char *princ, gid_t *groups, int *ngroups, extra_mapping_params **ex);" |
| 39 |
.sp |
| 40 |
.BI "void nfs4_set_debug(int dbg_level, void (*logger)(const char *, ...));" |
| 41 |
.sp |
| 42 |
.fi |
| 43 |
.SH DESCRIPTION |
| 44 |
NFSv4 uses names of the form |
| 45 |
.IR user@domain . |
| 46 |
To write code that helps the kernel map uid's (as |
| 47 |
rpc.idmapd |
| 48 |
does) or that processes NFSv4 ACLs, you need to be able to convert between |
| 49 |
NFSv4 names and local uids and gids. |
| 50 |
.PP |
| 51 |
The |
| 52 |
.B nfs4_uid_to_name() |
| 53 |
and |
| 54 |
.B nfs4_gid_to_name() |
| 55 |
functions, given |
| 56 |
.I uid |
| 57 |
or |
| 58 |
.I gid |
| 59 |
and |
| 60 |
.I domain |
| 61 |
(as a null-terminated string), |
| 62 |
write the corresponding nfsv4 name into the buffer provided in |
| 63 |
.IR name , |
| 64 |
which must be of length at least |
| 65 |
.IR len . |
| 66 |
.PP |
| 67 |
The |
| 68 |
.B nfs4_uid_to_owner() |
| 69 |
and |
| 70 |
.B nfs4_gid_to_group_owner() |
| 71 |
functions, given |
| 72 |
.I uid |
| 73 |
or |
| 74 |
.I gid |
| 75 |
and |
| 76 |
.I domain |
| 77 |
(as a null-terminated string), |
| 78 |
write the corresponding nfsv4 name into the buffer provided in |
| 79 |
.IR name , |
| 80 |
which must be of length at least |
| 81 |
.IR len . |
| 82 |
If there is no valid mapping from |
| 83 |
.I uid |
| 84 |
or |
| 85 |
.I gid |
| 86 |
to |
| 87 |
.IR name , |
| 88 |
then the numerical string representing uid or gid is returned instead. |
| 89 |
.PP |
| 90 |
The |
| 91 |
.B nfs4_name_to_uid() |
| 92 |
and |
| 93 |
.B nfs4_name_to_gid() |
| 94 |
functions, given |
| 95 |
.I name |
| 96 |
(as a null-terminated string), return the corresponding uid or gid in |
| 97 |
the second parameter. |
| 98 |
.PP |
| 99 |
The |
| 100 |
.B nfs4_owner_to_uid() |
| 101 |
and |
| 102 |
.B nfs4_group_owner_to_gid() |
| 103 |
functions, given |
| 104 |
.I name |
| 105 |
(as a null-terminated string), return the corresponding uid or gid in |
| 106 |
the second parameter. |
| 107 |
If there is no valid mapping from |
| 108 |
.I name |
| 109 |
to |
| 110 |
.I uid |
| 111 |
or |
| 112 |
.I gid |
| 113 |
the value for the user or group "nobody" will be returned instead. |
| 114 |
. PP |
| 115 |
The |
| 116 |
.B nfs4_init_name_mapping() |
| 117 |
function must be called before using any of these functions. It reads |
| 118 |
defaults from the configuration file at the provided path, usually |
| 119 |
"etc/idmapd.conf". |
| 120 |
.PP |
| 121 |
The |
| 122 |
.I domain |
| 123 |
argument to the id-to-name functions is there to provide a hint to the name |
| 124 |
mapper in the case where an id might be mapped to names in multiple domains. |
| 125 |
In most cases, this argument should just be the name returned in the |
| 126 |
.I domain |
| 127 |
argument to |
| 128 |
.B nfs4_get_default_domain() |
| 129 |
which should be called with |
| 130 |
.I server |
| 131 |
set to NULL. The |
| 132 |
.I domain |
| 133 |
should be a buffer of length |
| 134 |
.IR len . |
| 135 |
The constant NFS4_MAX_DOMAIN_LEN may be used to determine a reasonable |
| 136 |
value for that length. |
| 137 |
.PP |
| 138 |
The function |
| 139 |
.BR nfs4_get_grouplist() , |
| 140 |
given a |
| 141 |
.IR name , |
| 142 |
fills the provided array |
| 143 |
.I groups |
| 144 |
with up to |
| 145 |
.I *ngroups |
| 146 |
group IDs corresponding to which the user |
| 147 |
.I name |
| 148 |
belongs to, setting |
| 149 |
.I *ngroups |
| 150 |
to the actual number of such groups. If the user belongs to more than |
| 151 |
.I *ngroups |
| 152 |
groups, then an error is returned and the actual number of groups is stored in |
| 153 |
*ngroups. |
| 154 |
.PP |
| 155 |
Functions |
| 156 |
.BR nfs4_gss_princ_to_ids() , |
| 157 |
.BR nfs4_gss_princ_to_grouplist() , |
| 158 |
.BR nfs4_gss_princ_to_ids_ex() , |
| 159 |
and |
| 160 |
.B nfs4_gss_princ_to_grouplist_ex() |
| 161 |
are used to convert from a gss principal name (as returned by |
| 162 |
.BR gss_display_name() ) |
| 163 |
to a uid and gid, or list of gids. |
| 164 |
.PP |
| 165 |
Finally, |
| 166 |
.B nfs4_set_debug() |
| 167 |
allows the application to set a debugging level to produce extra |
| 168 |
debugging information from within the library. The optional |
| 169 |
.I logger |
| 170 |
function specifies an alternative logging function to call for |
| 171 |
the debug messages rather than the default internal function |
| 172 |
within the library. |
| 173 |
.SH RETURN VALUE |
| 174 |
All functions return 0 or, in the case of error, -ERRNO. |