summaryrefslogtreecommitdiff
path: root/source3/smbd/open.c
AgeCommit message (Collapse)AuthorFilesLines
2001-10-20Move from timestamp to gen count file id's for finding oplocked filesJeremy Allison1-7/+2
in a tdb. Jeremy. (This used to be commit 058ae6b58f61ef46013dd076af3a84de5fbaaab1)
2001-10-02Removed 'extern int DEBUGLEVEL' as it is now in the smb.h header.Tim Potter1-2/+0
(This used to be commit 2d0922b0eabfdc0aaf1d0797482fef47ed7fde8e)
2001-09-24Change log message to 2 from zero when failing to create directory.Jeremy Allison1-1/+1
Stops spurious profile creation messages. Jeremy. (This used to be commit fa74d07207fa9024b6ebdb10686b032ef6673d18)
2001-09-17move to SAFE_FREE()Simo Sorce1-9/+8
(This used to be commit a95943fde0ad89ae3f2deca2f7ba9cb5ab612b74)
2001-09-15use variables _before_ freeing them!Simo Sorce1-3/+2
thanks to Andreas Moroder for spotting these two. (This used to be commit 01f30ca0ad472eaab8f80ec4278b1d391be3a1ae)
2001-09-05fixed formatting to make the code vaguely readable. It's still a dogsAndrew Tridgell1-142/+143
breakfast, but at least you can follow the indents (This used to be commit 9955ea0aaa299c6c946b4e7b7e98017c39b60bc8)
2001-08-27converted smbd to use NTSTATUS by defaultAndrew Tridgell1-4/+1
major changes include: - added NSTATUS type - added automatic mapping between dos and nt error codes - changed all ERROR() calls to ERROR_DOS() and many to ERROR_NT() these calls auto-translate to the client error code system - got rid of the cached error code and the writebmpx code We eventually will need to also: - get rid of BOOL, so we don't lose error info - replace all ERROR_DOS() calls with ERROR_NT() calls but that is too much for one night (This used to be commit 83d9896c1ea8be796192b51a4678c2a3b87f7518)
2001-08-22Missed '\' at eol...Jeremy Allison1-1/+1
Jeremy. (This used to be commit 0dbd1be704209c1a66280148b40f7b7437d47242)
2001-08-22Tidyup fixes for fcntl spin problem.Jeremy Allison1-3/+13
Jeremy. (This used to be commit 27d3dd0e7cb777ef6b21d6966c07045c2940fd37)
2001-08-22Fixed the (incorrect) paranioa fix I put in for the fcntl lock spin.Jeremy Allison1-9/+35
Don't delete a share mode that failed to remove the oplock (doh!), just set the oplock entry to zero.... Jeremy. (This used to be commit fe4aa720181a43f7a636ca029680fab0c836b968)
2001-08-21This is Jeremy pretending to be Volker, 'cos theVolker Lendecke1-0/+10
link from Seattle is having problems. I've added 3 things here to work on the fcntl spin problem. 1). Check *all* tdb return codes... :-). 2). If we're asking ourselves to break an oplock, and we can't find a fsp pointer that matches the entry, this is a *logic bug* and we should abort and panic so someone with gdb can pick up the pieces. 3). After we've broken an oplock, ensure that the entry itself has been removed, and if not remove it ourselves. This should not be neccessary in a correctly working environmen,t, but will provide an added layer of robustness in error situations. 4). I hate german keyboards :-) :-). Jeremy. (This used to be commit 1c94fa80646f9e31377fbb41332fe4780f550cab)
2001-07-24We were making an assumption in the oplockJeremy Allison1-1/+0
break code path that was invalid (ie. we were assuming we could infer a non-levelII oplock when such an oplock was detected - this may no longer be valid once we've processed the break process dealing with the break will change the state of it anyway. This prevents the state where we get the following packet trace : client server NTcreate -> <- NTcreate resp NTcreate -> <- break to level II ok - broken -> <- break to none Thanks to Alan Romeril for providing the trace that allowed me to track this down. Jeremy. (This used to be commit c343e4f49070011986fc2ed4acd4ce690d5f1d71)
2001-07-05Fix race where wrong action (created or opened) could be returned.Jeremy Allison1-0/+8
Jeremy. (This used to be commit af5b649b017f703a14a69f77a9067efb9c6a8269)
2001-07-04strchr and strrchr are macros when compiling with optimisation in gcc, so we ↵Andrew Tridgell1-2/+2
can't redefine them. damn. (This used to be commit c41fc06376d1a2b83690612304e85010b5e5f3cf)
2001-07-04The big character set handling changeover!Andrew Tridgell1-24/+2
This commit gets rid of all our old codepage handling and replaces it with iconv. All internal strings in Samba are now in "unix" charset, which may be multi-byte. See internals.doc and my posting to samba-technical for a more complete explanation. (This used to be commit debb471267960e56005a741817ebd227ecfc512a)
2001-06-30Fixed the first locking error (test #8 found by locktest code fromJeremy Allison1-1/+1
Clarion locktest. Jeremy. (This used to be commit 5c42845b5bb6fafd0ebf93fbdd23d9bf861da865)
2001-06-19Extra debug in open.c, fix for bad debug message in reply.cJeremy Allison1-2/+2
Jeremy. (This used to be commit 2c2fc8513699eb39721ac1d65fa1fdaecde526a8)
2001-04-18Removed mktemp from HEAD - same as done in 2.2.Jeremy Allison1-1/+1
Jeremy. (This used to be commit 121b59669fbcd1aaedb08011ff36169fc6561c55)
2001-04-16Finally got the semantics right (hurrah!).Jeremy Allison1-6/+14
Jeremy. (This used to be commit 362574c5a32005d4247c7ac75a5aa9e35e894db0)
2001-04-16Correct fix for open readonly with truncate.Jeremy Allison1-17/+18
Jeremy. (This used to be commit 6706e258e17c3d69d617b95feb3407124f50852d)
2001-04-14This little piece of insanity is inspired by theJeremy Allison1-3/+18
fact that an NT client can open a file for O_RDONLY, but set the create disposition to FILE_EXISTS_TRUNCATE. If the client *can* write to the file, then it expects to truncate the file, even though it is opening for readonly. Quicken uses this stupid trick in backup file creation... Thanks *greatly* to "David W. Chapman Jr." <dwcjr@inethouston.net> for helping track this one down. It didn't bite us in 2.0.x as we always opened files read-write in that release. Jeremy. (This used to be commit 5baef56831f9bc4fa10a851abd5f9305b974fb3b)
2001-04-14configure:Jeremy Allison1-7/+47
configure.in: include/config.h.in: include/profile.h: smbd/vfs-wrap.c: smbd/vfs.c: Added fchmod and fchown to VFS (sorry Gerald - but we needed them anyway). smbd/dosmode.c: smbd/files.c: printing/printfsp.c: smbd/close.c: smbd/open.c: Fixed "dos filemode" correctly so there are no race conditions. Forces test of open of file O_WRONLY before allowing fchmod as root. Afterwards, calls standard close function that preserves POSIX locks due to POSIX-me-harder braindamage. :-). Andrew please review this code. Also - in removing the tmpdir param in smbrun an extra NULL parameter was missed in each print_run_command() call (which is a varargs fn.). Now fixed. Jeremy. (This used to be commit 32397e5bc6d995ce7ca37c82d6aedc1e5b1b6fbd)
2001-04-13Fixed potential file descriptor leak with MS-Access fix.Jeremy Allison1-1/+9
Jeremy. (This used to be commit 192887fe72157a141b8df1977085f479e5204782)
2001-03-30This is a big, rather ugly patch. Whilst investigating the files not truncatedJeremy Allison1-6/+39
when copying to a full disk problem, I discovered that we were not allowing the delete on close flag to be set properly, this led to other things, and after investigation of the proper delete on close semantics and their relationship to the file_share_delete flag I discovered there were some cases where we weren't doing the deny modes properly. And this after only 5 years working on them..... :-) :-). So here's the latest attempt. I realised the delete on close flag needs to be set across all smbds with a dev/ino pair open - in addition, the delete on close flag, allow share delete and delete access requested all need to be stored in the share mode tdb. The "delete_on_close" entry in the fsp struct is now redundant and should really be removed. This may also mean we can get rid of the "iterate_fsp" calls that I didn't like adding in the first place. Whilst doing this patch, I also discovered we needed to do the se_map_generic() call for file opens and POSIX ACL mapping, so I added that also. This code, although ugly, now passes the deny mode torture tests plus the delete on close tests I added. I do need to add one more multiple connection delete on close test to make sure I got the semantics exactly right, plus we should also (as Andrew suggested) move to random testing here. The good news is that NT should now correctly delete the file on disk full error when copying to a disk :-). Jeremy. (This used to be commit 51987684bd231c744da2e5f3705fd236d5616173)
2001-03-26smbd/posix_acls.c: Saving and restoring errno here is the wrong place. Moved itJeremy Allison1-3/+6
to the places where [f]chmod_acl is called instead. Jeremy. (This used to be commit 641ada44ae6429761c1fd0dbcafabc69f897fac7)
2001-03-11Merge of new 2.2 code into HEAD (Gerald I hate you :-) :-). Allows new SAMRJeremy Allison1-4/+0
RPC code to merge with new passdb code. Currently rpcclient doesn't compile. I'm working on it... Jeremy. (This used to be commit 0be41d5158ea4e645e93e8cd30617c038416e549)
2001-01-24Sync up with POSIX ACL code from 2.2.Jeremy Allison1-0/+7
Jeremy. (This used to be commit e0431672cc54ed09d6c5cf083054db12ccd9dcf6)
2001-01-23include/vfs.h:Jeremy Allison1-2/+2
smbd/vfs-wrap.c: smbd/vfs.c: Added fchmod_acl and chmod_acl. lib/substitute.c: smbd/lanman.c: smbd/open.c: smbd/process.c: smbd/reply.c: smbd/service.c: Removed sessetup_user variable. Added current_user_info struct which conatins domain info etc. Added '%D' for client domain parameter. Jeremy. (This used to be commit 2844ec3d511680609d6794b8718001a1bda9e89f)
2000-12-11Fixed very subtle bug returning correct error on an open, when we haveJeremy Allison1-8/+22
a choice of invalid share mode and access denied. We must return the access denied by preference, but also remember to break the oplocks... This is needed for multi-user MS-Access. Jeremy. (This used to be commit 7eb7241442ea0f1e065b009c3cccd5821b89a8b6)
2000-10-20Fix for vfs_fstat() crash with new stat code.Jeremy Allison1-0/+3
Jeremy. (This used to be commit 979aa01e011d433328af0ead7644f47d0cfadf13)
2000-10-19Ok - this is a big patch - and it may break smbd a bit (althoughJeremy Allison1-52/+64
I hope not). If you encounter strange file-serving behavior after this patch then back it out. I analysed our stat() usage and realised we were doing approx. 3 stat calls per open, and 2 per getattr/setattr. This patch should fix all that. It causes the stat struct returned from unix_convert() (which now *must* be passed a valid SMB_STRUCT_STAT pointer) to be passed through into the open code. This should prevent the multiple stats that were being done so as not to violate layer encapsulation in the API's. Herb - if you could run a NetBench test with this code and do a padc/par syscall test and also run with the current 2.2.0 code and test the padc/par syscalls I'd appreciate it - you should find the number of stat calls reduced - not sure by how much. The patch depends on unix_convert() actually finding the file and returning a stat struct, or returning a zero'd out stat struct if the file didn't exist. I believe we can guarentee this to be the case - I just wasn't confident enough to make this an assertion before. Ok ok - I did write this whilst at the Miami conference..... sometimes you get a little free time at these things :-). Jeremy. (This used to be commit 66a5c05ec46b641224fbe01b30bd7e83571a2a1b)
2000-10-06Restructuring of vfs layer to include a "this" pointer - can be an fsp orJeremy Allison1-7/+7
a conn struct depending on the call. We need this to have a clean NT ACL call interface. This will break any existing VFS libraries (that's why this is pre-release code). Andrew gets credit for this one :-) :-). In addition - added Herb's WITH_PROFILE changes - Herb - please examine the changes I've made to the smbd/reply.c code you added. The original code was very ugly and I have replaced it with a START_PROFILE(x)/END_PROFILE(x) pair using the preprocessor. Please check this compiles ok with the --with-profile switch. Jeremy. (This used to be commit b07611f8159b0b3f42e7e02611be9f4d56de96f5)
2000-10-03utf-8 and EUC3 patch from Hiroshi Miura Samba User Group Japan staff.Jeremy Allison1-2/+1
mkdir high bits patch from Robert Dahlem" <Robert.Dahlem@gmx.net>. jeremy. (This used to be commit b40191d27180ab1e59935086073c4d312552f717)
2000-06-15open files with O_NONBLOCK when available. This is necessary toAndrew Tridgell1-1/+6
prevent possible deadlocks with kernel leases and harmless when kernel leases are not used. basically we don't ever want smbd to block (This used to be commit 9fd67b94a7e43c9dcbe098940b88879ae8743c00)
2000-06-15added support for kernel level share modes. These are a (small) hack,Andrew Tridgell1-1/+24
I suspect we will either get rid of them or do them properly at some stage. (This used to be commit fabe1f350e1fc58db33d22cebd38652950697ced)
2000-05-12Check fstat return for error.Jeremy Allison1-1/+5
Jeremy. (This used to be commit c54e77b1f9defce3d6c2e530e0fb460c2b0c54c2)
2000-05-10more merging voodooAndrew Tridgell1-0/+4
this adds "#define OLD_NTDOMAIN 1" in lots of places. Don't panic - this isn't permanent, it should go after another few merge steps have been done (This used to be commit 92109d7b3c06f240452d39f669ecb8c9c86ab610)
2000-05-02Added sys_fork() and sys_getpid() functions to stop the overheadJeremy Allison1-2/+2
of doing a system call every time we want to just get our pid. Jeremy. (This used to be commit 148628b616b5c29ba6340d65fc3ddbcabba6e67a)
2000-04-28Made changes suggested by Andrew review.Jeremy Allison1-15/+1
fd_close now calls fd_close_posix() directly. set_posix_lock/release_posix_lock() now handle the reference counting. More changes due when this gets moved to the file locking/posix.c Jeremy. (This used to be commit 239abd48f049c6a8d2bbc0636eacf347ab77588c)
2000-04-27Ok - this is more subtle than it looks :-).Jeremy Allison1-4/+0
When a file is being closed, once it passes the fnum and tid tests then the locking context should be ignored when removing all locks. This is what is done in the brl close case, but when you have outstanding POSIX locks, then you cannot remove all the brl locks in one go, you have to get the lock list and call do_unlock individually. As this uses global_smbpid as the locking context, you need to make sure that this is set correctly for the specific lock being removed. I now do this by storing the smbpid in each entry in the unlock list returned from the query call. I removed the smbpid from fsp (not needed) and things seem ok (even with the stupid smbpid tricks that smbtorture plays :-). Jeremy. (This used to be commit 6baa96bb466915cc17e8cbad50254d6bd47b967b)
2000-04-27Fixed subtle unlocking bug when a file is closed. We need to store theJeremy Allison1-0/+4
smbpid used when a file was opened in the files_struct. Else we use the wrong global_smbpid when we are closing the file and trying to remove the brl locks - this causes the brl locks to be left when the file is closed as the samba_context check fails. Jeremy. (This used to be commit 2746e5602e493e5b022764b4b839eb4d2f14363b)
2000-04-27Did the rewrite Andrew wanted where all knowledge of POSIX locking isJeremy Allison1-114/+1
removed from the smbd/open.c code. We now use a dlink list of structures indexed by dev/inode to store all pending fd's for close. This could be rewritten to use lib/hash.c if this is discovered to be too slow in use. Andrew, please take a look and let me know if this is what you had in mind. Jeremy. (This used to be commit 0487841120a7584da9a2b83b9574562c415d7024)
2000-04-27Fixed crash bugs Andrew pointed out with LOCK4 smbtortureJeremy Allison1-4/+8
test. Was miscounting posix locks, plus was not taking into account the case where other_fsp == fsp in the 'move locks' case. DOH ! This code will be re-written anyway :-). Jeremy. (This used to be commit 5278ec016cb24d8263fe6e7c1d389f466270ef24)
2000-04-24Added the code that keeps fd's open across a close if there are other fsp'sJeremy Allison1-1/+119
open on the same dev/inode pair with existing POSIX locks. This is done at the smbd/open layer, so smbd just calls fd_close() and the transfer of any open fd's is done under the covers of fd_close(). When an fsp is closed and no other fsp's open on the same dev/inode pair have existing POSIX locks then all fd's associated with this fsp are closed. Now only the hard part of doing the POSIX range unlock code when read locks overlap remains for full POSIX/SMB lock integration.... Jeremy. (This used to be commit 1df48ed55ee303b6d84d7277fd79761cfe5f7052)
2000-04-24Now that fsp's are created on successful file open, the structure memberJeremy Allison1-10/+6
fsp->open is no longer needed (if an fsp pointer is valid, then it's open :-). NB for Luke, this patch also did not apply to TNG. TNG is not yet identical w.r.t file serving with HEAD. This makes it impossible for me to help maintain TNG. Please fix asap. lib/substitute.c: Removed unused variable (pidstr). Jeremy. (This used to be commit 389b700a26e8a308a0dff6fc038c38068aa0119a)
2000-04-22This is a *big* checkin that may break some things, but implements theJeremy Allison1-340/+411
new open mechanism Andrew & I discussed. config.sub: configure: Included the QNX patch. include/vfs.h: smbd/vfs-wrap.c: smbd/vfs.c: Added ftruncate vfs call (needed). Note that we will also need locking calls in the vfs (to be added). lib/util_unistr.c: nmbd/nmbd_processlogon.c: Fix for NT domain logons causing nmbd to core dump. Also fix for sidsize DOS bug. locking/locking.c: Check value of ret before using it for memdup. printing/printing.c: Convert print_fsp_open to return an allocated fsp. rpc_server/srv_lsa.c: Fix for NT domain logons. I have removed all use of lp_share_modes() from the code (although I left the parameter in the table for backwards compatibility). It no longer makes sense for this to exist. smbd/close.c: Removed lp_share_modes(). smbd/fileio.c: Fixed parameters to unlock_share_entry call in panic code. smbd/files.c: Correctly set the unix_ERR_code to ERRnofids on fsp allocation fail. smbd/nttrans.c: smbd/reply.c: smbd/trans2.c: Changed all occurrences of open_file_shared/open_directory/ open_file_stat to return an fsp from the call. smbd/open.c: Changed all occurrences of open_file_shared/open_directory/ open_file_stat to return an fsp from the call. In addition I have fixed a long standing race condition in the deny mode processing w.r.t. two smbd's creating a file. Andrew, please note that your original idea of using open with O_EXCL in this case would not work (I went over the races very carefully) and so we must re-check deny modes *after* the open() call returns. This is because there is a race between the open with O_EXCL and the lock of the share mode entry. Imagine the case where the first smbd does the open with O_EXCL and a deny mode of DENY_ALL, but is pre-empted before it locks the share modes and creates the deny mode entry for DENY_ALL. A second smbd could then come in with O_RDONLY and a deny mode of DENY_NONE and the two opens would be allowed. The *only* way to fix this race is to lock the share modes after the open and then do the deny mode checks *after* this lock in the case where the file did not originally exist. This code will need extensive testing but seems to initially work. Jeremy. (This used to be commit ab0ecc39d688f16b9692fe90b991f0b89287070a)
2000-04-16the changes to the main smb codeAndrew Tridgell1-1/+1
------------ The following series of commits are for the new tdb based printing backend. This completely replaces our old printing backend. Major changes include: - all print ops are now done in printing/*.c rather than scattered all over the place - system job ids are decoupled from SMB job ids - the lpq parsers don't need to be nearly so smart, they only need to parse the filename, the status and system job id - we can store lots more info about a job, including the full job name - the queue cache control is much better I also added a new utility routine file_lines_load() that loads a text file and parses it into lines. This is used in out lpq parsing and I also want to use it to replace all of our fgets() based code in other places. (This used to be commit d870542c2884510bd45fd5b54ff2157434d53f4c)
2000-04-12Code to map tdb locks onto POSIX. Mainly placeholder code at the moment,Jeremy Allison1-0/+3
but the structure is done enough so that Andrew can look it over and give a yea/nay decision. Jeremy. (This used to be commit db96f83e34a139f47776fcbb5c1624fbf9d9943b)
2000-04-11The latest open() code changes broke the NT directory opens. Detect if aJeremy Allison1-8/+26
read-only open on a directory was done and return an EISDIR from open_file(). Changed interface to fd_close to return error. Jeremy. (This used to be commit df4302f3911447fcebe9342f6cbf3b89bd3bafba)
2000-04-10the bulk of the changes to get rid of fd_ptr and move print openAndrew Tridgell1-534/+116
handling to printing/printing.c most of this was just replacing things like fsp->fd_ptr->fd with fsp->fd the changes in open.c are quite dramatic. Most of it is removing all the functions that handled the fd multiplexing (This used to be commit d1827a3648009fd0a0d165055015d9aeda7a1037)