bool create_junction(TALLOC_CTX *ctx,
const char *dfs_path,
struct junction_map *jucn);
-bool create_msdfs_link(const struct junction_map *jucn,
- bool exists);
+bool create_msdfs_link(const struct junction_map *jucn);
bool remove_msdfs_link(const struct junction_map *jucn);
struct junction_map *enum_msdfs_links(TALLOC_CTX *ctx, size_t *p_num_jn);
NTSTATUS resolve_dfspath(TALLOC_CTX *ctx,
struct referral *old_referral_list = NULL;
bool self_ref = False;
int consumedcnt = 0;
- bool exists = False;
char *altpath = NULL;
NTSTATUS status;
TALLOC_CTX *ctx = talloc_tos();
return ntstatus_to_werror(status);
}
- exists = True;
jn->referral_count += 1;
old_referral_list = jn->referral_list;
jn->referral_list[jn->referral_count-1].ttl = REFERRAL_TTL;
jn->referral_list[jn->referral_count-1].alternate_path = altpath;
- if(!create_msdfs_link(jn, exists)) {
+ if(!create_msdfs_link(jn)) {
vfs_ChDir(p->conn,p->conn->connectpath);
return WERR_DFS_CANT_CREATE_JUNCT;
}
return WERR_DFS_NO_SUCH_VOL;
}
} else {
- if(!create_msdfs_link(jn, True)) {
+ if(!create_msdfs_link(jn)) {
vfs_ChDir(p->conn,p->conn->connectpath);
return WERR_DFS_CANT_CREATE_JUNCT;
}
return True;
}
-bool create_msdfs_link(const struct junction_map *jucn,
- bool exists)
+bool create_msdfs_link(const struct junction_map *jucn)
{
char *path = NULL;
char *msdfs_link = NULL;
DEBUG(5,("create_msdfs_link: Creating new msdfs link: %s -> %s\n",
path, msdfs_link));
- if(exists) {
- if(SMB_VFS_UNLINK(conn,path)!=0) {
+ if(SMB_VFS_SYMLINK(conn, msdfs_link, path) < 0) {
+ if (errno == EEXIST) {
+ if(SMB_VFS_UNLINK(conn,path)!=0) {
+ goto out;
+ }
+ }
+ if (SMB_VFS_SYMLINK(conn, msdfs_link, path) < 0) {
+ DEBUG(1,("create_msdfs_link: symlink failed "
+ "%s -> %s\nError: %s\n",
+ path, msdfs_link, strerror(errno)));
goto out;
}
}
- if(SMB_VFS_SYMLINK(conn, msdfs_link, path) < 0) {
- DEBUG(1,("create_msdfs_link: symlink failed "
- "%s -> %s\nError: %s\n",
- path, msdfs_link, strerror(errno)));
- goto out;
- }
-
ret = True;
out: