Hi all,
I tried the following experiment. /tmp/file1 (marked executable) has the following content: #!/bin/date echo "$@" /tmp/file2 has the following content: #!/tmp/file1 echo "File2" when I run file2, I expect it to print out the current date. Instead, it prints out "File2". In other words, it goes to /bin/sh to execute. I tried going over the kernel code that handles this, but I must be looking at the wrong place. I got as far as the function "load_script" (fs/binfmt_script.c line 18 in the 2.6.23 kernel code), which seems to go over the file, extract the interpreter, and restart the entire process. Of course, once the process has restarted, bprm->sh_bang is not zero (line 25 of the file), and the function returns ENOEXEC. This explains why a shell script cannot be the interpreter for a shell script. What is not explained, however, is what does happen. I have not been able to locate what happens when the kernel runs out of functions that may make sense of the file we try to execute (aside from returning ENOEXEC, which does not seem to be what is actually happening). I have also been unable to locate where in the source there is any special casing of /bin/sh (aside from when the kernel cannot find /sbin/init, /etc/init and /bin/init during boot). What's going on here? Shachar ================================================================= To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
