From 2945d4492d10d83acd2d345339da941db5d7fc53 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 2 Aug 2007 19:50:56 +0000 Subject: r24141: Add check_fsp as a replacement for CHECK_FSP (This used to be commit a3d77a576f863c4d9f95a1a898f70ae5b5bbc471) --- source3/smbd/reply.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'source3') diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 0bb9d9ca7d..91e4274814 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -284,6 +284,33 @@ size_t srvstr_get_path(const char *inbuf, uint16 smb_flags2, char *dest, return ret; } +/**************************************************************************** + Check if we have a correct fsp pointing to a file. Replacement for the + CHECK_FSP macro. +****************************************************************************/ +BOOL check_fsp(connection_struct *conn, struct smb_request *req, + files_struct *fsp, struct current_user *user) +{ + if (!(fsp) || !(conn)) { + reply_nterror(req, NT_STATUS_INVALID_HANDLE); + return False; + } + if (((conn) != (fsp)->conn) || current_user.vuid != (fsp)->vuid) { + reply_nterror(req, NT_STATUS_INVALID_HANDLE); + return False; + } + if ((fsp)->is_directory) { + reply_nterror(req, NT_STATUS_INVALID_DEVICE_REQUEST); + return False; + } + if ((fsp)->fh->fd == -1) { + reply_nterror(req, NT_STATUS_ACCESS_DENIED); + return False; + } + (fsp)->num_smb_operations++; + return True; +} + /**************************************************************************** Reply to a (netbios-level) special message. ****************************************************************************/ -- cgit