nfs4_uid_to_name(3)
πΈ NAME πΈ
okay bestie, this page is nfs4_uid_to_name(3) (Library Functions Manual energy π
) and it's the whole squad of ID mapping routines used for NFSv4. Meet the girls:
nfs4_uid_to_namenfs4_gid_to_namenfs4_name_to_uidnfs4_name_to_gidnfs4_init_name_mappingnfs4_get_default_domainnfs4_gss_princ_to_idsnfs4_gss_princ_to_grouplistnfs4_gss_princ_to_ids_exnfs4_gss_princ_to_grouplist_exnfs4_set_debug
they're all ID mapping routines used for NFSv4 and they're all iconic, no cap β¨
π 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 π
so NFSv4 uses names that look like user@domain. if you're writing code that helps the kernel map uid's (the way rpc.idmapd does) or code that processes NFSv4 ACLs, you literally need to convert between NFSv4 names and local uids and gids. it's giving essential, fr fr π¦
the nfs4_uid_to_name() and nfs4_gid_to_name() functions? you hand them a uid or gid plus domain (as a null-terminated string), and they write the corresponding nfsv4 name into the buffer you gave them in name, which must be at least len long. respect the buffer bestie, she has boundaries π
then nfs4_uid_to_owner() and nfs4_gid_to_group_owner() β same deal, you pass a uid or gid and domain (null-terminated string, as always), and they write the corresponding nfsv4 name into the buffer in name, which must be of length at least len. but if there's no valid mapping from uid or gid to a name, then the numerical string representing uid or gid gets returned instead. fallback queen π
nfs4_name_to_uid() and nfs4_name_to_gid() β you give them name (null-terminated string, you know the drill) and they return the corresponding uid or gid in the second parameter π«Ά
nfs4_owner_to_uid() and nfs4_group_owner_to_gid() β given name (null-terminated string), they return the corresponding uid or gid in the second parameter. and if there's no valid mapping from name to uid or gid, the value for the user or group "nobody" will be returned instead. not the glow-up you wanted but okay π
nfs4_init_name_mapping() must be called before using any of these functions. like, mandatory. no skipping. she reads defaults from the configuration file at the path you provide, usually "etc/idmapd.conf". do not come for me about that path, that's exactly what it says πΈ
the domain argument on the id-to-name functions is there to give the name mapper a hint for when an id might map to names in multiple domains. in most cases you should just pass the name that came back in the domain argument of nfs4_get_default_domain(), which should be called with server set to NULL. the domain should be a buffer of length len, and you can use the constant NFS4_MAX_DOMAIN_LEN to figure out a reasonable value for that length. she's the measuring tape, iykyk π
nfs4_get_grouplist(), given a name, fills the array you provided in groups with up to *ngroups group IDs corresponding to which the user name belongs to, and sets *ngroups to the actual number of such groups. but if the user belongs to more than *ngroups groups, then an error is returned and the actual number of groups is stored in *ngroups. she tells you how much room she really needed π
then the gss girlies: nfs4_gss_princ_to_ids(), nfs4_gss_princ_to_grouplist(), nfs4_gss_princ_to_ids_ex(), and nfs4_gss_princ_to_grouplist_ex() are used to convert from a gss principal name (as returned by gss_display_name()) to a uid and gid, or a list of gids. main character conversions β¨
and finally, nfs4_set_debug() lets the application set a debugging level to produce extra debugging information from inside the library. the optional logger function specifies an alternative logging function to call for the debug messages instead of the default internal function inside the library. bring your own logger if you want, she supports your choices π
ngl, the debug output is only as good as the logger you give her. no logger, no custom vibes β just the library's default.
β RETURN VALUE β
all functions return 0, or, in the case of error, -ERRNO. that's it. zero means slay, negative errno means the vibe check failed π
and that's the page, bestie!! this was the Library Functions Manual cut of nfs4_uid_to_name(3), dated 2004-08-05 β yes she's vintage, yes she still ate ππ go call nfs4_init_name_mapping() first, periodt π
π¦ where this page comes from
- alpine 3.22: nfs-utils-doc 2.6.4-r4 Β· GPL-2.0-only
- alpine 3.23: nfs-utils-doc 2.6.4-r6 Β· GPL-2.0-only
- alpine 3.24: nfs-utils-doc 2.6.4-r6 Β· GPL-2.0-only
- arch rolling: nfsidmap 3.1.1-1 Β· GPL-2.0-or-later
- centos-stream 10: libnfsidmap 1:2.8.3-9.el10 Β· BSD
- centos-stream 10: nfs-utils 1:2.8.3-9.el10 Β· MIT and GPLv2 and GPLv2+ and BSD
- centos-stream 9: libnfsidmap 1:2.5.4-45.el9 Β· BSD
- centos-stream 9: libnfsidmap 1:2.5.4-45.el9 Β· BSD
- centos-stream 9: nfs-utils 1:2.5.4-45.el9 Β· MIT and GPLv2 and GPLv2+ and BSD
- debian bookworm: nfs-common 1:2.6.2-4+deb12u1
- debian trixie: nfs-common 1:2.8.3-1
- fedora 43: libnfsidmap 1:2.8.4-0.fc43 Β· LicenseRef-Callaway-BSD
- fedora 43: libnfsidmap 1:2.8.4-0.fc43 Β· LicenseRef-Callaway-BSD
- fedora 43: libnfsidmap 1:2.8.7-6.fc43 Β· LicenseRef-Callaway-BSD
- fedora 43: libnfsidmap 1:2.8.7-6.fc43 Β· LicenseRef-Callaway-BSD
- fedora 43: nfs-utils 1:2.8.4-0.fc43 Β· LicenseRef-Callaway-MIT AND GPL-2.0-only AND GPL-2.0-or-later AND LicenseRef-Callaway-BSD
- fedora 43: nfs-utils 1:2.8.7-6.fc43 Β· LicenseRef-Callaway-MIT AND GPL-2.0-only AND GPL-2.0-or-later AND LicenseRef-Callaway-BSD
- fedora 44: libnfsidmap-devel 1:2.8.7-0.fc44 Β· BSD-3-Clause
- fedora 44: libnfsidmap-devel 1:2.8.7-0.fc44 Β· BSD-3-Clause
- fedora 44: libnfsidmap-devel 1:2.8.7-7.fc44 Β· BSD-3-Clause
- fedora 44: libnfsidmap-devel 1:2.8.7-7.fc44 Β· BSD-3-Clause
- nixos 26.05: nfs-utils 2.9.1
- nixpkgs unstable: nfs-utils 3.1.1
- opensuse-leap 16.0: nfsidmap-devel 1.0-160000.4.1 Β· GPL-2.0-or-later
- opensuse-leap 16.0: nfsidmap-devel 1.0-160000.4.1 Β· GPL-2.0-or-later
- opensuse-leap 16.0: nfsidmap-devel 1.0-160000.4.1 Β· GPL-2.0-or-later
- opensuse-leap 16.0: nfsidmap-devel 1.0-160000.4.1 Β· GPL-2.0-or-later
- ubuntu jammy: nfs-common 1:2.6.1-1ubuntu1
- ubuntu jammy: nfs-common 1:2.6.1-1ubuntu1.2
- ubuntu noble: nfs-common 1:2.6.4-3ubuntu5
- ubuntu noble: nfs-common 1:2.6.4-3ubuntu5.1
- ubuntu questing: nfs-common 1:2.8.3-1ubuntu3
- ubuntu resolute: nfs-common 1:2.8.5-1ubuntu1
- ubuntu stonking: nfs-common 1:2.9.1-1ubuntu1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms