]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
Remove the "exists" parameter from create_msdfs_link
authorVolker Lendecke <vl@samba.org>
Sun, 22 Jun 2008 18:33:28 +0000 (20:33 +0200)
committerVolker Lendecke <vl@samba.org>
Sun, 22 Jun 2008 18:45:53 +0000 (20:45 +0200)
Jeremy, setting "exists" to True in _dfs_Add prevented the initial creation of
a new symlink for me, because the SMB_VFS_UNLINK failed. This also exists in
3.2. I only check it into 3.3 as I would like you to look at it first.

Thanks,

Volker

source/include/proto.h
source/rpc_server/srv_dfs_nt.c
source/smbd/msdfs.c

index 30642678eb55e76848c42d8d213d7a04a2ae879b..1d30a9a186dea00d2d47dd73e823c6f525d0416e 100644 (file)
@@ -9774,8 +9774,7 @@ int setup_dfs_referral(connection_struct *orig_conn,
 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,
index 974523dded8dae099492238185ef32d606e4b1fb..72b8236fb9e5ee0a246d4644f7a145fb3e98d1bd 100644 (file)
@@ -44,7 +44,6 @@ WERROR _dfs_Add(pipes_struct *p, struct dfs_Add *r)
        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();
@@ -76,7 +75,6 @@ WERROR _dfs_Add(pipes_struct *p, struct dfs_Add *r)
                return ntstatus_to_werror(status);
        }
 
-       exists = True;
        jn->referral_count += 1;
        old_referral_list = jn->referral_list;
 
@@ -101,7 +99,7 @@ WERROR _dfs_Add(pipes_struct *p, struct dfs_Add *r)
        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;
        }
@@ -184,7 +182,7 @@ WERROR _dfs_Remove(pipes_struct *p, struct dfs_Remove *r)
                                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;
                        }
index bc7cd81337ebb7880a5e2a6f65b062e78a539fb7..062ab804cc967f069f9cc35f8b738b342eb6ce2b 100644 (file)
@@ -1318,8 +1318,7 @@ static bool junction_to_local_path(const struct junction_map *jucn,
        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;
@@ -1369,19 +1368,20 @@ bool create_msdfs_link(const struct junction_map *jucn,
        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: