3

Say I have an /etc/profile

# good stuff here
# ...

/usr/local/bin/obnoxious_ascii_art

Is there anything I can do to prevent the execution of the last line when I log in? Assume I don't necessarily have root access.

cpugeniusmv
  • 2,657
  • Is this a machine you're accessing via SSH? If so there might be some dirty stuff you can do with an authorized_keys command. But otherwise, I don't think so. /etc/profile is executed before any of your personal files, thus you don't get a chance to do anything about it. – phemmer May 28 '14 at 19:10
  • 2
    No! ~\O?\O/O/~ ...[]:} – goldilocks May 28 '14 at 19:11
  • @Patrick Yes, via SSH. Interesting thought about the authorized_keys command. – cpugeniusmv May 28 '14 at 19:16
  • 1
    If all else fails, you could change your shell to csh and then exec your regular shell in your ~/.login – Mark Plotnick May 28 '14 at 21:46
  • 1
    Sacrilege ;) But one day you might return the favor! –  May 28 '14 at 22:38
  • Well, I will be honest. I have some 80+ servers where I login as a normal (non-root) user and all of them have a readonly TMOUT set to 900. I would like to know of a way to bypass /etc/profile which calls /etc/profile.d/tmout.sh Not trying to break any security here, just trying to be productive. Have tried talking to the security department to atleast increasing the value to 1 hour, but instead I heard that they are thinking of reducing it down to 10 minutes! exec env TMOUT= /bin/ksh does not work, it says TMOUT readonly and does not change its value. Thanks! –  Sep 08 '14 at 00:24

3 Answers3

2

If I can't prevent it, I can at least hide the output after the fact with this in my .bash_profile:

clear

Or, if I know how many lines it is:

for l in {1..26}; do
  tput cuu1 # move up a line
done
tput ed # clear to end of screen
cpugeniusmv
  • 2,657
  • 1
    Even if you don't know how many lines it is, or if it can change, you can run it again manually and pipe it into wc -l – phemmer May 28 '14 at 19:35
2

You can copy profile to your home, edit it as needed
after that, this should work

ssh -t user@host '. ~/profile ; bash'

-t Force pseudo-tty allocation

MolbOrg
  • 710
  • 7
  • 11
1

It depends on what do you mean by "obnoxious_ascii_art".

If it's admin's practical joke, you should simply talk to the guy with root access about it. In this case it's a social problem and you should solve it by social means, not with technology.

If it's something that actually does something, but you don't like it, try to ask yourself why it's there in the first place. Maybe it's security related? In such case - I'm sorry to say that, but just let it run - when the machine goes belly up, nobody will blame you.

If it's something broken (but the admin refuses to fix it, for any reason), or you're just curious, then Mark Plotnick's comment is the best solution I can think of.

I know it's not the kind of answer you expected, but technical brute forcing through the problem is not always the best way.

  • In this case it's exactly what it sounds like :) I probably need to encourage him to add a [ -e ~/.ascii_art_is_stupid ] check to his script. I was merely curious (from a purely technical standpoint) to see if there were some obscure or interesting workarounds. – cpugeniusmv May 28 '14 at 22:10
  • Or to check UID. But your idea is better, because any user may configure it. Hell, he can even make a feature, so that any user may configure which ascii art he gets (in your case - empty file). That may convince him, because probably he will snatch the credit and bragging rights for new feature. – Darth Hunterix May 28 '14 at 22:17