From: Jeremy Allison Date: Thu, 9 Jan 2020 22:21:46 +0000 (-0800) Subject: s3: smbd: msdfs: Change create_msdfs_link() to call SMB_VFS_CREATE_DFS_PATHAT(). X-Git-Tag: ldb-2.1.0~57 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=748379c66bc3d5131a9346c4c7a973d514b35563;p=thirdparty%2Fsamba.git s3: smbd: msdfs: Change create_msdfs_link() to call SMB_VFS_CREATE_DFS_PATHAT(). No change in the (rather strange) logic. First step in abstracting MSDFS storage from direct symlink calls. Signed-off-by: Jeremy Allison Reviewed-by: Volker Lendecke Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Fri Jan 10 21:05:25 UTC 2020 on sn-devel-184 --- diff --git a/source3/smbd/msdfs.c b/source3/smbd/msdfs.c index ab345fa2001..75ad2d9223b 100644 --- a/source3/smbd/msdfs.c +++ b/source3/smbd/msdfs.c @@ -1421,68 +1421,56 @@ bool create_msdfs_link(const struct junction_map *jucn, { TALLOC_CTX *frame = talloc_stackframe(); char *path = NULL; - char *msdfs_link = NULL; connection_struct *conn; - bool ret = False; struct smb_filename *smb_fname = NULL; bool ok; - int retval; + NTSTATUS status; + bool ret = false; ok = junction_to_local_path_tos(jucn, session_info, &path, &conn); if (!ok) { - TALLOC_FREE(frame); - return False; - } - - /* Form the msdfs_link contents */ - msdfs_link = msdfs_link_string(frame, - jucn->referral_list, - jucn->referral_count); - if (msdfs_link == NULL) { goto out; } - DEBUG(5,("create_msdfs_link: Creating new msdfs link: %s -> %s\n", - path, msdfs_link)); - smb_fname = synthetic_smb_fname(frame, path, NULL, NULL, 0); if (smb_fname == NULL) { - errno = ENOMEM; goto out; } - retval = SMB_VFS_SYMLINKAT(conn, - msdfs_link, - conn->cwd_fsp, - smb_fname); - if (retval < 0) { - if (errno == EEXIST) { - retval = SMB_VFS_UNLINKAT(conn, + status = SMB_VFS_CREATE_DFS_PATHAT(conn, + conn->cwd_fsp, + smb_fname, + jucn->referral_list, + jucn->referral_count); + if (!NT_STATUS_IS_OK(status)) { + if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) { + int retval = SMB_VFS_UNLINKAT(conn, conn->cwd_fsp, smb_fname, 0); if (retval != 0) { - TALLOC_FREE(smb_fname); goto out; } } - retval = SMB_VFS_SYMLINKAT(conn, - msdfs_link, + status = SMB_VFS_CREATE_DFS_PATHAT(conn, conn->cwd_fsp, - smb_fname); - if (retval < 0) { - DEBUG(1,("create_msdfs_link: symlinkat failed " - "%s -> %s\nError: %s\n", - path, msdfs_link, strerror(errno))); + smb_fname, + jucn->referral_list, + jucn->referral_count); + if (!NT_STATUS_IS_OK(status)) { + DBG_WARNING("SMB_VFS_CREATE_DFS_PATHAT failed " + "%s - Error: %s\n", + path, + nt_errstr(status)); goto out; } } - ret = True; + ret = true; out: TALLOC_FREE(frame);