From bb54f72b94dca9206bf377b0d6a4b669e389e339 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 20 Jan 2011 16:27:56 -0800 Subject: Make processing of incoming stream rename paths common between reply_mv and ntrename. Ensure we don't depend on "./" in the streams module. --- source3/smbd/nttrans.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'source3/smbd/nttrans.c') diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c index da1231c83b..9d6a892ad6 100644 --- a/source3/smbd/nttrans.c +++ b/source3/smbd/nttrans.c @@ -1495,6 +1495,7 @@ void reply_ntrename(struct smb_request *req) uint32_t ucf_flags_dst = 0; uint16 rename_type; TALLOC_CTX *ctx = talloc_tos(); + bool stream_rename = false; START_PROFILE(SMBntrename); @@ -1527,10 +1528,16 @@ void reply_ntrename(struct smb_request *req) goto out; } - /* The newname must begin with a ':' if the oldname contains a ':'. */ - if (strchr_m(oldname, ':') && (newname[0] != ':')) { - reply_nterror(req, NT_STATUS_INVALID_PARAMETER); - goto out; + if (!lp_posix_pathnames()) { + /* The newname must begin with a ':' if the + oldname contains a ':'. */ + if (strchr_m(oldname, ':')) { + if (newname[0] != ':') { + reply_nterror(req, NT_STATUS_INVALID_PARAMETER); + goto out; + } + stream_rename = true; + } } /* @@ -1579,6 +1586,17 @@ void reply_ntrename(struct smb_request *req) goto out; } + if (stream_rename) { + /* smb_fname_new must be the same as smb_fname_old. */ + TALLOC_FREE(smb_fname_new->base_name); + smb_fname_new->base_name = talloc_strdup(smb_fname_new, + smb_fname_old->base_name); + if (!smb_fname_new->base_name) { + reply_nterror(req, NT_STATUS_NO_MEMORY); + goto out; + } + } + DEBUG(3,("reply_ntrename: %s -> %s\n", smb_fname_str_dbg(smb_fname_old), smb_fname_str_dbg(smb_fname_new))); -- cgit