I was making a Bash script with the setuid permission on, but it didn't work. So I found my solution here:
Now my script works fine and all (I rewrote it in cpp).
To satisfy my curiosity as to why pure Bash shell didn't work, I read this link: http://www.faqs.org/faqs/unix-faq/faq/part4/section-7.html (referenced by this answer: https://unix.stackexchange.com/a/2910). At that site, I came across the following:
$ echo \#\!\/bin\/sh > /etc/setuid_script
$ chmod 4755 /etc/setuid_script
$ cd /tmp
$ ln /etc/setuid_script -i
$ PATH=.
$ -i
I don't understand the fourth line, which reads ln /etc/setuid_script -i.
What does that command do?
I've read in the ln manual that -i is just the "interactive" flag (asking whether you want to overwrite an existing file or not). So why does ln /etc/setuid_script -i followed by PATH=. and -i make my shell execute /bin/sh -i?