Reporting broken symlinks to clients
Jeremy Allison
jra at samba.org
Fri Jun 14 13:37:24 MDT 2013
On Thu, Jun 13, 2013 at 04:22:38PM -0700, Christof Schmitt wrote:
> I got asked if it would make sense to report broken symlinks to
> Windows clients. With the current code, the stat() call in
> smbd_dirptr_lanman2_mode_fn fails on the broken symlink and it is not
> reported in the directory listing to the client. This could be changed
> without too much effort, like this hack:
>
> --- a/source3/smbd/trans2.c
> +++ b/source3/smbd/trans2.c
> @@ -1553,11 +1553,22 @@ static bool
> smbd_dirptr_lanman2_mode_fn(TALLOC_CTX *ctx,
> SMB_VFS_STAT(state->conn, smb_fname) != 0) {
> /* Needed to show the msdfs symlinks as
> * directories */
> + int stat_errno = errno;
>
> ms_dfs_link = check_msdfs_link(state->conn,
> smb_fname->base_name,
> &smb_fname->st);
> - if (!ms_dfs_link) {
> + if (!ms_dfs_link && stat_errno == ENOENT) {
> + /* Invalid link target, try to get lstat() data to show
> + * a dummy file */
> + if (SMB_VFS_LSTAT(state->conn, smb_fname) != 0) {
> + DEBUG(5,("smbd_dirptr_lanman2_mode_fn: "
> + "Couldn't stat and lstat [%s] (%s)\n",
> + smb_fname_str_dbg(smb_fname),
> + strerror(errno)));
> + return false;
> + }
> + } else if (!ms_dfs_link) {
> DEBUG(5,("smbd_dirptr_lanman2_mode_fn: "
> "Couldn't stat [%s] (%s)\n",
> smb_fname_str_dbg(smb_fname),
>
> This could be useful in environments where the same directory is
> accessible to Windows clients and to Linux/Unix systems. When a
> broken symlink is created, the Windows clients would at least be able
> to see that there is a file.
>
> Comments?
What is the goal of presenting the broken links to the Windows clients ?
I'm trying to understand the use case here.
Thanks,
Jeremy.
More information about the samba-technical
mailing list