s3: VFS: Change SMB_VFS_SYMLINK to use const struct smb_filename * instead of const...
[kamenim/samba-autobuild/.git] / source3 / modules / vfs_cap.c
index 2c21ab18c48bc0d1a9d126e040f02ded53c9e33f..c07a05954c0f233ea0ae519c4863b6a6314296f4 100644 (file)
@@ -479,17 +479,44 @@ static int cap_ntimes(vfs_handle_struct *handle,
 }
 
 
-static int cap_symlink(vfs_handle_struct *handle, const char *oldpath,
-                      const char *newpath)
+static int cap_symlink(vfs_handle_struct *handle,
+                       const char *link_contents,
+                       const struct smb_filename *new_smb_fname)
 {
-       char *capold = capencode(talloc_tos(), oldpath);
-       char *capnew = capencode(talloc_tos(), newpath);
+       char *capold = capencode(talloc_tos(), link_contents);
+       char *capnew = capencode(talloc_tos(), new_smb_fname->base_name);
+       struct smb_filename *new_cap_smb_fname = NULL;
+       int saved_errno = 0;
+       int ret;
 
        if (!capold || !capnew) {
                errno = ENOMEM;
                return -1;
        }
-       return SMB_VFS_NEXT_SYMLINK(handle, capold, capnew);
+       new_cap_smb_fname = synthetic_smb_fname(talloc_tos(),
+                                       capnew,
+                                       NULL,
+                                       NULL,
+                                       new_smb_fname->flags);
+       if (new_cap_smb_fname == NULL) {
+               TALLOC_FREE(capold);
+               TALLOC_FREE(capnew);
+               errno = ENOMEM;
+               return -1;
+       }
+       ret = SMB_VFS_NEXT_SYMLINK(handle,
+                       capold,
+                       new_cap_smb_fname);
+       if (ret == -1) {
+               saved_errno = errno;
+       }
+       TALLOC_FREE(capold);
+       TALLOC_FREE(capnew);
+       TALLOC_FREE(new_cap_smb_fname);
+       if (saved_errno != 0) {
+               errno = saved_errno;
+       }
+       return ret;
 }
 
 static int cap_readlink(vfs_handle_struct *handle,