shexp(1) General Commands Manual shexp(1)Name
shexp - display password expiration information for a user
Syntax
shexp [-q] [username]
Description
The command is used to display a user's password expiration information. The specified username, or logname if no username is supplied, is
converted to a UID by searching through the passwd file. The UID is then used to look up the user's entry in the Auth Data Base. The
password expiration information is then printed out in format.
% shexp
Expires Tue Dec 6 10:49:18 EST 1988
If the password has already expired the word Expires will be replaced with the word Expired. If password expiration is disabled for the
particular user in question the output of will be Never expires.
Options-q Instead of displaying the expiration date and time in format, outputs it as three decimal numbers: the minimum password lifetime, the
maximum password lifetime, and the password modification time. All three numbers are displayed as they are found in the database.
Restrictions
Only the super-user may obtain information about users with UIDs other than the real UID of the invoking process.
Diagnostics
User not found in passwd data base.
There is no entry in for the specified username.
Cannot stat auth file.
The database is missing (security features may not be enabled).
Insufficient privilege.
An insufficiently privileged user is asking for information about a username with a UID different then their current real-UID.
An exit value of 0 indicates a successful operation, any other exit status indicates an error.
FilesSee Alsopasswd(1), getauthuid(3), auth(5)
Security Guide for Users
shexp(1)
Check Out this Related Man Page
authenticate_user(3x)authenticate_user(3x)Name
authenticate_user - authenticate user
Syntax
#include <pwd.h>
#include <auth.h> /* For error codes */
int authenticate_user(user, password, line)
struct passwd *user;
char *password;
char *line;
Arguments
user The UID.
password
The password for the UID.
line The name of the login line as it is listed in
Description
The routine authenticates a username/UID against a supplied password and returns a nonnegative integer on success. The value returned is
the number of failed login authentication attempts since the last successful login authentication (or zero if this feature is not enabled).
This routine is found in the library and loaded using the -lauth option.
At all security levels higher than BSD, the login fail count in the auth database is incremented if authentication fails, and cleared if it
succeeds. In addition, the account must be marked enabled for logins as defined by the Account Mask value for A_LOGIN. See for informa-
tion about the Account Mask values.
If a non-NULL value is supplied for the argument and the argument is not the empty string, the function also verifies that the specified
user is allowed access through that line. In particular, accounts with UID equal to zero will only return success if the specified line is
marked secure in the file.
Restrictions
The process must have read access to the auth database to authenticate users in a secure environment.
The process must have read/write access to the auth database to update the authentication fail count.
If auth information is being served through BIND, the process is required to obtain a Kerberos ticket for that service before invoking this
function.
Example
extern 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
", status);
Return Values
When successful, the routine returns the number of failed login authentication attempts since last successful login authentication.
When an error occurs, is set and a negative error code is returned. The error code returned may be the same as or it may be an extended
error code defined in
Diagnostics
On error return may be set to one of the following values:
[EPERM] Either the password is incorrect, the password is expired, the specified line needs to be secure and is not, or the
account is disabled and a login authentication is required.
[EINVAL] No authentication information for user.
[ENOSYS] Security subsystem not configured correctly.
[EACCES] Process does not have read access to the necessary information.
On error return the return value may be the same as or, if errno is [EPERM], it may be one of the following additional values defined in
[A_EBADPASS] The supplied password was incorrect.
[A_ESOFTEXP] The accounts password has expired recently.
[A_EHARDEXP] The accounts password expired quite some time ago.
[A_ENOLOGIN] The account is not enabled.
[A_EOPENLINE] The account requires a secure line and the specified line was not marked that way in
FilesEnvironment
If the system is operating in the BSD security level, the password expiration, login fail count, and account disabling features are not
available (and therefore are not used in authentication computations).
See Alsogetauthuid(3), getpwent(3), auth(5), passwd(5yp), ttys(5)authenticate_user(3x)