From e8573c8fa928602fd979d5ac45c692e7464f0aad Mon Sep 17 00:00:00 2001 From: Alexander Bokovoy Date: Mon, 12 May 2003 01:20:17 +0000 Subject: Add NT quota support. Patch from Stefan (metze) Metzemacher 1. Allows to change quota settings for shared mount points from Win2K and WinXP from Explorer properties tab 2. Disabled by default and when requested, will be probed and enabled only on Linux where it works 3. Was tested for approx. two weeks now on Linux by two independent QA teams, have not found any bugs so far Documentation to follow (This used to be commit 4bf022ce9e45be85609426762ba2644ac2031326) --- source3/smbd/fake_file.c | 166 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100644 source3/smbd/fake_file.c (limited to 'source3/smbd/fake_file.c') diff --git a/source3/smbd/fake_file.c b/source3/smbd/fake_file.c new file mode 100644 index 0000000000..86d78e039a --- /dev/null +++ b/source3/smbd/fake_file.c @@ -0,0 +1,166 @@ +/* + Unix SMB/CIFS implementation. + FAKE FILE suppport, for faking up special files windows want access to + Copyright (C) Stefan (metze) Metzmacher 2003 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + +/**************************************************************************** + Open a file with a share mode. +****************************************************************************/ +files_struct *open_fake_file_shared1(enum FAKE_FILE_TYPE fake_file_type, connection_struct *conn,char *fname, + SMB_STRUCT_STAT *psbuf, + uint32 desired_access, + int share_mode,int ofun, mode_t mode,int oplock_request, + int *Access,int *action) +{ + extern struct current_user current_user; + int flags=0; + files_struct *fsp = NULL; + + if (fake_file_type == 0) { + return open_file_shared1(conn,fname,psbuf,desired_access, + share_mode,ofun,mode, + oplock_request,Access,action); + } + + /* access check */ + if (conn->admin_user != True) { + DEBUG(1,("access_denied to service[%s] file[%s] user[%s]\n", + lp_servicename(SNUM(conn)),fname,conn->user)); + errno = EACCES; + return NULL; + } + + fsp = file_new(conn); + if(!fsp) + return NULL; + + DEBUG(5,("open_fake_file_shared1: fname = %s, FID = %d, share_mode = %x, ofun = %x, mode = %o, oplock request = %d\n", + fname, fsp->fnum, share_mode, ofun, (int)mode, oplock_request )); + + if (!check_name(fname,conn)) { + file_free(fsp); + return NULL; + } + + fsp->fd = -1; + fsp->mode = psbuf->st_mode; + fsp->inode = psbuf->st_ino; + fsp->dev = psbuf->st_dev; + fsp->vuid = current_user.vuid; + fsp->size = psbuf->st_size; + fsp->pos = -1; + fsp->can_lock = True; + fsp->can_read = ((flags & O_WRONLY)==0); + fsp->can_write = ((flags & (O_WRONLY|O_RDWR))!=0); + fsp->share_mode = 0; + fsp->desired_access = desired_access; + fsp->print_file = False; + fsp->modified = False; + fsp->oplock_type = NO_OPLOCK; + fsp->sent_oplock_break = NO_BREAK_SENT; + fsp->is_directory = False; + fsp->is_stat = False; + fsp->directory_delete_on_close = False; + fsp->conn = conn; + string_set(&fsp->fsp_name,fname); + fsp->wcp = NULL; /* Write cache pointer. */ + + fsp->fake_file_handle = init_fake_file_handle(fake_file_type); + + if (fsp->fake_file_handle==NULL) { + file_free(fsp); + return NULL; + } + + conn->num_files_open++; + return fsp; +} + +static FAKE_FILE fake_files[] = { +#ifdef WITH_QUOTAS + {FAKE_FILE_NAME_QUOTA, FAKE_FILE_TYPE_QUOTA, init_quota_handle, destroy_quota_handle}, +#endif /* WITH_QUOTAS */ + {NULL, FAKE_FILE_TYPE_NONE, NULL, NULL } +}; + +int is_fake_file(char *fname) +{ + int i; + + if (!fname) + return 0; + + for (i=0;fake_files[i].name!=NULL;i++) { + if (strncmp(fname,fake_files[i].name,strlen(fake_files[i].name))==0) { + DEBUG(5,("is_fake_file: [%s] is a fake file\n",fname)); + return fake_files[i].type; + } + } + + return FAKE_FILE_TYPE_NONE; +} + +struct _FAKE_FILE_HANDLE *init_fake_file_handle(enum FAKE_FILE_TYPE type) +{ + TALLOC_CTX *mem_ctx = NULL; + FAKE_FILE_HANDLE *fh = NULL; + int i; + + for (i=0;fake_files[i].name!=NULL;i++) { + if (fake_files[i].type==type) { + DEBUG(5,("init_fake_file_handle: for [%s]\n",fake_files[i].name)); + + if ((mem_ctx=talloc_init("fake_file_handle"))==NULL) { + DEBUG(0,("talloc_init(fake_file_handle) failed.\n")); + return NULL; + } + + if ((fh =(FAKE_FILE_HANDLE *)talloc_zero(mem_ctx, sizeof(FAKE_FILE_HANDLE)))==NULL) { + DEBUG(0,("talloc_zero() failed.\n")); + talloc_destroy(mem_ctx); + return NULL; + } + + fh->type = type; + fh->mem_ctx = mem_ctx; + + if (fake_files[i].init_pd) + fh->pd = fake_files[i].init_pd(fh->mem_ctx); + + fh->free_pd = fake_files[i].free_pd; + + return fh; + } + } + + return NULL; +} + +void destroy_fake_file_handle(FAKE_FILE_HANDLE **fh) +{ + if (!fh||!(*fh)) + return ; + + if ((*fh)->free_pd) + (*fh)->free_pd(&(*fh)->pd); + + talloc_destroy((*fh)->mem_ctx); + (*fh) = NULL; +} -- cgit From 722aa118c66b020c2b9f2b595e1af50429f13986 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 2 Apr 2004 18:46:19 +0000 Subject: Added per-share parameter "store dos attributes". When set, will store dos attributes in an EA. Based on an original patch from tridge, but modified somewhat to cover all cases. Jeremy. (This used to be commit ed653cd468213e0be901bc654aa3748ce5837947) --- source3/smbd/fake_file.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/smbd/fake_file.c') diff --git a/source3/smbd/fake_file.c b/source3/smbd/fake_file.c index 86d78e039a..5ccb548ba5 100644 --- a/source3/smbd/fake_file.c +++ b/source3/smbd/fake_file.c @@ -26,7 +26,7 @@ files_struct *open_fake_file_shared1(enum FAKE_FILE_TYPE fake_file_type, connection_struct *conn,char *fname, SMB_STRUCT_STAT *psbuf, uint32 desired_access, - int share_mode,int ofun, mode_t mode,int oplock_request, + int share_mode,int ofun, uint32 new_dos_attr, int oplock_request, int *Access,int *action) { extern struct current_user current_user; @@ -35,7 +35,7 @@ files_struct *open_fake_file_shared1(enum FAKE_FILE_TYPE fake_file_type, connect if (fake_file_type == 0) { return open_file_shared1(conn,fname,psbuf,desired_access, - share_mode,ofun,mode, + share_mode,ofun,new_dos_attr, oplock_request,Access,action); } @@ -51,8 +51,8 @@ files_struct *open_fake_file_shared1(enum FAKE_FILE_TYPE fake_file_type, connect if(!fsp) return NULL; - DEBUG(5,("open_fake_file_shared1: fname = %s, FID = %d, share_mode = %x, ofun = %x, mode = %o, oplock request = %d\n", - fname, fsp->fnum, share_mode, ofun, (int)mode, oplock_request )); + DEBUG(5,("open_fake_file_shared1: fname = %s, FID = %d, share_mode = %x, ofun = %x, oplock request = %d\n", + fname, fsp->fnum, share_mode, ofun, oplock_request )); if (!check_name(fname,conn)) { file_free(fsp); -- cgit From 77182a81f0e370584d37dc9368f0697b8cf69afd Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 29 Apr 2004 17:19:42 +0000 Subject: r408: - replace (conn->admin_user != True) with (current_user.uid != 0) because someone changed it in all other places too - fix quotas support from windows explorer we now got the unix file name of a fake_file metze (This used to be commit 87e97d7723674e3835578ef080ce554d9c5537ac) --- source3/smbd/fake_file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/fake_file.c') diff --git a/source3/smbd/fake_file.c b/source3/smbd/fake_file.c index 5ccb548ba5..d3660addf1 100644 --- a/source3/smbd/fake_file.c +++ b/source3/smbd/fake_file.c @@ -40,7 +40,7 @@ files_struct *open_fake_file_shared1(enum FAKE_FILE_TYPE fake_file_type, connect } /* access check */ - if (conn->admin_user != True) { + if (current_user.uid != 0) { DEBUG(1,("access_denied to service[%s] file[%s] user[%s]\n", lp_servicename(SNUM(conn)),fname,conn->user)); errno = EACCES; -- cgit From 10e4a96b5399a7ecbc893d2493a9ceb3ec66c8ed Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 17 Sep 2004 15:09:20 +0000 Subject: r2388: fix client quota support for the client we need the windows path and for server we need unix path metze (This used to be commit 54fd28f5e7b70ce2b192c2037ce28da3fea9ef92) --- source3/smbd/fake_file.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/smbd/fake_file.c') diff --git a/source3/smbd/fake_file.c b/source3/smbd/fake_file.c index d3660addf1..fc874dc086 100644 --- a/source3/smbd/fake_file.c +++ b/source3/smbd/fake_file.c @@ -95,9 +95,9 @@ files_struct *open_fake_file_shared1(enum FAKE_FILE_TYPE fake_file_type, connect static FAKE_FILE fake_files[] = { #ifdef WITH_QUOTAS - {FAKE_FILE_NAME_QUOTA, FAKE_FILE_TYPE_QUOTA, init_quota_handle, destroy_quota_handle}, + {FAKE_FILE_NAME_QUOTA_UNIX, FAKE_FILE_TYPE_QUOTA, init_quota_handle, destroy_quota_handle}, #endif /* WITH_QUOTAS */ - {NULL, FAKE_FILE_TYPE_NONE, NULL, NULL } + {NULL, FAKE_FILE_TYPE_NONE, NULL, NULL } }; int is_fake_file(char *fname) @@ -156,7 +156,7 @@ struct _FAKE_FILE_HANDLE *init_fake_file_handle(enum FAKE_FILE_TYPE type) void destroy_fake_file_handle(FAKE_FILE_HANDLE **fh) { if (!fh||!(*fh)) - return ; + return; if ((*fh)->free_pd) (*fh)->free_pd(&(*fh)->pd); -- cgit From acf9d61421faa6c0055d57fdee7db300dc5431aa Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 7 Dec 2004 18:25:53 +0000 Subject: r4088: Get medieval on our ass about malloc.... :-). Take control of all our allocation functions so we can funnel through some well known functions. Should help greatly with malloc checking. HEAD patch to follow. Jeremy. (This used to be commit 620f2e608f70ba92f032720c031283d295c5c06a) --- source3/smbd/fake_file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/fake_file.c') diff --git a/source3/smbd/fake_file.c b/source3/smbd/fake_file.c index fc874dc086..53aac1e036 100644 --- a/source3/smbd/fake_file.c +++ b/source3/smbd/fake_file.c @@ -132,7 +132,7 @@ struct _FAKE_FILE_HANDLE *init_fake_file_handle(enum FAKE_FILE_TYPE type) return NULL; } - if ((fh =(FAKE_FILE_HANDLE *)talloc_zero(mem_ctx, sizeof(FAKE_FILE_HANDLE)))==NULL) { + if ((fh =TALLOC_ZERO_P(mem_ctx, FAKE_FILE_HANDLE))==NULL) { DEBUG(0,("talloc_zero() failed.\n")); talloc_destroy(mem_ctx); return NULL; -- cgit From 978ca8486031e43754a3c23757f361bf3a85f335 Mon Sep 17 00:00:00 2001 From: Herb Lewis Date: Wed, 6 Apr 2005 16:28:04 +0000 Subject: r6225: get rid of warnings from my compiler about nested externs (This used to be commit efea76ac71412f8622cd233912309e91b9ea52da) --- source3/smbd/fake_file.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/smbd/fake_file.c') diff --git a/source3/smbd/fake_file.c b/source3/smbd/fake_file.c index 53aac1e036..ee510eb003 100644 --- a/source3/smbd/fake_file.c +++ b/source3/smbd/fake_file.c @@ -20,6 +20,8 @@ #include "includes.h" +extern struct current_user current_user; + /**************************************************************************** Open a file with a share mode. ****************************************************************************/ @@ -29,7 +31,6 @@ files_struct *open_fake_file_shared1(enum FAKE_FILE_TYPE fake_file_type, connect int share_mode,int ofun, uint32 new_dos_attr, int oplock_request, int *Access,int *action) { - extern struct current_user current_user; int flags=0; files_struct *fsp = NULL; -- cgit From 08355754151b2d02b2102bc76e94b63ffffdf408 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sun, 8 May 2005 23:16:28 +0000 Subject: r6673: Fix the write cache based on some VERY good detective work from Ingo Kilian . You must do a make clean after updating this. Jeremy. (This used to be commit 3b2cd19fcb8ce38578b122fd6ae722b73081dcda) --- source3/smbd/fake_file.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source3/smbd/fake_file.c') diff --git a/source3/smbd/fake_file.c b/source3/smbd/fake_file.c index ee510eb003..59ddb60db5 100644 --- a/source3/smbd/fake_file.c +++ b/source3/smbd/fake_file.c @@ -65,7 +65,6 @@ files_struct *open_fake_file_shared1(enum FAKE_FILE_TYPE fake_file_type, connect fsp->inode = psbuf->st_ino; fsp->dev = psbuf->st_dev; fsp->vuid = current_user.vuid; - fsp->size = psbuf->st_size; fsp->pos = -1; fsp->can_lock = True; fsp->can_read = ((flags & O_WRONLY)==0); -- cgit From af8a691db11a5072865f8b03fd1cbd3aab5cb6d7 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 8 Jul 2005 04:51:27 +0000 Subject: r8219: Merge the new open code from HEAD to 3.0. Haven't yet run the torture tests on this as it's very late NY time (just wanted to get this work into the tree). I'll test this over the weekend.... Jerry - in looking at the difference between the two trees there seem to be some printing/ntprinting.c and registry changes we might want to examine to try keep in sync. Jeremy. (This used to be commit c7fe18761e2c753afbffd3a78abff46472a9b8eb) --- source3/smbd/fake_file.c | 174 ++++++++++++++++++++++------------------------- 1 file changed, 83 insertions(+), 91 deletions(-) (limited to 'source3/smbd/fake_file.c') diff --git a/source3/smbd/fake_file.c b/source3/smbd/fake_file.c index 59ddb60db5..799725a782 100644 --- a/source3/smbd/fake_file.c +++ b/source3/smbd/fake_file.c @@ -22,77 +22,6 @@ extern struct current_user current_user; -/**************************************************************************** - Open a file with a share mode. -****************************************************************************/ -files_struct *open_fake_file_shared1(enum FAKE_FILE_TYPE fake_file_type, connection_struct *conn,char *fname, - SMB_STRUCT_STAT *psbuf, - uint32 desired_access, - int share_mode,int ofun, uint32 new_dos_attr, int oplock_request, - int *Access,int *action) -{ - int flags=0; - files_struct *fsp = NULL; - - if (fake_file_type == 0) { - return open_file_shared1(conn,fname,psbuf,desired_access, - share_mode,ofun,new_dos_attr, - oplock_request,Access,action); - } - - /* access check */ - if (current_user.uid != 0) { - DEBUG(1,("access_denied to service[%s] file[%s] user[%s]\n", - lp_servicename(SNUM(conn)),fname,conn->user)); - errno = EACCES; - return NULL; - } - - fsp = file_new(conn); - if(!fsp) - return NULL; - - DEBUG(5,("open_fake_file_shared1: fname = %s, FID = %d, share_mode = %x, ofun = %x, oplock request = %d\n", - fname, fsp->fnum, share_mode, ofun, oplock_request )); - - if (!check_name(fname,conn)) { - file_free(fsp); - return NULL; - } - - fsp->fd = -1; - fsp->mode = psbuf->st_mode; - fsp->inode = psbuf->st_ino; - fsp->dev = psbuf->st_dev; - fsp->vuid = current_user.vuid; - fsp->pos = -1; - fsp->can_lock = True; - fsp->can_read = ((flags & O_WRONLY)==0); - fsp->can_write = ((flags & (O_WRONLY|O_RDWR))!=0); - fsp->share_mode = 0; - fsp->desired_access = desired_access; - fsp->print_file = False; - fsp->modified = False; - fsp->oplock_type = NO_OPLOCK; - fsp->sent_oplock_break = NO_BREAK_SENT; - fsp->is_directory = False; - fsp->is_stat = False; - fsp->directory_delete_on_close = False; - fsp->conn = conn; - string_set(&fsp->fsp_name,fname); - fsp->wcp = NULL; /* Write cache pointer. */ - - fsp->fake_file_handle = init_fake_file_handle(fake_file_type); - - if (fsp->fake_file_handle==NULL) { - file_free(fsp); - return NULL; - } - - conn->num_files_open++; - return fsp; -} - static FAKE_FILE fake_files[] = { #ifdef WITH_QUOTAS {FAKE_FILE_NAME_QUOTA_UNIX, FAKE_FILE_TYPE_QUOTA, init_quota_handle, destroy_quota_handle}, @@ -100,24 +29,11 @@ static FAKE_FILE fake_files[] = { {NULL, FAKE_FILE_TYPE_NONE, NULL, NULL } }; -int is_fake_file(char *fname) -{ - int i; - - if (!fname) - return 0; - - for (i=0;fake_files[i].name!=NULL;i++) { - if (strncmp(fname,fake_files[i].name,strlen(fake_files[i].name))==0) { - DEBUG(5,("is_fake_file: [%s] is a fake file\n",fname)); - return fake_files[i].type; - } - } - - return FAKE_FILE_TYPE_NONE; -} +/**************************************************************************** + Create a fake file handle +****************************************************************************/ -struct _FAKE_FILE_HANDLE *init_fake_file_handle(enum FAKE_FILE_TYPE type) +static struct _FAKE_FILE_HANDLE *init_fake_file_handle(enum FAKE_FILE_TYPE type) { TALLOC_CTX *mem_ctx = NULL; FAKE_FILE_HANDLE *fh = NULL; @@ -141,8 +57,9 @@ struct _FAKE_FILE_HANDLE *init_fake_file_handle(enum FAKE_FILE_TYPE type) fh->type = type; fh->mem_ctx = mem_ctx; - if (fake_files[i].init_pd) + if (fake_files[i].init_pd) { fh->pd = fake_files[i].init_pd(fh->mem_ctx); + } fh->free_pd = fake_files[i].free_pd; @@ -153,13 +70,88 @@ struct _FAKE_FILE_HANDLE *init_fake_file_handle(enum FAKE_FILE_TYPE type) return NULL; } +/**************************************************************************** + Does this name match a fake filename ? +****************************************************************************/ + +enum FAKE_FILE_TYPE is_fake_file(const char *fname) +{ +#ifdef HAVE_SYS_QUOTAS + int i; +#endif + + if (!fname) { + return FAKE_FILE_TYPE_NONE; + } + +#ifdef HAVE_SYS_QUOTAS + for (i=0;fake_files[i].name!=NULL;i++) { + if (strncmp(fname,fake_files[i].name,strlen(fake_files[i].name))==0) { + DEBUG(5,("is_fake_file: [%s] is a fake file\n",fname)); + return fake_files[i].type; + } + } +#endif + + return FAKE_FILE_TYPE_NONE; +} + + +/**************************************************************************** + Open a fake quota file with a share mode. +****************************************************************************/ + +files_struct *open_fake_file(connection_struct *conn, + enum FAKE_FILE_TYPE fake_file_type, + const char *fname, + uint32 access_mask) +{ + files_struct *fsp = NULL; + + /* access check */ + if (current_user.uid != 0) { + DEBUG(1,("open_fake_file_shared: access_denied to service[%s] file[%s] user[%s]\n", + lp_servicename(SNUM(conn)),fname,conn->user)); + errno = EACCES; + return NULL; + } + + fsp = file_new(conn); + if(!fsp) { + return NULL; + } + + DEBUG(5,("open_fake_file_shared: fname = %s, FID = %d, access_mask = 0x%x\n", + fname, fsp->fnum, (unsigned int)access_mask)); + + fsp->conn = conn; + fsp->fh->fd = -1; + fsp->vuid = current_user.vuid; + fsp->fh->pos = -1; + fsp->can_lock = True; /* Should this be true ? */ + fsp->access_mask = access_mask; + string_set(&fsp->fsp_name,fname); + + fsp->fake_file_handle = init_fake_file_handle(fake_file_type); + + if (fsp->fake_file_handle==NULL) { + file_free(fsp); + return NULL; + } + + conn->num_files_open++; + return fsp; +} + void destroy_fake_file_handle(FAKE_FILE_HANDLE **fh) { - if (!fh||!(*fh)) + if (!fh||!(*fh)) { return; + } - if ((*fh)->free_pd) + if ((*fh)->free_pd) { (*fh)->free_pd(&(*fh)->pd); + } talloc_destroy((*fh)->mem_ctx); (*fh) = NULL; -- cgit From d14af63e6ab600eb3ac705f2f425c860e927553a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 2 Feb 2006 20:44:50 +0000 Subject: r13293: Rather a big patch I'm afraid, but this should fix bug #3347 by saving the UNIX token used to set a delete on close flag, and using it when doing the delete. libsmbsharemodes.so still needs updating to cope with this change. Samba4 torture tests to follow. Jeremy. (This used to be commit 23f16cbc2e8cde97c486831e26bcafd4ab4a9654) --- source3/smbd/fake_file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/fake_file.c') diff --git a/source3/smbd/fake_file.c b/source3/smbd/fake_file.c index 799725a782..1356baf1a8 100644 --- a/source3/smbd/fake_file.c +++ b/source3/smbd/fake_file.c @@ -109,7 +109,7 @@ files_struct *open_fake_file(connection_struct *conn, files_struct *fsp = NULL; /* access check */ - if (current_user.uid != 0) { + if (current_user.ut.uid != 0) { DEBUG(1,("open_fake_file_shared: access_denied to service[%s] file[%s] user[%s]\n", lp_servicename(SNUM(conn)),fname,conn->user)); errno = EACCES; -- cgit From c91a675ac108f48046ce72287c6d70a1a54ef65f Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 17 May 2006 15:01:57 +0000 Subject: r15660: Without this when using smbcquotas I get MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit close fd=-1 fnum=4321 (numopen=1) close_file: Could not get share mode lock for file $Extend/$Quota:$Q:$INDEX_ALLOCATION unix_error_packet: error string = Das Argument ist ungültig error packet at smbd/reply.c(3325) cmd=4 (SMBclose) NT_STATUS_INVALID_HANDLE so a fake file needs special close handling I think. Jeremy, can you check this? Thanks, Volker (This used to be commit f66b9701b5c6bb6302fa11889adab6902cbaf2e3) --- source3/smbd/fake_file.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source3/smbd/fake_file.c') diff --git a/source3/smbd/fake_file.c b/source3/smbd/fake_file.c index 1356baf1a8..b4f1f02b72 100644 --- a/source3/smbd/fake_file.c +++ b/source3/smbd/fake_file.c @@ -156,3 +156,9 @@ void destroy_fake_file_handle(FAKE_FILE_HANDLE **fh) talloc_destroy((*fh)->mem_ctx); (*fh) = NULL; } + +int close_fake_file(files_struct *fsp) +{ + file_free(fsp); + return 0; +} -- cgit From fbdcf2663b56007a438ac4f0d8d82436b1bfe688 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 11 Jul 2006 18:01:26 +0000 Subject: r16945: Sync trunk -> 3.0 for 3.0.24 code. Still need to do the upper layer directories but this is what everyone is waiting for.... Jeremy. (This used to be commit 9dafb7f48ca3e7af956b0a7d1720c2546fc4cfb8) --- source3/smbd/fake_file.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'source3/smbd/fake_file.c') diff --git a/source3/smbd/fake_file.c b/source3/smbd/fake_file.c index b4f1f02b72..7c5eeae5c7 100644 --- a/source3/smbd/fake_file.c +++ b/source3/smbd/fake_file.c @@ -101,24 +101,26 @@ enum FAKE_FILE_TYPE is_fake_file(const char *fname) Open a fake quota file with a share mode. ****************************************************************************/ -files_struct *open_fake_file(connection_struct *conn, +NTSTATUS open_fake_file(connection_struct *conn, enum FAKE_FILE_TYPE fake_file_type, const char *fname, - uint32 access_mask) + uint32 access_mask, + files_struct **result) { files_struct *fsp = NULL; + NTSTATUS status; /* access check */ if (current_user.ut.uid != 0) { DEBUG(1,("open_fake_file_shared: access_denied to service[%s] file[%s] user[%s]\n", lp_servicename(SNUM(conn)),fname,conn->user)); - errno = EACCES; - return NULL; + return NT_STATUS_ACCESS_DENIED; + } - fsp = file_new(conn); - if(!fsp) { - return NULL; + status = file_new(conn, &fsp); + if(!NT_STATUS_IS_OK(status)) { + return status; } DEBUG(5,("open_fake_file_shared: fname = %s, FID = %d, access_mask = 0x%x\n", @@ -128,7 +130,7 @@ files_struct *open_fake_file(connection_struct *conn, fsp->fh->fd = -1; fsp->vuid = current_user.vuid; fsp->fh->pos = -1; - fsp->can_lock = True; /* Should this be true ? */ + fsp->can_lock = False; /* Should this be true ? - No, JRA */ fsp->access_mask = access_mask; string_set(&fsp->fsp_name,fname); @@ -136,11 +138,12 @@ files_struct *open_fake_file(connection_struct *conn, if (fsp->fake_file_handle==NULL) { file_free(fsp); - return NULL; + return NT_STATUS_NO_MEMORY; } conn->num_files_open++; - return fsp; + *result = fsp; + return NT_STATUS_OK; } void destroy_fake_file_handle(FAKE_FILE_HANDLE **fh) -- cgit From 7a5fa7f12ec439ef5a4af29aa86498f799b6b9a5 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 6 Feb 2007 21:05:34 +0000 Subject: r21191: Add in the POSIX open/mkdir/unlink calls. Move more error code returns to NTSTATUS. Client test code to follow... See if this passes the build-farm before I add it into 3.0.25. Jeremy. (This used to be commit 83dbbdff345fa9e427c9579183f4380004bf3dd7) --- source3/smbd/fake_file.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/smbd/fake_file.c') diff --git a/source3/smbd/fake_file.c b/source3/smbd/fake_file.c index 7c5eeae5c7..208b325667 100644 --- a/source3/smbd/fake_file.c +++ b/source3/smbd/fake_file.c @@ -160,8 +160,8 @@ void destroy_fake_file_handle(FAKE_FILE_HANDLE **fh) (*fh) = NULL; } -int close_fake_file(files_struct *fsp) +NTSTATUS close_fake_file(files_struct *fsp) { file_free(fsp); - return 0; + return NT_STATUS_OK; } -- cgit From 12ba88574bf91bdcc4447bfc3d429b799064bfd9 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 27 Apr 2007 23:18:41 +0000 Subject: r22542: Move over to using the _strict varients of the talloc calls. No functional changes. Looks bigger than it is :-). Jeremy. (This used to be commit f6fa3080fee1b20df9f1968500840a88cf0ee592) --- source3/smbd/fake_file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/fake_file.c') diff --git a/source3/smbd/fake_file.c b/source3/smbd/fake_file.c index 208b325667..5333742ba8 100644 --- a/source3/smbd/fake_file.c +++ b/source3/smbd/fake_file.c @@ -49,7 +49,7 @@ static struct _FAKE_FILE_HANDLE *init_fake_file_handle(enum FAKE_FILE_TYPE type) } if ((fh =TALLOC_ZERO_P(mem_ctx, FAKE_FILE_HANDLE))==NULL) { - DEBUG(0,("talloc_zero() failed.\n")); + DEBUG(0,("TALLOC_ZERO() failed.\n")); talloc_destroy(mem_ctx); return NULL; } -- cgit From d824b98f80ba186030cbb70b3a1e5daf80469ecd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 9 Jul 2007 19:25:36 +0000 Subject: r23779: Change from v2 or later to v3 or later. Jeremy. (This used to be commit 407e6e695b8366369b7c76af1ff76869b45347b3) --- source3/smbd/fake_file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/fake_file.c') diff --git a/source3/smbd/fake_file.c b/source3/smbd/fake_file.c index 5333742ba8..17617ce443 100644 --- a/source3/smbd/fake_file.c +++ b/source3/smbd/fake_file.c @@ -5,7 +5,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, -- cgit From 5e54558c6dea67b56bbfaba5698f3a434d3dffb6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 00:52:41 +0000 Subject: r23784: use the GPLv3 boilerplate as recommended by the FSF and the license text (This used to be commit b0132e94fc5fef936aa766fb99a306b3628e9f07) --- source3/smbd/fake_file.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/smbd/fake_file.c') diff --git a/source3/smbd/fake_file.c b/source3/smbd/fake_file.c index 17617ce443..e4f71193e1 100644 --- a/source3/smbd/fake_file.c +++ b/source3/smbd/fake_file.c @@ -14,8 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" -- cgit From a2366187ad4e1308c8885ee6f928c747596a6c67 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 2 Dec 2007 12:54:11 +0100 Subject: Bump up debug level Fix bug 5115 (This used to be commit d3c839c22edeca2de68574a8f5dd328080577f3a) --- source3/smbd/fake_file.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source3/smbd/fake_file.c') diff --git a/source3/smbd/fake_file.c b/source3/smbd/fake_file.c index e4f71193e1..31fe030f46 100644 --- a/source3/smbd/fake_file.c +++ b/source3/smbd/fake_file.c @@ -111,8 +111,9 @@ NTSTATUS open_fake_file(connection_struct *conn, /* access check */ if (current_user.ut.uid != 0) { - DEBUG(1,("open_fake_file_shared: access_denied to service[%s] file[%s] user[%s]\n", - lp_servicename(SNUM(conn)),fname,conn->user)); + DEBUG(3, ("open_fake_file_shared: access_denied to " + "service[%s] file[%s] user[%s]\n", + lp_servicename(SNUM(conn)),fname,conn->user)); return NT_STATUS_ACCESS_DENIED; } -- cgit From 5bda9a8af02c7889e15e580a5620689aa312a16a Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 8 May 2008 16:06:42 +0200 Subject: Remove "user" from connection_struct (This used to be commit 368454a27cb53a408ec416cbf37235b304592fb5) --- source3/smbd/fake_file.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/smbd/fake_file.c') diff --git a/source3/smbd/fake_file.c b/source3/smbd/fake_file.c index 31fe030f46..0a54c85cd0 100644 --- a/source3/smbd/fake_file.c +++ b/source3/smbd/fake_file.c @@ -113,7 +113,8 @@ NTSTATUS open_fake_file(connection_struct *conn, if (current_user.ut.uid != 0) { DEBUG(3, ("open_fake_file_shared: access_denied to " "service[%s] file[%s] user[%s]\n", - lp_servicename(SNUM(conn)),fname,conn->user)); + lp_servicename(SNUM(conn)), fname, + conn->server_info->unix_name)); return NT_STATUS_ACCESS_DENIED; } -- cgit From e58729f0eaefb5659396f7f0ecb6239806ee275f Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 29 Mar 2008 18:19:31 +0100 Subject: Simplify fake_file logic (This used to be commit 93111ea0a1191e8547ad6cf112e2699d3bb3799b) --- source3/smbd/fake_file.c | 68 ++++++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 37 deletions(-) (limited to 'source3/smbd/fake_file.c') diff --git a/source3/smbd/fake_file.c b/source3/smbd/fake_file.c index 0a54c85cd0..565b557dd3 100644 --- a/source3/smbd/fake_file.c +++ b/source3/smbd/fake_file.c @@ -21,52 +21,52 @@ extern struct current_user current_user; -static FAKE_FILE fake_files[] = { +struct fake_file_type { + const char *name; + enum FAKE_FILE_TYPE type; + void *(*init_pd)(TALLOC_CTX *mem_ctx); +}; + +static struct fake_file_type fake_files[] = { #ifdef WITH_QUOTAS - {FAKE_FILE_NAME_QUOTA_UNIX, FAKE_FILE_TYPE_QUOTA, init_quota_handle, destroy_quota_handle}, + {FAKE_FILE_NAME_QUOTA_UNIX, FAKE_FILE_TYPE_QUOTA, init_quota_handle}, #endif /* WITH_QUOTAS */ - {NULL, FAKE_FILE_TYPE_NONE, NULL, NULL } + {NULL, FAKE_FILE_TYPE_NONE, NULL} }; /**************************************************************************** Create a fake file handle ****************************************************************************/ -static struct _FAKE_FILE_HANDLE *init_fake_file_handle(enum FAKE_FILE_TYPE type) +static struct fake_file_handle *init_fake_file_handle(enum FAKE_FILE_TYPE type) { - TALLOC_CTX *mem_ctx = NULL; - FAKE_FILE_HANDLE *fh = NULL; + struct fake_file_handle *fh = NULL; int i; - for (i=0;fake_files[i].name!=NULL;i++) { + for (i=0; fake_files[i].name!=NULL; i++) { if (fake_files[i].type==type) { - DEBUG(5,("init_fake_file_handle: for [%s]\n",fake_files[i].name)); - - if ((mem_ctx=talloc_init("fake_file_handle"))==NULL) { - DEBUG(0,("talloc_init(fake_file_handle) failed.\n")); - return NULL; - } + break; + } + } - if ((fh =TALLOC_ZERO_P(mem_ctx, FAKE_FILE_HANDLE))==NULL) { - DEBUG(0,("TALLOC_ZERO() failed.\n")); - talloc_destroy(mem_ctx); - return NULL; - } + if (fake_files[i].name == NULL) { + return NULL; + } - fh->type = type; - fh->mem_ctx = mem_ctx; + DEBUG(5,("init_fake_file_handle: for [%s]\n",fake_files[i].name)); - if (fake_files[i].init_pd) { - fh->pd = fake_files[i].init_pd(fh->mem_ctx); - } + fh = talloc(NULL, struct fake_file_handle); + if (fh == NULL) { + DEBUG(0,("TALLOC_ZERO() failed.\n")); + return NULL; + } - fh->free_pd = fake_files[i].free_pd; + fh->type = type; - return fh; - } + if (fake_files[i].init_pd) { + fh->private_data = fake_files[i].init_pd(fh); } - - return NULL; + return fh; } /**************************************************************************** @@ -147,18 +147,12 @@ NTSTATUS open_fake_file(connection_struct *conn, return NT_STATUS_OK; } -void destroy_fake_file_handle(FAKE_FILE_HANDLE **fh) +void destroy_fake_file_handle(struct fake_file_handle **fh) { - if (!fh||!(*fh)) { + if (!fh) { return; } - - if ((*fh)->free_pd) { - (*fh)->free_pd(&(*fh)->pd); - } - - talloc_destroy((*fh)->mem_ctx); - (*fh) = NULL; + TALLOC_FREE(*fh); } NTSTATUS close_fake_file(files_struct *fsp) -- cgit From d49de28f1154140f63670cfbf5093cdee6f16eb0 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 15 Jun 2008 13:37:53 +0200 Subject: Remove the current_user reference from fake_file.c The current vuid is not only available there, it is also in the current smb_request structure. (This used to be commit c8fd5eef32a86888c7a28317f0fdf717a26b7d4c) --- source3/smbd/fake_file.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'source3/smbd/fake_file.c') diff --git a/source3/smbd/fake_file.c b/source3/smbd/fake_file.c index 565b557dd3..47982d4f00 100644 --- a/source3/smbd/fake_file.c +++ b/source3/smbd/fake_file.c @@ -19,8 +19,6 @@ #include "includes.h" -extern struct current_user current_user; - struct fake_file_type { const char *name; enum FAKE_FILE_TYPE type; @@ -101,6 +99,7 @@ enum FAKE_FILE_TYPE is_fake_file(const char *fname) ****************************************************************************/ NTSTATUS open_fake_file(connection_struct *conn, + uint16_t current_vuid, enum FAKE_FILE_TYPE fake_file_type, const char *fname, uint32 access_mask, @@ -110,7 +109,7 @@ NTSTATUS open_fake_file(connection_struct *conn, NTSTATUS status; /* access check */ - if (current_user.ut.uid != 0) { + if (conn->server_info->uid != 0) { DEBUG(3, ("open_fake_file_shared: access_denied to " "service[%s] file[%s] user[%s]\n", lp_servicename(SNUM(conn)), fname, @@ -129,7 +128,7 @@ NTSTATUS open_fake_file(connection_struct *conn, fsp->conn = conn; fsp->fh->fd = -1; - fsp->vuid = current_user.vuid; + fsp->vuid = current_vuid; fsp->fh->pos = -1; fsp->can_lock = False; /* Should this be true ? - No, JRA */ fsp->access_mask = access_mask; -- cgit From 40f5eab5eb515937e1b23cf6762b77c194d29b9d Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 19 Jun 2008 16:54:12 +0200 Subject: Wrap the unix token info in a unix_user_token in auth_serversupplied_info No functional change, this is a preparation for more current_user ref removal (This used to be commit dcaedf345e62ab74ea87f0a3fa1e3199c75c5445) --- source3/smbd/fake_file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/fake_file.c') diff --git a/source3/smbd/fake_file.c b/source3/smbd/fake_file.c index 47982d4f00..8dd9abee1a 100644 --- a/source3/smbd/fake_file.c +++ b/source3/smbd/fake_file.c @@ -109,7 +109,7 @@ NTSTATUS open_fake_file(connection_struct *conn, NTSTATUS status; /* access check */ - if (conn->server_info->uid != 0) { + if (conn->server_info->utok.uid != 0) { DEBUG(3, ("open_fake_file_shared: access_denied to " "service[%s] file[%s] user[%s]\n", lp_servicename(SNUM(conn)), fname, -- cgit