Discussion:
bug#29475: filesystem does not allow ln to create bad symbolic link
(too old to reply)
Paul Eggert
2017-11-27 22:37:25 UTC
Permalink
$ ln -s not-there badlink
ln: failed to create symbolic link ‘badlink’: No such file or directory
What happens if you do the following shell command instead?

strace ln -s not-there badlink

On my platform (Fedora 27) the strace output ends this way:

stat("badlink", 0x7ffebc9ddbe0)         = -1 ENOENT (No such file or
directory)
symlinkat("not-there", AT_FDCWD, "badlink") = 0
lseek(0, 0, SEEK_CUR)                   = -1 ESPIPE (Illegal seek)
close(0)                                = 0
close(1)                                = 0
close(2)                                = 0
exit_group(0)                           = ?

which is expected. What happens on your platform?
Paul Eggert
2017-11-28 02:41:12 UTC
Permalink
stat("badlink", 0x7ffc0eb805a0) = -1 ENOENT (No such file or directory)
symlink("not-there", "badlink") = -1 ENOENT (No such file or directory)
My guess is that you've removed the working directory somehow, or are on a buggy
filesystem that thinks the working directory has been removed. I can reproduce
the situation as follows on Ubuntu 16.04.3:

$ cd /tmp
$ mkdir d
$ cd d
$ rmdir /tmp/d
$ LC_ALL=C strace ln -s a b
...
stat("b", 0x7fffe6df6140) = -1 ENOENT (No such file or directory)
symlink("a", "b") = -1 ENOENT (No such file or directory)
...

The only suggestion I have is "don't do that". If memory serves, POSIX doesn't
specify the behavior in this case.
Paul Eggert
2017-12-01 01:07:17 UTC
Permalink
From my trial and error, this file system does not let you create bad sym links.
Hmm, yes, apparently that filesystem can be configured to disallow
creation of dangling symlinks or links to files they don't own. See:

https://www.cloudlinux.com/getting-started-with-cloudlinux-os/41-security-features/933-activating-securelink

Using this feature will break a lot of programs (not just ln), but
evidently they're not concerned about that.
Assaf Gordon
2018-10-30 02:13:32 UTC
Permalink
tags 29475 notabug
close 29475
stop

(triaging old bugs)
Post by Paul Eggert
 From my trial and error, this file system does not let you create bad
sym links.
Hmm, yes, apparently that filesystem can be configured to disallow
https://www.cloudlinux.com/getting-started-with-cloudlinux-os/41-security-features/933-activating-securelink
Using this feature will break a lot of programs (not just ln), but
evidently they're not concerned about that.
Given the above, I'm closing this bug.
Discussion can continue by replying to this thread.

-assaf

Continue reading on narkive:
Loading...