Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: note misleading error code in uv_os_get_passwd #3926

Open
wants to merge 1 commit into
base: v1.x
Choose a base branch
from

Conversation

theSuess
Copy link

If an effective uid does not have an entry in the passwd file, the uv_os_get_passwd function will return ENOENT which has misled our debugging efforts to look for missing files even if they were present. I've added a short note to the documentation to help others encountering similar issues in the future.

@@ -541,6 +541,10 @@ API
memory allocated to `pwd` needs to be freed with
:c:func:`uv_os_free_passwd`.

.. note::
If the effective uid does not have an entry in the password file this
function will return ENOENT even if the file exists.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
function will return ENOENT even if the file exists.
function will return `UV_ENOENT` even if the file exists.

I kind of feel we shouldn't be using the phrase "password file" since there doesn't have to be one (e.g., on systems that use LDAP-based authentication) but I'm not sure what to replace "password file entry" on line 536 with.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think "user source" or "user database" would fit well

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's a good suggestion.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took a look at the windows source, and it looks like the specific ENOENT issue is only relevant for unix. Also, the term password file is used all over the documentation of this function.

Maybe prefixing this block with On Unix systems, if the effective uid... would be the way to go

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd consider UV_ENOENT being Unix-only an implementation detail. It's something that can change in the future. I wouldn't mention that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What can be particularly confusing here is that the authoritative information for linux systems now comes not directly from /etc/password but from /etc/nsswitch.conf which specifies a list of dynamic library (such as libnss_files.so) to open to search for pwnam info corresponding to the given uid. The man page has this to say about the error:

       0 or ENOENT or ESRCH or EBADF or EPERM or ...
              The given name or uid was not found.

@stale stale bot removed the stale label May 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants