📄 authenticate.3x
字号:
.\" SCCSID: @(#)authenticate.3x ?.? 11/1/89.\".TH authenticate_user 3x .SH Nameauthenticate_user \- authenticate user.SH Syntax#include <pwd.h>.br#include <auth.h> /* For error codes */.PPint authenticate_user(\fIuser\fP, \fIpassword\fP, \fIline\fP).brstruct passwd *\fIuser\fP;.brchar *\fIpassword\fP;.brchar *\fIline\fP;.SH Arguments.TP 8\fIuser\fPThe UID..TP 8\fIpassword\fPThe password for the UID..TP 8\fIline\fPThe name of the login line as it is listed in .PN /etc/ttys ..SH Description.NXR "authenticate_user routine".NXR "password file (general)" "authenticating user"The.PN authenticate_userroutineauthenticates a username/UID against a supplied password and returnsa nonnegative integer on success.The value returned is the number of failed login authentication attempts sincethe last successful login authentication (or zero if this feature is not enabled).This routine is found in the .PN libauth.a library and loaded using the .B -lauthoption..PPAt all security levels higher than .B BSD,the login fail count in the auth databaseis incremented if authenticationfails, and cleared if it succeeds.In addition, the account must be markedenabled for logins as defined by the Account Mask value for A_LOGIN.See.MS auth 5for information about the Account Mask values..PPIf a non-NULL value is supplied for the.PN lineargument.I andthe argument is not the empty string,the function also verifies that the specified user is allowedaccess through that line. In particular, accounts with UID equal to zerowill only return success if the specified line is marked.B securein the.PN /etc/ttysfile..SH Restrictions.NXR "authenticate_user subroutine" "restricted"The processmust have read access to the auth database to authenticate users in a secure environment..PPThe process must have read/write access to the auth database to update the authentication fail count..PPIf auth information is being served through BIND, the process isrequired to obtain a Kerberos ticket for that service beforeinvoking this function..SH Example.EXextern int errno;struct passwd *pwd;int status;pwd = getpwnam("root");status = authenticate_user(pwd, "rootpass", "/dev/console");if(status < 0) if(errno == EPERM) puts("Login failed"); else perror("authenticate_user");else if(status > 0) printf("%d failed attempts\\n", status);.EE.SH Return ValuesWhen successful, the routine returns the number of failed login authentication attempts since last successfullogin authentication..PPWhen an error occurs, .PN errnois set and a negative error code is returned. The error code returnedmay be the same as.PN errnoor it may be an extended error code defined in.PN auth.h ..SH DiagnosticsOn error return.PN errnomay be set to one of the following values:.sp.TP 18[EPERM]Either the password is incorrect, the password is expired, the specified lineneeds to be secure and is not, or the account is disabled and a loginauthentication is required..TP 18[EINVAL]No authentication information for user..TP 18[ENOSYS]Security subsystem not configured correctly..TP 18[EACCES]Process does not have read access to the necessary information..PPOn error return the return value may be the same as.PN errnoor, if errno is[EPERM],it may be one of the following additional values defined in.PN auth.h :.sp.TP 18[A_EBADPASS]The supplied password was incorrect..TP 18[A_ESOFTEXP]The accounts password has expired recently..TP 18[A_EHARDEXP]The accounts password expired quite some time ago..TP 18[A_ENOLOGIN]The account is not enabled..TP 18[A_EOPENLINE]The account requires a secure line and the specified line was not markedthat way in.PN /etc/ttys ..SH Files.PN /etc/auth.dir.br.PN /etc/auth.pag.br.PN /etc/svc.conf.br.PN /etc/ttys.SH EnvironmentIf the system is operating in theBSDsecurity level,the password expiration, login fail count, andaccount disabling featuresare not available (and therefore are not usedin authentication computations)..SH See Alsogetauthuid(3), getpwent(3), auth(5), passwd(5yp), ttys(5)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -