0

The File module has function such as File:file_info() and File:read_file_info that return the #file_info record relative to a file. It contains fields such as uid and gid that are numeric identifiers that relate to the OS user id and group id.

All file operations use the numeric uid and gid values, but it would be nice to identify it by user name (string), considering the uid on a host might be different than another host, but the user name might be the same by matters of department convention (installation policy/etc).

Question: Is there a module or function that works on most operating systems to retrieve the user name and group name for a given uid or gid ?

1 Answer 1

2

The C function of choice is getpwuid for POSIX-compliant operating systems. To get the group name, the equivalent is getgrgid.

Jungerl used to have a posix_drv driver module that provided both, among other things. But it's pretty old and hasn't survived the changes in R15 that affect driver APIs.

An alternative might be this: https://github.com/sergey-miryanov/erlang-pwd - gives you a get_by_uid (that calls getpwuid) but does not have an equivalent to getgrgid.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.