I’ve created a new whoami command which requires a fake username and have put it in the PATH by adding it to ~/.profile . It is created in a way that whoami is called before actual the actual whoami from Linux.
The main reason to do this is because I am remote accessing a Hadoop cluster and want the copied files to be under the fake username.
This works fine when I call whoami in the shell and even calling $PATH shows the path to my created whoami before everything else. But for some reason, when Hadoop is called, it doesn’t pick the created `whoami’.
Can someone help me with how to fix this?
thanks
Most applications do not use
whoamito determine a user’s username or group. For instance, in bash you can use the commandidto find more detailed information about yourself orid [username](such asid root) to find out more detailed information about other users. Groups can be found withgroupsas well. Also, different programming languages, such as C, have their own methods of determining user identities such as thegetuid()command.If you really “need” to go as far as faking your user account, you’ll need to go down to OS level and create hooks into the kernel/API that handles those methods.
Is it possible that you simply
chownthe files after they are copied instead?UPDATE:
It appears that some releases of Hadoop do actually use
whoami(my own implementation w/ clustering does not).In this event, the best (a term loosely used) suggestion would be to move the legitimate
whoamiexecutable and create awhoamishell script that goes in it’s place. The custom script should validate the current user and if it’s “hadoop”, return whatever faked username you want – otherwise return valid output. Igor’s answer would work in this case.