I think that pwd -P
and readlink
are going to be your friends for this task.
"How can I get the behavior of GNU's readlink -f on a Mac?" is a handy resource.
pwd -P
only works if you're inside the symlink directory:
14:07:13 jason@mac ~ $ cd bin
14:08:08 jason@mac bin $ pwd -P
/Users/jason/Applications
readlink
works by specifying the target (thus it can be used against files):
14:09:03 jason@mac ~ $ readlink bin
Applications
14:09:34 jason@mac ~ $ readlink /var
private/var
The output of readlink
appears to be relative to the parent of the specified target.
Ex: The parent of /var
is /
, so private/var
is correct, relative to /
. Per my above example of bin -> Applications
, both are in my Home Directory, no matter where I run it, the output is the same.
In your configuration, you have unix extensions = no
which is fine, but that is why symbolic links on the server are showing up as folders and not aliases. In this mode the server resolves the symbolic links and the client never sees them. If the client tries to create a symbolic link, the server actually generates an alias file, not a host-OS symbolic link. Reasons for this include security (preventing someone from getting access to /etc/passwd
on the server by creating a symbolic link to it) and client compatibility, as OS X and Windows and Unix have slightly different ideas about what constitutes a symbolic link but they pretty much agree on what is a directory or a file.
Permissions issues with SAMBA are complex, so it's not clear that you do not have a permissions issue. Likewise symbolic like resolving is complex, so it is not clear that what you are doing should, in theory work, and there's always the possibility of a bug (most likely in the SAMBA server).
When accessing a SAMBA server from a Mac, these identities and permissions are involved:
- The Mac User you are logged into the Mac as
- The SAMBA user you are logged into the SAMBA server as
- The SMABA server host OS user you get converted to
- Unix-style file permissions
- For NTFS and HFS+, associated file-system ACLs
So even though you have provided a lot of information, it's still not clear that you are not having permissions problems. The fact that you can mv
and cp
on the server (using what account?) does not mean you do not have a permissions problem preventing you from doing it on the client (using what accounts and with what effective account on the server?).
If the server is supporting ACLs and since you have options like inherit permissions = yes
and inherit acls = yes
set there could be some kind of ACL problem that is only allowing read access to directories accessed via symbolic links. There are several other avenues of investigation based on the server configuration.
I would really expect you should be able to find more information in the SAMBA server logs than you have communicated. They should give you a much better sense of exactly what is being denied.
For what it is worth, I tried to duplicate your setup using an Ubuntu 12.04 host as the SAMBA server and could not reproduce your problem. Symbolic links worked for me as expected.
Best Answer
Unfortunately, this is not how symbolic links work.
From the man page (
man ln
)Emphasis mine
So, how do you get around this? Use an environment variable. For example:
Note, you should use absolute paths when doing this; using relative paths can and will have unintended consequences.