Hi Mike:
I am wrong, (some mistakes were to copy and paste), you are right. This was the 
correct code that I wanted to write. 
It is not necessary to generate random numbers

if [ ! -e ~/flag* ]; then
        touch ~/flag
fi

#Trying to release the lock
sleep 1
mv ~/flag  ~/flag.lock  2> /dev/null
while (( $? > 0));  do
  mv ~/flag  ~/flag.lock  2> /dev/null
done 

# do locked stuff here

#Release the lock
mv ~/flag.lock ~/flag 2> /dev/null


mkdir / ln method also fails if malicious person erase with rmdir or rm
--
This message posted from opensolaris.org

Reply via email to