authenticate_user.3x
来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· 3X 代码 · 共 179 行
3X
179 行
.\" SCCSID: @(#)authenticate.3x ?.? 11/1/89.\".\" 28Dec90: Peter Baker.\".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 2\fIuser\fPA pointer to the passwd entry..TP 2\fIpassword\fPA pointer to the password..TP 2\fIline\fPThe name of the terminal line as it is listed in the .PN /etc/ttys file..SH Description.NXR "authenticate_user routine".NXR "password file (general)" "authenticating user"The.PN authenticate_userroutineauthenticates a user name or 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 with 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 lineargumentandthe argument is not the empty string,the function also verifies that the specified user is allowedaccess through that line. In particular, accounts with a UID equal to zerowill return success only 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, .I errnois set and a negative error code is returned. The error code returnedmay be the same as.I errnoor it may be an extended error code defined in.PN auth.h ..SH DiagnosticsOn error return.I 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.I errnoor, if .I 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 account's password expired recently..TP 18[A_EHARDEXP]The account's 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 the.PN /etc/ttys file..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 the.B BSDsecurity level,the password expiration, login fail count, andaccount disabling featuresare not available (and therefore are not usedin authentication computations)..SH See Alsogetauthent(3x), getpwent(3), auth(5), passwd(5yp), ttys(5)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?