So I've been getting more and more into my UNIX system, a mac, and I wanted to know where it goes to execute a log-in. I know where it keeps the passwords and such, but I would like to see the script it runs at log-in. I did find /usr/bin/login
but neither vim nor nano will show anything that looks like code(eg. it's 90% @ symbols). So if that is the file how can I read it?
2 Answers
It depends... if you start a console login, a program usually called getty
(in Fedora Linux, agetty(8)
) shows the login:
prompt, asks for the username and passes that to login(1)
, which gets the user's information, asks for the password and (if successful) sets up the environment and starts a shell for the user. The login program is quite standard, the Linux one is part of the util-linux
package. The FreeBSD version is here (that is probably nearer the MacOS one than the Linux version).
For a graphical login, there is a greeter program like xdm(1)
or something more elaborate like gdm
, which does most of the above, but starts an X session with predefined programs running.
As you are running Mac OSX, you can use dtrace execsnoop in a terminal to see all commands executed:
nohup sudo execsnoop -v > /var/tmp/execsnoop.log &
Then logout and login and you'll see what your OS is running.
You might modify this dtrace script for it to use anonymous tracing and then see all programs executed while your OS is booting.
/usr/bin/login
is actually a binary file. You should try looking for its source code in your repos.