2

On a terminal in Ubuntu (14.04) when I hit Tab after cd /usr/bin it gives cd /usr/bin/X11.

If I keep hitting Tab, I get cd /usr/bin/X11/X11/X11/X11/X11/X11/X11 and so on. Should it be like this or am I looking at something funny?

2

Yes it looks somewhat funny but that's intended configuration we all have for the backward compatibility. On Debian/Ubuntu based systems x11-common package actually provides such a symlink:

$ ls -l /usr/bin/X11
lrwxrwxrwx 1 root root 1 Mar 17 02:52 /usr/bin/X11 -> ./
$ dpkg -S /usr/bin/X11
x11-common: /usr/bin/X11

man hier contains some historical description about /usr/bin/X11 and /usr/X11R6 dirs which are no longer used.

  • Can this feature of a ./ symlink be used as an exploit? If there were something like this in an executable it could consume all system resources with an infinite loop...? Thanks for man hier (it sounds like a verbal order in German lol), I had been using improgrammer.net/wp-content/uploads/2015/01/… formerly. – Yogesch Aug 13 '15 at 6:57
  • 1
    @Yogesch I don’t think so, there is a limit to which the kernel would chase symlinks (see man errno, ELOOP). If an application is manually processing symlinks it better had that limit by itself. – Jonas Schäfer Aug 13 '15 at 7:01
  • @JonasWielicki Yes, you're right. it stops after 40 times. So the max is /usr/bin/X11/X11..................40 times.../X11. And doing cd X11 after that (within the 40th dir) brings back nicely to /usr/bin. Any idea how that (bringing back to /usr/bin) could be implemented? – Yogesch Aug 13 '15 at 7:09
2

There is a link (at least in my Mint 17.2 install) in /usr/bin/X11 called X11 pointing to the directory:

$ ls -l /usr/bin/X11/X11
lrwxrwxrwx 1 root root 1 Jun  1  2014 /usr/bin/X11/X11 -> ./

so this is normal, but does require your tab expansion to be set to only expand subdirs (or that link is the only entry in /usr/bin/X11).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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