Make pw_getconf(3) set errno so we have indication on what went wrong.

Document possible errno values in the manpage.
This commit is contained in:
elad 2005-08-18 21:07:23 +00:00
parent f55b2b19ea
commit dd3453b45c
2 changed files with 23 additions and 4 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: passwd.c,v 1.39 2005/01/15 03:07:56 christos Exp $ */
/* $NetBSD: passwd.c,v 1.40 2005/08/18 21:07:23 elad Exp $ */
/*
* Copyright (c) 1987, 1993, 1994, 1995
@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: passwd.c,v 1.39 2005/01/15 03:07:56 christos Exp $");
__RCSID("$NetBSD: passwd.c,v 1.40 2005/08/18 21:07:23 elad Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@ -577,6 +577,11 @@ pw_getconf(char *data, size_t max, const char *key, const char *option)
}
fclose(fp);
if (!found)
errno = ENOENT;
if (!got)
errno = ENOTDIR;
/*
* If we got no result and were looking for a default
* value, try hard coded defaults.

View File

@ -1,4 +1,4 @@
.\" $NetBSD: pw_getconf.3,v 1.7 2003/04/16 13:35:15 wiz Exp $
.\" $NetBSD: pw_getconf.3,v 1.8 2005/08/18 21:07:23 elad Exp $
.\"
.\" Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
.\" All rights reserved.
@ -30,7 +30,7 @@
.\"
.\" from OpenBSD: pw_getconf.3,v 1.5 1999/09/21 04:52:46 csapuntz Exp
.\"
.Dd July 6, 2000
.Dd August 18, 2005
.Dt PW_GETCONF 3
.Os
.Sh NAME
@ -77,6 +77,20 @@ An empty string is returned for all errors.
.Bl -tag -width /etc/passwd.conf -compact
.It Pa /etc/passwd.conf
.El
.Sh ERRORS
.Fn pw_getconf
will fail if:
.Bl -tag -width Er
.It Bq Er ENOTDIR
If there is no key in
.Pa /etc/passwd.conf
named
.Pa key .
.It Bq Er ENOENT
If there is no option named
.Pa option
in the specified key.
.El
.Sh SEE ALSO
.Xr passwd 5 ,
.Xr passwd.conf 5