Sponsored Content
Operating Systems AIX How to check password expiry in AIX? Post 302273407 by aixylinux on Sunday 4th of January 2009 01:29:29 PM
Old 01-04-2009
Use passwdexpired system call

If you can write a C program, you can call the passwdexpired() system call to get this information. See:

Help -

Here's a code fragment that does the trick. Unfortunately, due to employer restrictions, I can't share the whole code with you. I hacked this out of an existing module, so it is illustrative only.

/* typical includes needed by C programs */
#include <string.h>
#include <ctype.h>
#include <sys/types.h>
#include <time.h>
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>

/* this is the include needed for passwdexpired */
#include <usersec.h>

void main( int argc, char* argv[]) {
char* userid=argv[1];

char p[100] = "";
int rc;

rc = putenv( "LANG=C" ); /* force LANG=C */

/* get password date expiration string */
rc = passwdexpired( userid, &p );
if ( rc == 1 || rc == 2 )
{
printf( "%s\nReset the password \n", p);
exit( 2 );
}

/* some other error */
if ( rc != 0 )
{
if ( errno == ENOENT || errno == ESRCH )
{
fprintf( stderr, "User %s is not defined\n", userid );
}
else
{
fprintf( stderr, "passwdexpired() rc=%d, %s\n", rc, strerror(errno) );
}
exit( 1 );
}

printf( "passwdexpired returned message:\n'%s'\n", p );

}

The binary file must be setuid root, else root must run the program.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

password expiry

Hi, under SUN Unix, in which file the expiry date of a user password is indicated ? Many thanks. (2 Replies)
Discussion started by: big123456
2 Replies

2. Solaris

Notification of password expiry.

Hi, Is there any way of sending an email to a number of users indicating that the passwords of user accounts will expire? Currently we have a test server with a number of oracle test accounts on it. Each of these accounts correspond to an instance of Oracle on the server. These... (2 Replies)
Discussion started by: sparcman
2 Replies

3. Solaris

Notification of password expiry.

Hi, Is there any way of sending an email to a number of users indicating that the passwords of user accounts will expire? Currently we have a test server with a number of oracle test accounts on it. Each of these accounts correspond to an instance of Oracle on the server. These... (2 Replies)
Discussion started by: sparcman
2 Replies

4. Solaris

SSH Password-less login fails on password expiry.

Hi Gurus I have a few Sol 5.9 servers and i have enabled password less authentication between them for my user ID. Often i have found that when my password has expired,the login fails. Resetting my password reenables the keys. Do i need to do something to avoid this scenario or is this... (2 Replies)
Discussion started by: Renjesh
2 Replies

5. Shell Programming and Scripting

password expiry notification

Hi, Could someone please let me know how to write script for passwd expiry notification on salaries boxes. Regards Dnyan (1 Reply)
Discussion started by: dnyan
1 Replies

6. Solaris

disable password expiry

Hi How do i disable password expiration on ldap? It runs on Solaris 10 machine. Thanks in advance. (3 Replies)
Discussion started by: hrist
3 Replies

7. Shell Programming and Scripting

Password expiry date check for hp servers

Hi All, Can anybody help me, to find the command to check for the password expiry date for the hp servers. Thanks, Deepak (3 Replies)
Discussion started by: dswain
3 Replies

8. Shell Programming and Scripting

Password expiry report

Hi All, I want to write a script that will send the alert when linux server password expiry for user 'x' is less than 12 days. I have written the below script but this is not working for expiry date 04 july script;- P_EXPIRY_DATE=`chage -l msdp| grep 'Password expires' | awk ' {... (2 Replies)
Discussion started by: abhigrkist
2 Replies

9. Solaris

Command to find out password expiry

Hi, I would like to know is there command which will tell me when password will be expire and when last password was changed ? like on linux chage -l <username? (2 Replies)
Discussion started by: manoj.solaris
2 Replies

10. AIX

UNIX cmd to check for non expiry type password

Hi, Here's the version of unix that we are working on. > uname -a AIX yyyyyyyy 1 6 00F613E24C00 @:on(cluster303)/iishomea/kmani00-> i have application id: aaabbb Now i need to check whether the password for the application id set to non expiry type or not. Moreover, with that unix... (3 Replies)
Discussion started by: kmanivan82
3 Replies
explain_fprintf(3)					     Library Functions Manual						explain_fprintf(3)

NAME
explain_fprintf - explain fprintf(3) errors SYNOPSIS
#include <libexplain/fprintf.h> const char *explain_fprintf(FILE *fp, const char *format, ...); const char *explain_errno_fprintf(int errnum, FILE *fp, const char *format, ...); void explain_message_fprintf(char *message, int message_size, FILE *fp, const char *format, ....); void explain_message_errno_fprintf(char *message, int message_size, int errnum, FILE *fp, const char *format, ...); DESCRIPTION
These functions may be used to obtain explanations for errors returned by the fprintf(3) system call. explain_fprintf const char *explain_fprintf(FILE *fp, const char *format, ...); The explain_fprintf function is used to obtain an explanation of an error returned by the fprintf(3) system call. The least the message will contain is the value of strerror(errno), but usually it will do much better, and indicate the underlying cause in more detail. The errno global variable will be used to obtain the error value to be decoded. fp The original fp, exactly as passed to the fprintf(3) system call. format The original format, exactly as passed to the fprintf(3) system call. Returns: The message explaining the error. This message buffer is shared by all libexplain functions which do not supply a buffer in their argument list. This will be overwritten by the next call to any libexplain function which shares this buffer, including other threads. Note: This function is not thread safe, because it shares a return buffer across all threads, and many other functions in this library. Example: This function is intended to be used in a fashion similar to the following example: errno = EINVAL; int result = fprintf(fp, format, ...); if (result < 0) { fprintf(stderr, "%s ", explain_fprintf(fp, format, ...)); exit(EXIT_FAILURE); } The above code example is available pre-packaged as the explain_fprintf_or_die(3) function. explain_errno_fprintf const char *explain_errno_fprintf(int errnum, FILE *fp, const char *format, ...); The explain_errno_fprintf function is used to obtain an explanation of an error returned by the fprintf(3) system call. The least the mes- sage will contain is the value of strerror(errno), but usually it will do much better, and indicate the underlying cause in more detail. errnum The error value to be decoded, usually obtained from the errno global variable just before this function is called. This is neces- sary if you need to call any code between the system call to be explained and this function, because many libc functions will alter the value of errno. fp The original fp, exactly as passed to the fprintf(3) system call. format The original format, exactly as passed to the fprintf(3) system call. Returns: The message explaining the error. This message buffer is shared by all libexplain functions which do not supply a buffer in their argument list. This will be overwritten by the next call to any libexplain function which shares this buffer, including other threads. Note: This function is not thread safe, because it shares a return buffer across all threads, and many other functions in this library. Example: This function is intended to be used in a fashion similar to the following example: errno = EINVAL; int result = fprintf(fp, format, ...); if (result < 0) { int err = errno; fprintf(stderr, "%s ", explain_errno_fprintf(err, fp, format, ...)); exit(EXIT_FAILURE); } The above code example is available pre-packaged as the explain_fprintf_or_die(3) function. explain_message_fprintf void explain_message_fprintf(char *message, int message_size, FILE *fp, const char *format, ...); The explain_message_fprintf function is used to obtain an explanation of an error returned by the fprintf(3) system call. The least the message will contain is the value of strerror(errno), but usually it will do much better, and indicate the underlying cause in more detail. The errno global variable will be used to obtain the error value to be decoded. message The location in which to store the returned message. If a suitable message return buffer is supplied, this function is thread safe. message_size The size in bytes of the location in which to store the returned message. fp The original fp, exactly as passed to the fprintf(3) system call. format The original format, exactly as passed to the fprintf(3) system call. Example: This function is intended to be used in a fashion similar to the following example: errno = EINVAL; int result = fprintf(fp, format, ...); if (result < 0) { char message[3000]; explain_message_fprintf(message, sizeof(message), fp, format, ...); fprintf(stderr, "%s ", message); exit(EXIT_FAILURE); } The above code example is available pre-packaged as the explain_fprintf_or_die(3) function. explain_message_errno_fprintf void explain_message_errno_fprintf(char *message, int message_size, int errnum, FILE *fp, const char *format, ...); The explain_message_errno_fprintf function is used to obtain an explanation of an error returned by the fprintf(3) system call. The least the message will contain is the value of strerror(errno), but usually it will do much better, and indicate the underlying cause in more detail. message The location in which to store the returned message. If a suitable message return buffer is supplied, this function is thread safe. message_size The size in bytes of the location in which to store the returned message. errnum The error value to be decoded, usually obtained from the errno global variable just before this function is called. This is neces- sary if you need to call any code between the system call to be explained and this function, because many libc functions will alter the value of errno. fp The original fp, exactly as passed to the fprintf(3) system call. format The original format, exactly as passed to the fprintf(3) system call. Example: This function is intended to be used in a fashion similar to the following example: errno = EINVAL; int result = fprintf(fp, format, ...); if (result < 0) { int err = errno; char message[3000]; explain_message_errno_fprintf(message, sizeof(message), err, fp, format, ...); fprintf(stderr, "%s ", message); exit(EXIT_FAILURE); } The above code example is available pre-packaged as the explain_fprintf_or_die(3) function. SEE ALSO
fprintf(3) formatted output conversion explain_fprintf_or_die(3) formatted output conversion and report errors COPYRIGHT
libexplain version 0.52 Copyright (C) 2010 Peter Miller explain_fprintf(3)
All times are GMT -4. The time now is 03:31 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy