mailing list of musl libc
 help / color / mirror / code / Atom feed
* getspnam: errno=ENOENT for absent user
@ 2018-12-25 22:07 Philippe Grégoire
  2018-12-26 12:29 ` Szabolcs Nagy
  0 siblings, 1 reply; 4+ messages in thread
From: Philippe Grégoire @ 2018-12-25 22:07 UTC (permalink / raw)
  To: musl

Hi,

I'm working with saltstack on Alpine Linux and am getting trouble
managing users. I tracked the problem down to musl and the fact
that getspnam sets errno to ENOENT when a user is missing. This
behavior differs from glibc which leaves errno to 0 and makes
the user relies on the return value; when the name is missing.

Semantically, ENOENT makes sense, but this is breaking compatibility
with other softwares, at the moment. I'll send a patch over to
saltstack so that current systems are supported, but believe it
should be fixed here too for future compatibility. What do you think?

Please, Cc me for reply as I'm not subscribed.


Program to demonstrate the issue:

#include <errno.h>
#include <shadow.h>
#include <stdio.h>
int main(void)
{
         errno = 0;
         void* r = getspnam("enoent);
         perror("getspnam");
         printf("%p\n", r);
}

On Debian:
getspnam: Success
(nil)

On Alpine:
getspnam: No such file or directory
0



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: getspnam: errno=ENOENT for absent user
  2018-12-25 22:07 getspnam: errno=ENOENT for absent user Philippe Grégoire
@ 2018-12-26 12:29 ` Szabolcs Nagy
  2018-12-26 15:47   ` Rich Felker
  0 siblings, 1 reply; 4+ messages in thread
From: Szabolcs Nagy @ 2018-12-26 12:29 UTC (permalink / raw)
  To: musl; +Cc: Philippe Grégoire

* Philippe Grégoire <pg@pgregoire.xyz> [2018-12-25 17:07:14 -0500]:
> I'm working with saltstack on Alpine Linux and am getting trouble
> managing users. I tracked the problem down to musl and the fact
> that getspnam sets errno to ENOENT when a user is missing. This
> behavior differs from glibc which leaves errno to 0 and makes
> the user relies on the return value; when the name is missing.
> 
> Semantically, ENOENT makes sense, but this is breaking compatibility
> with other softwares, at the moment. I'll send a patch over to
> saltstack so that current systems are supported, but believe it
> should be fixed here too for future compatibility. What do you think?

based on

http://pubs.opengroup.org/onlinepubs/9699919799/functions/getpwnam.html
"If the requested entry was not found, errno shall not be changed."

this should be fixed in musl.

> 
> Please, Cc me for reply as I'm not subscribed.
> 
> 
> Program to demonstrate the issue:
> 
> #include <errno.h>
> #include <shadow.h>
> #include <stdio.h>
> int main(void)
> {
>         errno = 0;
>         void* r = getspnam("enoent);
>         perror("getspnam");
>         printf("%p\n", r);
> }
> 
> On Debian:
> getspnam: Success
> (nil)
> 
> On Alpine:
> getspnam: No such file or directory
> 0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: getspnam: errno=ENOENT for absent user
  2018-12-26 12:29 ` Szabolcs Nagy
@ 2018-12-26 15:47   ` Rich Felker
  2018-12-28 22:00     ` Rich Felker
  0 siblings, 1 reply; 4+ messages in thread
From: Rich Felker @ 2018-12-26 15:47 UTC (permalink / raw)
  To: musl; +Cc: Philippe Grégoire

On Wed, Dec 26, 2018 at 01:29:17PM +0100, Szabolcs Nagy wrote:
> * Philippe Grégoire <pg@pgregoire.xyz> [2018-12-25 17:07:14 -0500]:
> > I'm working with saltstack on Alpine Linux and am getting trouble
> > managing users. I tracked the problem down to musl and the fact
> > that getspnam sets errno to ENOENT when a user is missing. This
> > behavior differs from glibc which leaves errno to 0 and makes
> > the user relies on the return value; when the name is missing.
> > 
> > Semantically, ENOENT makes sense, but this is breaking compatibility
> > with other softwares, at the moment. I'll send a patch over to
> > saltstack so that current systems are supported, but believe it
> > should be fixed here too for future compatibility. What do you think?
> 
> based on
> 
> http://pubs.opengroup.org/onlinepubs/9699919799/functions/getpwnam.html
> "If the requested entry was not found, errno shall not be changed."
> 
> this should be fixed in musl.

Thanks for checking this. I'll write and commit a fix.

Rich


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: getspnam: errno=ENOENT for absent user
  2018-12-26 15:47   ` Rich Felker
@ 2018-12-28 22:00     ` Rich Felker
  0 siblings, 0 replies; 4+ messages in thread
From: Rich Felker @ 2018-12-28 22:00 UTC (permalink / raw)
  To: musl

On Wed, Dec 26, 2018 at 10:47:19AM -0500, Rich Felker wrote:
> On Wed, Dec 26, 2018 at 01:29:17PM +0100, Szabolcs Nagy wrote:
> > * Philippe Grégoire <pg@pgregoire.xyz> [2018-12-25 17:07:14 -0500]:
> > > I'm working with saltstack on Alpine Linux and am getting trouble
> > > managing users. I tracked the problem down to musl and the fact
> > > that getspnam sets errno to ENOENT when a user is missing. This
> > > behavior differs from glibc which leaves errno to 0 and makes
> > > the user relies on the return value; when the name is missing.
> > > 
> > > Semantically, ENOENT makes sense, but this is breaking compatibility
> > > with other softwares, at the moment. I'll send a patch over to
> > > saltstack so that current systems are supported, but believe it
> > > should be fixed here too for future compatibility. What do you think?
> > 
> > based on
> > 
> > http://pubs.opengroup.org/onlinepubs/9699919799/functions/getpwnam.html
> > "If the requested entry was not found, errno shall not be changed."
> > 
> > this should be fixed in musl.
> 
> Thanks for checking this. I'll write and commit a fix.

Should be fixed in commit 9db81b862d95326d43af7c7fae9078ad9ff5bd6f
with a related tweak in de7dc1318f493184b20f7661bc12b1829b957b67.

Rich


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-12-28 22:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-25 22:07 getspnam: errno=ENOENT for absent user Philippe Grégoire
2018-12-26 12:29 ` Szabolcs Nagy
2018-12-26 15:47   ` Rich Felker
2018-12-28 22:00     ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).