summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2005-08-02 23:55:38 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:00:23 -0500
commit78d6fa7277fadc77d80c400d3a38114a9e296d12 (patch)
tree7dfe41773d7c103c9d4ca81ff90f1b8262e16c09
parent08ebcb09418a359bbf1eaeb650364fe3ee50f491 (diff)
downloadsamba-78d6fa7277fadc77d80c400d3a38114a9e296d12.tar.gz
samba-78d6fa7277fadc77d80c400d3a38114a9e296d12.tar.bz2
samba-78d6fa7277fadc77d80c400d3a38114a9e296d12.zip
r8963: Clean up the horrid "fake conn struct" part of MSDFS.
Jeremy. (This used to be commit 14dd5ab632ff9abb9582e6484187c6ee1573cdd6)
-rw-r--r--source3/smbd/conn.c22
-rw-r--r--source3/smbd/msdfs.c30
2 files changed, 34 insertions, 18 deletions
diff --git a/source3/smbd/conn.c b/source3/smbd/conn.c
index 534a3367d4..b69868ecec 100644
--- a/source3/smbd/conn.c
+++ b/source3/smbd/conn.c
@@ -225,10 +225,10 @@ void conn_clear_vuid_cache(uint16 vuid)
}
/****************************************************************************
- Free a conn structure.
+ Free a conn structure - internal part.
****************************************************************************/
-void conn_free(connection_struct *conn)
+void conn_free_internal(connection_struct *conn)
{
vfs_handle_struct *handle = NULL, *thandle = NULL;
TALLOC_CTX *mem_ctx = NULL;
@@ -243,8 +243,6 @@ void conn_free(connection_struct *conn)
handle = thandle;
}
- DLIST_REMOVE(Connections, conn);
-
if (conn->ngroups && conn->groups) {
SAFE_FREE(conn->groups);
conn->ngroups = 0;
@@ -264,15 +262,25 @@ void conn_free(connection_struct *conn)
string_free(&conn->connectpath);
string_free(&conn->origpath);
- bitmap_clear(bmap, conn->cnum);
- num_open--;
-
mem_ctx = conn->mem_ctx;
ZERO_STRUCTP(conn);
talloc_destroy(mem_ctx);
}
+/****************************************************************************
+ Free a conn structure.
+****************************************************************************/
+
+void conn_free(connection_struct *conn)
+{
+ DLIST_REMOVE(Connections, conn);
+ bitmap_clear(bmap, conn->cnum);
+ num_open--;
+
+ conn_free_internal(conn);
+}
+
/****************************************************************************
receive a smbcontrol message to forcibly unmount a share
the message contains just a share name and all instances of that
diff --git a/source3/smbd/msdfs.c b/source3/smbd/msdfs.c
index ade167f3c5..2b13e2a4b5 100644
--- a/source3/smbd/msdfs.c
+++ b/source3/smbd/msdfs.c
@@ -133,12 +133,11 @@ static BOOL create_conn_struct(connection_struct *conn, int snum, char *path)
pstring connpath;
ZERO_STRUCTP(conn);
+
conn->service = snum;
pstrcpy(connpath, path);
pstring_sub(connpath , "%S", lp_servicename(snum));
- string_set(&conn->connectpath, connpath);
-
/* needed for smbd_vfs_init() */
if ( (conn->mem_ctx=talloc_init("connection_struct")) == NULL ) {
@@ -146,9 +145,11 @@ static BOOL create_conn_struct(connection_struct *conn, int snum, char *path)
return False;
}
+ string_set(&conn->connectpath, connpath);
+
if (!smbd_vfs_init(conn)) {
DEBUG(0,("create_conn_struct: smbd_vfs_init failed.\n"));
- talloc_destroy( conn->mem_ctx );
+ conn_free_internal(conn);
return False;
}
@@ -161,9 +162,10 @@ static BOOL create_conn_struct(connection_struct *conn, int snum, char *path)
if (vfs_ChDir(conn,conn->connectpath) != 0) {
DEBUG(3,("create_conn_struct: Can't ChDir to new conn path %s. Error was %s\n",
conn->connectpath, strerror(errno) ));
- talloc_destroy( conn->mem_ctx );
+ conn_free_internal(conn);
return False;
}
+
return True;
}
@@ -477,7 +479,7 @@ BOOL get_referred_path(TALLOC_CTX *ctx, char *pathname, struct junction_map *juc
struct dfs_path dp;
struct connection_struct conns;
- struct connection_struct* conn = &conns;
+ struct connection_struct *conn = &conns;
pstring conn_path;
int snum;
BOOL ret = False;
@@ -585,10 +587,7 @@ BOOL get_referred_path(TALLOC_CTX *ctx, char *pathname, struct junction_map *juc
out:
- if (conn->mem_ctx) {
- talloc_destroy( conn->mem_ctx );
- }
-
+ conn_free_internal(conn);
return ret;
}
@@ -937,6 +936,8 @@ BOOL create_msdfs_link(struct junction_map *jucn, BOOL exists)
BOOL insert_comma = False;
BOOL ret = False;
+ ZERO_STRUCT(conns);
+
if(!junction_to_local_path(jucn, path, sizeof(path), conn)) {
return False;
}
@@ -981,7 +982,8 @@ BOOL create_msdfs_link(struct junction_map *jucn, BOOL exists)
ret = True;
out:
- talloc_destroy( conn->mem_ctx );
+
+ conn_free_internal(conn);
return ret;
}
@@ -992,6 +994,8 @@ BOOL remove_msdfs_link(struct junction_map *jucn)
connection_struct *conn = &conns;
BOOL ret = False;
+ ZERO_STRUCT(conns);
+
if( junction_to_local_path(jucn, path, sizeof(path), conn) ) {
if( SMB_VFS_UNLINK(conn, path) == 0 ) {
ret = True;
@@ -999,6 +1003,7 @@ BOOL remove_msdfs_link(struct junction_map *jucn)
talloc_destroy( conn->mem_ctx );
}
+ conn_free_internal(conn);
return ret;
}
@@ -1012,6 +1017,8 @@ static int form_junctions(TALLOC_CTX *ctx, int snum, struct junction_map *jucn,
connection_struct conn;
struct referral *ref = NULL;
+ ZERO_STRUCT(conn);
+
if (jn_remain <= 0) {
return 0;
}
@@ -1078,7 +1085,8 @@ static int form_junctions(TALLOC_CTX *ctx, int snum, struct junction_map *jucn,
SMB_VFS_CLOSEDIR(&conn,dirp);
out:
- conn_free(&conn);
+
+ conn_free_internal(&conn);
return cnt;
}