diff options
author | Volker Lendecke <vl@samba.org> | 2009-01-20 15:21:04 +0100 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2009-01-20 16:41:14 +0100 |
commit | b8b6cddb29b51dcbe0d352c1ce780804ee0664fd (patch) | |
tree | 298de8047299256b85c07db5dfebe455781b01dd /source3/smbd | |
parent | bd4718d2812f5f59d890be0284642ab78c3f1bc2 (diff) | |
download | samba-b8b6cddb29b51dcbe0d352c1ce780804ee0664fd.tar.gz samba-b8b6cddb29b51dcbe0d352c1ce780804ee0664fd.tar.bz2 samba-b8b6cddb29b51dcbe0d352c1ce780804ee0664fd.zip |
Remove some smb fsp knowledge from rpc_server/
np_open/read/write don't have to know about files_struct
Diffstat (limited to 'source3/smbd')
-rw-r--r-- | source3/smbd/ipc.c | 13 | ||||
-rw-r--r-- | source3/smbd/nttrans.c | 2 | ||||
-rw-r--r-- | source3/smbd/pipes.c | 54 |
3 files changed, 61 insertions, 8 deletions
diff --git a/source3/smbd/ipc.c b/source3/smbd/ipc.c index fabc8393ce..7c150561b1 100644 --- a/source3/smbd/ipc.c +++ b/source3/smbd/ipc.c @@ -220,8 +220,14 @@ static void api_rpc_trans_reply(connection_struct *conn, return; } - status = np_read(fsp, rdata, max_trans_reply, &data_len, - &is_data_outstanding); + if (!fsp_is_np(fsp)) { + SAFE_FREE(rdata); + api_no_reply(conn,req); + return; + } + + status = np_read(fsp->fake_file_handle, rdata, max_trans_reply, + &data_len, &is_data_outstanding); if (!NT_STATUS_IS_OK(status)) { SAFE_FREE(rdata); api_no_reply(conn,req); @@ -355,7 +361,8 @@ static void api_fd_reply(connection_struct *conn, uint16 vuid, case TRANSACT_DCERPCCMD: { /* dce/rpc command */ ssize_t nwritten; - status = np_write(fsp, data, tdscnt, &nwritten); + status = np_write(fsp->fake_file_handle, data, tdscnt, + &nwritten); if (!NT_STATUS_IS_OK(status)) { api_no_reply(conn, req); return; diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c index 63b4776fbc..1ee3edbdbe 100644 --- a/source3/smbd/nttrans.c +++ b/source3/smbd/nttrans.c @@ -316,7 +316,7 @@ static void nt_open_pipe(char *fname, connection_struct *conn, /* Strip \\ off the name. */ fname++; - status = np_open(req, fname, &fsp); + status = open_np_file(req, fname, &fsp); if (!NT_STATUS_IS_OK(status)) { if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) { reply_botherror(req, NT_STATUS_OBJECT_NAME_NOT_FOUND, diff --git a/source3/smbd/pipes.c b/source3/smbd/pipes.c index 4841882cc3..b148cff045 100644 --- a/source3/smbd/pipes.c +++ b/source3/smbd/pipes.c @@ -32,6 +32,40 @@ #define MAX_PIPE_NAME_LEN 24 +NTSTATUS open_np_file(struct smb_request *smb_req, const char *name, + struct files_struct **pfsp) +{ + struct connection_struct *conn = smb_req->conn; + struct files_struct *fsp; + NTSTATUS status; + + status = file_new(smb_req, conn, &fsp); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0, ("file_new failed: %s\n", nt_errstr(status))); + return status; + } + + fsp->conn = conn; + fsp->fh->fd = -1; + fsp->vuid = smb_req->vuid; + fsp->can_lock = false; + fsp->access_mask = FILE_READ_DATA | FILE_WRITE_DATA; + string_set(&fsp->fsp_name, name); + + status = np_open(NULL, name, conn->client_address, + conn->server_info, &fsp->fake_file_handle); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(10, ("np_open(%s) returned %s\n", name, + nt_errstr(status))); + file_free(smb_req, fsp); + return status; + } + + *pfsp = fsp; + + return NT_STATUS_OK; +} + /**************************************************************************** Reply to an open and X on a named pipe. This code is basically stolen from reply_open_and_X with some @@ -77,7 +111,7 @@ void reply_open_pipe_and_X(connection_struct *conn, struct smb_request *req) } #endif - status = np_open(req, fname, &fsp); + status = open_np_file(req, fname, &fsp); if (!NT_STATUS_IS_OK(status)) { if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) { reply_botherror(req, NT_STATUS_OBJECT_NAME_NOT_FOUND, @@ -133,7 +167,14 @@ void reply_pipe_write(struct smb_request *req) nwritten = 0; } else { NTSTATUS status; - status = np_write(fsp, data, numtowrite, &nwritten); + if (!fsp_is_np(fsp)) { + reply_nterror(req, NT_STATUS_INVALID_HANDLE); + return; + } + DEBUG(6, ("reply_pipe_write: %x name: %s len: %d\n", + (int)fsp->fnum, fsp->fsp_name, (int)numtowrite)); + status = np_write(fsp->fake_file_handle, data, numtowrite, + &nwritten); if (!NT_STATUS_IS_OK(status)) { reply_nterror(req, status); return; @@ -183,6 +224,9 @@ void reply_pipe_write_and_X(struct smb_request *req) return; } + DEBUG(6, ("reply_pipe_write_and_X: %x name: %s len: %d\n", + (int)fsp->fnum, fsp->fsp_name, (int)numtowrite)); + data = (uint8_t *)smb_base(req->inbuf) + smb_doff; if (numtowrite == 0) { @@ -208,7 +252,8 @@ void reply_pipe_write_and_X(struct smb_request *req) data += 2; numtowrite -= 2; } - status = np_write(fsp, data, numtowrite, &nwritten); + status = np_write(fsp->fake_file_handle, data, numtowrite, + &nwritten); if (!NT_STATUS_IS_OK(status)) { reply_nterror(req, status); return; @@ -268,7 +313,8 @@ void reply_pipe_read_and_X(struct smb_request *req) data = (uint8_t *)smb_buf(req->outbuf); - status = np_read(fsp, data, smb_maxcnt, &nread, &unused); + status = np_read(fsp->fake_file_handle, data, smb_maxcnt, &nread, + &unused); if (!NT_STATUS_IS_OK(status)) { reply_doserror(req, ERRDOS, ERRnoaccess); |