User id creation/deletion - notification

Can someone help me with a shell script that will send an email to a set of email ids when a user id is created or deleted on AIX system.
Also, if the script can let the admin know when a particular user id's password will expire.

Are you thinking of a (daily?) cron job? Did you check/search these forums on this exact topic?

Dear ggayathri,

I have a few to questions pose in response first:-

  • What have you tried so far?
  • What output/errors do you get?
  • What AIX version are you using?
  • What files are you exploring to get this information?
  • What are your preferred tools? (C, shell, perl, awk, etc.)
  • What logical process have you considered? (to help steer us to follow what you are trying to achieve)

Most importantly, What have you tried so far?

There are probably many ways to achieve most tasks, so giving us an idea of your style and thoughts will help us guide you to an answer most suitable to you so you can adjust it to suit your needs in future.

We're all here to learn and getting the relevant information will help us all.

Robin

Hi Robin,

This is to be executed as a cron job on a daily basis. Can consider shell/awk/perl scripts as well. My thoughts have been to find the difference between the /etc/passwd file and come up with the additions/deletions. I have not tried any scripting in this regard.

Your suggestions could be set out as:-

  • Compare today's /etc/passwd to yesterday (sort first for ease)
  • Save current /etc/passwd to use tomorrow

You can then look for password expiry based on the content of /etc/security/password It's a little awkward because:-

  • The Last password change time is stored in seconds from 1/1/1970
  • The expiry will be in weeks, either per user or in the default stanza

Using /etc/passwd as a driver, you can read one stanza from /etc/security/passwd with grep -Ep "^$userid:" /etc/security/passwd although you then have to consider the points above to decide if the password is about to expire, depending also how you define 'about to expire'

Does this give you something to work with?

Robin