Re: Forcing password change for a user
On 29 Apr 1999, Arcady Genkin wrote:
> Thanks for your reply.
> A little terminology query: by "touch" did you mean "create"? :)
Yes, you "create" it with the touch command.
>
> I created .newuser file in a testdummy user's home directory. Then I
> have added the following to ~/.bash_profile:
>
> if test -e ~/.newuser; then
> echo "Change of password forced"
> /usr/bin/passwd
> rm ~/.newuser
> fi
>
> (please bear with me, this is the first shell script I have ever
> written :-/). This seems to do what I wanted, but I see a
> complication - a user can abort changing password by
> pressing CNTRL-C (just tried it). How can I make *absolutely* sure
> that the password gets changed the first time a user logs on?
>
> I think I could make a loop in the script, exit condition of which
> would be successful termination of passwd, right? But then, does
> CNTRL-C terminate execution of the script or only of the current
> command in the script?
>
> Thanks for any input!
Test the exit condition of the passwd command. If it exits normally, the
password was changed. If it exits abnormally, something happened.
Reply to: