sâmbătă, 26 noiembrie 2011

Lesson for life ...


"Do not let your children in front of many people and their words, they are the train ..."
Goodbye Andrei, I hope to see you soon, with love - your father.

Protect your root account.

I will present a solution to protect the root account, quite funny but still elegant.
You can read about the command trap using : man trap.
What is this command?
when the specified event will occur will execute the command specified.
In this case, it will receive signal respectively will execute one command - exit
The the source code.

 protect()
 {
 echo "What is the secret ?"
 trap protect 2 20
 read -s resp
 if [ "$resp" != "asd" ]; then
 echo "Error!"
exit
fi
 }
 protect
The result will be leaving the root account if you do not answer the question correctly.
Now protect the file against unauthorized changes:
# chmod 700 /root/.bashrc
You can create using the example above, different ways to execute various commands.