summaryrefslogtreecommitdiff
path: root/source3/smbd/msdfs.c
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2012-10-10 13:47:49 +1100
committerJeremy Allison <jra@samba.org>2013-01-07 16:09:39 -0800
commit6c80cf747d75e648a1d88d477bcf476e6874c4b3 (patch)
treece9aef0f15d9c9588eb0cd4b0a12c347591a8e86 /source3/smbd/msdfs.c
parent6a5afa244203c42265207c56e95783ec740ee89e (diff)
downloadsamba-6c80cf747d75e648a1d88d477bcf476e6874c4b3.tar.gz
samba-6c80cf747d75e648a1d88d477bcf476e6874c4b3.tar.bz2
samba-6c80cf747d75e648a1d88d477bcf476e6874c4b3.zip
smbd: Split create_conn_struct into a fn that does not change the working dir
The python bindings do not want the current working directory changed during operations, so we provide two functions, one providing the original behaviour, and other providing the python bindings with just the memory allocation and initilisation stuff. Andrew Bartlett Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/smbd/msdfs.c')
-rw-r--r--source3/smbd/msdfs.c58
1 files changed, 44 insertions, 14 deletions
diff --git a/source3/smbd/msdfs.c b/source3/smbd/msdfs.c
index b6ebaca1a1..83f140c25b 100644
--- a/source3/smbd/msdfs.c
+++ b/source3/smbd/msdfs.c
@@ -218,8 +218,9 @@ static NTSTATUS parse_dfs_path(connection_struct *conn,
}
/********************************************************
- Fake up a connection struct for the VFS layer.
- Note: this performs a vfs connect and CHANGES CWD !!!! JRA.
+ Fake up a connection struct for the VFS layer, for use in
+ applications (such as the python bindings), that do not want the
+ global working directory changed under them.
*********************************************************/
NTSTATUS create_conn_struct(TALLOC_CTX *ctx,
@@ -228,12 +229,10 @@ NTSTATUS create_conn_struct(TALLOC_CTX *ctx,
connection_struct **pconn,
int snum,
const char *path,
- const struct auth_session_info *session_info,
- char **poldcwd)
+ const struct auth_session_info *session_info)
{
connection_struct *conn;
char *connpath;
- char *oldcwd;
const char *vfs_user;
conn = talloc_zero(ctx, connection_struct);
@@ -247,9 +246,9 @@ NTSTATUS create_conn_struct(TALLOC_CTX *ctx,
return NT_STATUS_NO_MEMORY;
}
connpath = talloc_string_sub(conn,
- connpath,
- "%S",
- lp_servicename(talloc_tos(), snum));
+ connpath,
+ "%S",
+ lp_servicename(talloc_tos(), snum));
if (!connpath) {
TALLOC_FREE(conn);
return NT_STATUS_NO_MEMORY;
@@ -341,6 +340,37 @@ NTSTATUS create_conn_struct(TALLOC_CTX *ctx,
}
conn->fs_capabilities = SMB_VFS_FS_CAPABILITIES(conn, &conn->ts_res);
+ *pconn = conn;
+
+ return NT_STATUS_OK;
+}
+
+/********************************************************
+ Fake up a connection struct for the VFS layer.
+ Note: this performs a vfs connect and CHANGES CWD !!!! JRA.
+
+ The old working directory is returned on *poldcwd, allocated on ctx.
+*********************************************************/
+
+NTSTATUS create_conn_struct_cwd(TALLOC_CTX *ctx,
+ struct tevent_context *ev,
+ struct messaging_context *msg,
+ connection_struct **pconn,
+ int snum,
+ const char *path,
+ const struct auth_session_info *session_info,
+ char **poldcwd)
+{
+ connection_struct *conn;
+ char *oldcwd;
+
+ NTSTATUS status = create_conn_struct(ctx, ev,
+ msg, &conn,
+ snum, path,
+ session_info);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
/*
* Windows seems to insist on doing trans2getdfsreferral() calls on
@@ -350,14 +380,14 @@ NTSTATUS create_conn_struct(TALLOC_CTX *ctx,
oldcwd = vfs_GetWd(ctx, conn);
if (oldcwd == NULL) {
- NTSTATUS status = map_nt_error_from_unix(errno);
+ status = map_nt_error_from_unix(errno);
DEBUG(3, ("vfs_GetWd failed: %s\n", strerror(errno)));
conn_free(conn);
return status;
}
if (vfs_ChDir(conn,conn->connectpath) != 0) {
- NTSTATUS status = map_nt_error_from_unix(errno);
+ status = map_nt_error_from_unix(errno);
DEBUG(3,("create_conn_struct: Can't ChDir to new conn path %s. "
"Error was %s\n",
conn->connectpath, strerror(errno) ));
@@ -981,7 +1011,7 @@ NTSTATUS get_referred_path(TALLOC_CTX *ctx,
return NT_STATUS_OK;
}
- status = create_conn_struct(ctx,
+ status = create_conn_struct_cwd(ctx,
server_event_context(),
server_messaging_context(),
&conn, snum,
@@ -1160,7 +1190,7 @@ static bool junction_to_local_path(const struct junction_map *jucn,
if(snum < 0) {
return False;
}
- status = create_conn_struct(talloc_tos(),
+ status = create_conn_struct_cwd(talloc_tos(),
server_event_context(),
server_messaging_context(),
conn_out,
@@ -1325,7 +1355,7 @@ static int count_dfs_links(TALLOC_CTX *ctx, int snum)
* Fake up a connection struct for the VFS layer.
*/
- status = create_conn_struct(talloc_tos(),
+ status = create_conn_struct_cwd(talloc_tos(),
server_event_context(),
server_messaging_context(),
&conn,
@@ -1401,7 +1431,7 @@ static int form_junctions(TALLOC_CTX *ctx,
* Fake up a connection struct for the VFS layer.
*/
- status = create_conn_struct(ctx,
+ status = create_conn_struct_cwd(ctx,
server_event_context(),
server_messaging_context(),
&conn, snum, connect_path, NULL,