Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am trying to access the directory /usr/software/test/agnostic. There are several symlinks involved in this path. As you can see by the below transcript, I am unable to cd directly to the path, but I can check each step of the way and cd to the symlinked directories until I reach the destination. Why is this? (and how do I fix it?)

Ubuntu 12.10, bash

> ls /usr/software/test/agnostic
ls: cannot access /usr/software/test/agnostic: Permission denied

> cd /usr/software/test

> cd agnostic
bash: cd: agnostic: Permission denied

> pwd -P
/x/eng/localtest/arch/x86_64-redhat-rhel5

> ls -al | grep agnostic
lrwxrwxrwx  1 root  root    15 Oct 23  2007 agnostic -> noarch/agnostic

> ls -al | grep noarch
...
lrwxrwxrwx  1 root  root    23 Oct 23  2007 noarch -> /x/eng/localtest/noarch

> cd noarch

> cd agnostic
bash: cd: agnostic: Permission denied

> ls -al | grep agnostic
lrwxrwxrwx   1   5808 dip         4 Oct  5  2010 agnostic -> main

> cd main

> ls
(correct output of `ls`)

> pwd
/usr/software/test/noarch/main

> pwd -P
/x/eng/localtest/noarch/main
share|improve this question
    
Why don’t you just say ls –l agnostic? (Use ls –ld foo if “foo” might be a directory.) –  Scott Nov 27 '12 at 0:08

1 Answer 1

As documented here:

If you have a symlink in a world writeable directory that has the sticky bit set so that only the owner of a file can delete it (for example, /tmp), only the owner of a symlink can dereference it. Everyone else will get EACCES on any operation that attempts to do so, including things like attempting to stat() the symlink. If this is happening to you, your Ubuntu kernel will log messages like:

non-matching-uid symlink following attempted in sticky world-writable directory by cat (fsuid 915 != 2315)
yama_inode_follow_link: 16 callbacks suppressed

The fix is to turn kernel.yama.protected_sticky_symlinks to 0 (off).

To do this temporarily (to test if it fixes your problem):

sudo -i
echo 0 > /proc/sys/kernel/yama/protected_sticky_symlinks

To make the change permanent (as of next reboot), add a line to your sysctl.conf file:

echo "kernel.yama.protected_sticky_symlinks = 0" | sudo tee -a /etc/sysctl.conf
share|improve this answer
    
«Everyone else will get EACCES on any operation …, including things like attempting to stat() the symlink.» If that’s what’s happening, why were you able to get ls –l information at every point? –  Scott Nov 27 '12 at 0:09

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.