[F23] cannot unlock a user with passwd - invalid shadow.lock

Rick Stevens ricks at alldigital.com
Fri Dec 4 17:30:45 UTC 2015


On 12/04/2015 05:29 AM, Frédéric Bron wrote:
> in fact, I just had to delete the .lock file. I do not understand why
> it was there.

Many commands create a lock file so that you can't run multiple copies
of the command simultaneously. If you had two users running that
command, both writing to the shadow file, you could easily corrupt it.

The downside to lockfiles is if you interrupt the command somehow
(CTRL-C, sigint, whatever), it may terminate without cleaning up its
lock file first (poor programming, but it often happens). Future runs
of the command are denied because the lock file is present and the
command assumes another copy of itself is already running.

Example in shell script:

     if [ -e /tmp/lockfile ]; then
	echo "Lockfile found, exiting"
	exit 1
     fi

     touch /tmp/lockfile
     (do stuff)
     rm -f /tmp/lockfile
     exit 0

To make sure the lockfile gets deleted, you must create a function
that deletes the lockfile, and specify that function in a trap call
to trap SIGINT, SIGTERM, etc. That way it cleans up after itself if
you abort it.

You get the idea.
----------------------------------------------------------------------
- Rick Stevens, Systems Engineer, AllDigital    ricks at alldigital.com -
- AIM/Skype: therps2        ICQ: 226437340           Yahoo: origrps2 -
-                                                                    -
-     Try to look unimportant.  The bad guys may be low on ammo.     -
----------------------------------------------------------------------


More information about the users mailing list