[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Forcing password change for a user



George Bonser <grep@shorelink.com> writes:

> When you create a user, touch a file in their directory called .newuser
> In the .bash_profile or .profile or .cshrc or whatever have the script
> check for the existance of this file. If found, it execs the passwd
> command and then delete the .newuser file.
> This has the advantage of allowing you to touch .newuser (and change the
> ownership so the user can delete it without complaint) at any time to
> force a password change ... or at least STRONGLY suggest a password
> change.

Thanks for your reply.
A little terminology query: by "touch" did you mean "create"? :)

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!
-- 
Arcady Genkin
"I opened up my wallet, and it's full of blood..." - GsYDE


Reply to: