Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I need to run custom binary when user logged in to system ,so that I have changed user's shell to /bin/binary to /etc/passwd but I have observed that /etc/profile file was not read when I logged in with changed user's shell

So /etc/profile will be only read if user's shell is /bin/sh in /etc/passwd??

share|improve this question
add comment

1 Answer 1

up vote 6 down vote accepted

Not quite. /etc/profile will be read if the user's shell according to /etc/passwd (or LDAP, or other tool) knows how to read it and does it.

If you replace /bin/sh with a binary that doesn't know how to read /etc/profile, then it won't be read.

One way to fix it is obviously to fix the binary so that it knows how to handle /etc/profile.

Another is to keep the user's shell set to /bin/sh, and to edit the user's $HOME/.profile to start the binary after everything else has been set up.

A third way is to make the user log in using an SSH key, and edit the key so that it will start /bin/binary and disregard any other commands. You do this by editing the user's $HOME/.ssh/authorized_keys to read e.g.

 command="/bin/binary"  ssh-dss AA.....restofkeyhere....
share|improve this answer
    
Thanks @HenningMakholm for the edit! –  Jenny D Mar 31 at 13:46
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.