2

I already know that I can read the password structure (getpwnam etc.) but how can I alter the specific password. Do I have to lock the master.passwd and modify it directly or better make a copy from master.passwd modify this and make a file move after correct modifications?

At last, I don't want to make a system(usermod ...) because that invokes the shell and should be the last solution!

Thanks in advance

1
  • Thanks for the hints! My solution is now very close to the solution in OpenBSD's local_passwd.c Which uses the functions pw_lock(), pw_init() and pw_mkdb(). These functions let you also do some modifications if you're using the old passwd or the spwd.db. Commented Feb 8, 2012 at 12:47

1 Answer 1

2

In C for Unix like Solaris or AIX , you can either :

You'll see here a complete sample program to change a pasword for unix in C using putpwent & getpwent. AIX documentation seems to confirm it should also works on their OS.

Sign up to request clarification or add additional context in comments.

1 Comment

If the passwords are stored in the passwd file and not shadow or equivalent, why even bother setting a password? All it does is make it so it takes 3 hours longer to login as whoever you want... ;-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.