summaryrefslogtreecommitdiffstats
path: root/source/smbd/open.c
Commit message (Collapse)AuthorAgeFilesLines
* sync with SAMBA_2_2 for 2.2.6rc1Gerald Carter2002-10-091-9/+57
|
* beginning to sync up for 2.2.5 release....Gerald Carter2002-06-171-2/+2
|
* Start of merge to 2_2_RELEASE branch for release.Jeremy Allison2002-04-301-247/+260
| | | | Jeremy.
* Move over to RELEASE branch.Jeremy Allison2002-02-011-44/+65
| | | | Jeremy.
* Sync-up with SAMBA_2_2 branch.Jeremy Allison2001-10-111-78/+122
| | | | Jeremy.
* Syncup getting ready for release.Jeremy Allison2001-07-061-6/+14
| | | | Jeremy.
* Finally got the semantics right (hurrah).Jeremy Allison2001-04-161-3/+0
| | | | Jeremy.
* Still working on the open with truncate problem...Jeremy Allison2001-04-161-3/+14
| | | | Jeremy.
* Correct fix for open readonly with truncate bug.Jeremy Allison2001-04-151-17/+18
| | | | Jeremy.
* This little piece of insanity is inspired by theJeremy Allison2001-04-141-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.
* configure:Jeremy Allison2001-04-131-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. Jeremy.
* Fixed potential file descriptor leak with MS-Access fix.Jeremy Allison2001-04-131-1/+9
| | | | Jeremy.
* This is a big, rather ugly patch. Whilst investigating the files not truncatedJeremy Allison2001-03-301-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.
* smbd/posix_acls.c: Saving and restoring errno here is the wrong place. Moved itJeremy Allison2001-03-261-3/+6
| | | | | to the places where [f]chmod_acl is called instead. Jeremy.
* But Doctor, I had to kill the patient in order to save him....Jeremy Allison2001-02-211-4/+0
| | | | | | | | | | | | | | | | | | | This will probably break 2.2 for a while. Do *NOT* checkout unless you like core dumps. This is the first merge of the TNG SAMR code into 2.2. It will eventually give us a wonderful PDC, but maybe painful in the short term. It had to be done however, and this touches almost every file (mostly just removing the OLD_NT_DOMAIN) stuff. I removed some SAMR functionality from rpcclient that would no longer compile. Also changed fstring to 256 bytes to better match an NT pathname. Jeremy.
* Fixed problems with chmod interacting with ACL code.Jeremy Allison2001-01-231-2/+2
| | | | Jeremy
* Fixup for chmod_acl, fchmod_acl for inherited ACLs.Jeremy Allison2001-01-231-0/+7
| | | | | Needs testing..... Jeremy.
* include/vfs.h:Jeremy Allison2001-01-231-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.
* Fixed very subtle bug returning correct error on an open, when we haveJeremy Allison2000-12-111-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.
* Fixes for extra stat's broght back from HEAD. This cuts down on theJeremy Allison2000-10-251-52/+67
| | | | | | | number of stats per smb call as we now trust the statcache. There are more optimizations to come.... Also generic merges to keep 2.2.0 and HEAD in sync. Jeremy.
* Restructuring of vfs layer to include a "this" pointer - can be an fsp orJeremy Allison2000-10-061-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). 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.
* utf-8 and EUC3 patch from Hiroshi Miura Samba User Group Japan staff.Jeremy Allison2000-10-031-2/+1
| | | | | mkdir high bits patch from Robert Dahlem" <Robert.Dahlem@gmx.net>. jeremy.
* open files with O_NONBLOCK when available. This is necessary toAndrew Tridgell2000-06-151-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
* added support for kernel level share modes. These are a (small) hack,Andrew Tridgell2000-06-151-1/+24
| | | | | I suspect we will either get rid of them or do them properly at some stage.
* Check fstat return for error.Jeremy Allison2000-05-121-1/+5
| | | | Jeremy.
* more merging voodooAndrew Tridgell2000-05-101-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
* Added sys_fork() and sys_getpid() functions to stop the overheadJeremy Allison2000-05-021-2/+2
| | | | | of doing a system call every time we want to just get our pid. Jeremy.
* Made changes suggested by Andrew review.Jeremy Allison2000-04-281-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.
* Ok - this is more subtle than it looks :-).Jeremy Allison2000-04-271-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.
* Fixed subtle unlocking bug when a file is closed. We need to store theJeremy Allison2000-04-271-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.
* Did the rewrite Andrew wanted where all knowledge of POSIX locking isJeremy Allison2000-04-271-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.
* Fixed crash bugs Andrew pointed out with LOCK4 smbtortureJeremy Allison2000-04-271-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.
* Added the code that keeps fd's open across a close if there are other fsp'sJeremy Allison2000-04-241-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.
* Now that fsp's are created on successful file open, the structure memberJeremy Allison2000-04-241-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 is a *big* checkin that may break some things, but implements theJeremy Allison2000-04-221-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.
* the changes to the main smb codeAndrew Tridgell2000-04-161-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.
* Code to map tdb locks onto POSIX. Mainly placeholder code at the moment,Jeremy Allison2000-04-121-0/+3
| | | | | | but the structure is done enough so that Andrew can look it over and give a yea/nay decision. Jeremy.
* The latest open() code changes broke the NT directory opens. Detect if aJeremy Allison2000-04-111-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.
* the bulk of the changes to get rid of fd_ptr and move print openAndrew Tridgell2000-04-101-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
* Don't assume that the (files_struct *) passed to fd_attempt_close()Tim Potter2000-02-171-2/+9
| | | | will be non-NULL.
* Put back lots of missing calls to dos_to_unix(). Thanks toTim Potter2000-02-031-6/+7
| | | | aono@cc.osaka-kyoiku.ac.jp (Tomoki AONO)
* Mega-VFS merge. Yeah baby!Tim Potter2000-02-031-34/+37
| | | | | Synopsis: change every disk access function to work through a vfs_ops structure contained in the connection_struct.
* fixed some typos in access_table() which, amaziingly enough, make noAndrew Tridgell2000-01-161-3/+3
| | | | difference to the result.
* made access_table() a pure logic function - makes it simpler to applyAndrew Tridgell2000-01-161-16/+26
| | | | maths to
* as obelix would say "these romans are crazy"Andrew Tridgell2000-01-161-40/+59
| | | | | | | | | I've finally got the access table code right for the case where the two opens are on the same connection. It is _incredibly_ complex, but now all 1296 test cases pass. I'll be very surprised if anyone by MS and us gets this right at CIFS2000
* rewrote the access_table() code to get it right for *.exe, *.dll,Andrew Tridgell2000-01-161-27/+41
| | | | | | | | | *.sym and *.com files. I still find it incredible that SMB treats file locking differently depending on the file name - that is so ugly it stinks. anyway, we now behave the same way as NT, except for the same-connection case which I'm still working on.
* Added "inherit permissions" patch.Jeremy Allison2000-01-141-1/+1
| | | | | Fixed locking bug found by Andrew. Jeremy.
* changes to reflect the new syntax of the locking calls.Andrew Tridgell2000-01-131-2/+2
|
* fix a error in access_table revealed by the new deny test in smbtorture. We ↵Andrew Tridgell2000-01-081-3/+5
| | | | now exactly match NT for normal files. We still don't match for *.exe files though
* Fixed deny mode bug :Jeremy Allison2000-01-081-9/+9
| | | | | | | : If a file is resident on NT and the first user opens it read/write with DENY_READ then a subsequent : attempt by a second user (running under Windows 95) to open it read/write DENY_NONE fails. : Under samba 2.0.5a the second open succeeds but the file is write only. Jeremy.