[SCM] Samba Shared Repository - branch v3-3-test updated - release-3-2-0pre2-2942-gf58b098

Volker Lendecke vlendec at samba.org
Sun Jun 22 19:42:41 GMT 2008


The branch, v3-3-test has been updated
       via  f58b098a4172949018e84c4d0c722d6eb9bba514 (commit)
       via  948607f16112f6529f3a54cd6bbe978e8a600bc8 (commit)
       via  d031e6d8cabe2dd0b29e90d173d45843e145176a (commit)
      from  587bd636cb70d09600111ced040adaa55af35d0f (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-3-test


- Log -----------------------------------------------------------------
commit f58b098a4172949018e84c4d0c722d6eb9bba514
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Jun 22 20:33:28 2008 +0200

    Remove the "exists" parameter from create_msdfs_link
    
    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

commit 948607f16112f6529f3a54cd6bbe978e8a600bc8
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Jun 22 20:27:20 2008 +0200

    Check for sec_initial_uid() instead of uid==0 in dfs management

commit d031e6d8cabe2dd0b29e90d173d45843e145176a
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Jun 22 11:28:57 2008 +0200

    Reduce memory usage in form_junctions() a little bit

-----------------------------------------------------------------------

Summary of changes:
 source/include/proto.h         |    3 +--
 source/rpc_server/srv_dfs_nt.c |   10 ++++------
 source/smbd/msdfs.c            |   23 ++++++++++++-----------
 3 files changed, 17 insertions(+), 19 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/include/proto.h b/source/include/proto.h
index 3064267..1d30a9a 100644
--- a/source/include/proto.h
+++ b/source/include/proto.h
@@ -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,
diff --git a/source/rpc_server/srv_dfs_nt.c b/source/rpc_server/srv_dfs_nt.c
index 29538a3..72b8236 100644
--- a/source/rpc_server/srv_dfs_nt.c
+++ b/source/rpc_server/srv_dfs_nt.c
@@ -44,12 +44,11 @@ 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();
 
-	if (p->pipe_user.ut.uid != 0) {
+	if (p->pipe_user.ut.uid != sec_initial_uid()) {
 		DEBUG(10,("_dfs_add: uid != 0. Access denied.\n"));
 		return WERR_ACCESS_DENIED;
 	}
@@ -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;
 	}
@@ -119,7 +117,7 @@ WERROR _dfs_Remove(pipes_struct *p, struct dfs_Remove *r)
 	TALLOC_CTX *ctx = talloc_tos();
 	char *altpath = NULL;
 
-	if (p->pipe_user.ut.uid != 0) {
+	if (p->pipe_user.ut.uid != sec_initial_uid()) {
 		DEBUG(10,("_dfs_remove: uid != 0. Access denied.\n"));
 		return WERR_ACCESS_DENIED;
 	}
@@ -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;
 			}
diff --git a/source/smbd/msdfs.c b/source/smbd/msdfs.c
index df30257..062ab80 100644
--- a/source/smbd/msdfs.c
+++ b/source/smbd/msdfs.c
@@ -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:
@@ -1567,6 +1567,7 @@ static int form_junctions(TALLOC_CTX *ctx,
 				jucn[cnt].comment = "";
 				cnt++;
 			}
+			TALLOC_FREE(link_target);
 		}
 	}
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list