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_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

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