Bug 67958

Summary: shared/util.c:get_group_creds() should not return -ESRCH upon error
Product: systemd Reporter: Corey Ashford <cjashfor>
Component: generalAssignee: systemd-bugs
Status: RESOLVED NOTOURBUG QA Contact: systemd-bugs
Severity: normal    
Priority: medium    
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description Corey Ashford 2013-08-09 20:37:40 UTC
get_group_creds is returning -ESRCH upon error.  The name of this error code sounds reasonable, but the error string is "No such process".  This is a confusing error message for looking up a user group name.

The same problem exists for the functions get_user_creds() and get_home_dir().

We ran into this error during boot-up:
systemd-journald: Failed to resolve 'systemd-journal' group:
No such process

I ended up downloading the source of systemd to see if it was talking about a cgroup or a user group.

Instead of ESRCH, I'd suggest ENOENT.
There doesn't seem to be a perfect error code for this, but ESRCH is not a good choice in my opinion.
Comment 1 Lennart Poettering 2013-09-12 17:26:32 UTC
Well, the underlying getpwuid() tends to return ESRCH too, and in many cases we just pass that on (see getpwuid(3)). I am not sure it's such a good idea to tape over that...
Comment 2 Corey Ashford 2013-09-12 19:14:52 UTC
I see what you're saying, but on the other hand, getpwuid can also return ENOENT in the event that it can't find the user name.

And seeing as how this error ends up getting display to a user, I think "papering over" may not be a bad choice here. "no such process" is completely misleading and confusing.
Comment 3 Lennart Poettering 2013-09-12 20:01:26 UTC
But "No such file or directory" is misleading too. Users are neither files nor directories nor processes... Sounds wrong replacing one misleading error code with another misleading error code...
Comment 4 Corey Ashford 2013-09-12 20:06:34 UTC
Good point.  In that case, maybe doing some interpretation of the error
code rather than using perror (or strerror_r, etc.) to print the error message.
Comment 5 Lennart Poettering 2014-05-24 09:55:24 UTC
The problem is actually that NSS modules can return whatever they want, and they are not very good at sticking to clear rules when to return what.
Comment 6 Lennart Poettering 2014-06-25 10:36:18 UTC
Honestly, I am not sure we can fix this really. NSS modules can return whatever they want, and we shouldn't try to hide the precise errors. If this should be fixed, then please fix it in glibc.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.