Set errno on failure, and man-page updates.
This commit is contained in:
parent
ae8f65bfac
commit
2b9c10de57
|
@ -1,4 +1,4 @@
|
||||||
.\" $NetBSD: pw_policy.3,v 1.6 2006/02/24 21:07:29 wiz Exp $
|
.\" $NetBSD: pw_policy.3,v 1.7 2006/03/19 22:58:21 elad Exp $
|
||||||
.\"
|
.\"
|
||||||
.\" Copyright 2005, 2006 Elad Efrat <elad@NetBSD.org>
|
.\" Copyright 2005, 2006 Elad Efrat <elad@NetBSD.org>
|
||||||
.\"
|
.\"
|
||||||
|
@ -23,7 +23,7 @@
|
||||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
.\" SUCH DAMAGE.
|
.\" SUCH DAMAGE.
|
||||||
.\"
|
.\"
|
||||||
.Dd February 16, 2006
|
.Dd March 19, 2006
|
||||||
.Dt PW_POLICY 3
|
.Dt PW_POLICY 3
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
|
@ -247,19 +247,20 @@ to a value returned by the called handlers and/or
|
||||||
.Xr malloc 3 .
|
.Xr malloc 3 .
|
||||||
.Pp
|
.Pp
|
||||||
.Fn pw_policy_test
|
.Fn pw_policy_test
|
||||||
returns 0 if the password follows the policy, or any of the following
|
returns 0 if the password follows the policy, or -1 if it doesn't,
|
||||||
values:
|
.Ar errno
|
||||||
|
can be set to any of the following values:
|
||||||
.Bl -tag -width Er
|
.Bl -tag -width Er
|
||||||
.It Bq Er EPERM
|
.It Bq Er EPERM
|
||||||
The password does not follow the password policy.
|
The password does not follow the password policy.
|
||||||
.It Bq Er EFAULT
|
.It Bq Er EINVAL
|
||||||
.Dv NULL
|
.Dv NULL
|
||||||
pointer was passed as the password.
|
pointer was passed as the password.
|
||||||
.El
|
.El
|
||||||
.Pp
|
.Pp
|
||||||
In addition,
|
In addition,
|
||||||
.Fn pw_policy_test
|
.Ar errno
|
||||||
can also return any of the values returned by the called handlers.
|
can be set to any error code returned by the handlers.
|
||||||
.Sh FILES
|
.Sh FILES
|
||||||
.Bl -tag -width /etc/passwd.conf -compact
|
.Bl -tag -width /etc/passwd.conf -compact
|
||||||
.It Pa /etc/passwd.conf
|
.It Pa /etc/passwd.conf
|
||||||
|
@ -314,8 +315,7 @@ Check if
|
||||||
follows the policy in
|
follows the policy in
|
||||||
.Ar policy :
|
.Ar policy :
|
||||||
.Bd -literal -offset indent
|
.Bd -literal -offset indent
|
||||||
error = pw_policy_test(policy, the_password);
|
if (pw_policy_test(policy, the_password) != 0)
|
||||||
if (error == EPERM)
|
|
||||||
warnx("Please refer to the password policy");
|
warnx("Please refer to the password policy");
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: pw_policy.c,v 1.8 2006/03/19 22:18:25 christos Exp $ */
|
/* $NetBSD: pw_policy.c,v 1.9 2006/03/19 22:58:21 elad Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright 2005, 2006 Elad Efrat <elad@NetBSD.org>
|
* Copyright 2005, 2006 Elad Efrat <elad@NetBSD.org>
|
||||||
|
@ -460,8 +460,10 @@ pw_policy_test(pw_policy_t policy, char *pw)
|
||||||
{
|
{
|
||||||
struct pw_policy_handler *hp;
|
struct pw_policy_handler *hp;
|
||||||
|
|
||||||
if (policy == NULL)
|
if (policy == NULL) {
|
||||||
|
errno = EINVAL;
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
hp = &handlers[0];
|
hp = &handlers[0];
|
||||||
while (hp->name != NULL) {
|
while (hp->name != NULL) {
|
||||||
|
|
Loading…
Reference in New Issue