summaryrefslogtreecommitdiff
path: root/source3/smbd/open.c
AgeCommit message (Collapse)AuthorFilesLines
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)
2000-02-17Don't assume that the (files_struct *) passed to fd_attempt_close()Tim Potter1-2/+9
will be non-NULL. (This used to be commit 02f845e54351ec57ee873a8ed887285552c6ecab)
2000-02-03Put back lots of missing calls to dos_to_unix(). Thanks toTim Potter1-6/+7
aono@cc.osaka-kyoiku.ac.jp (Tomoki AONO) (This used to be commit 176c405d2702a4245561ff56c8eac3c754a0dea3)
2000-02-03Mega-VFS merge. Yeah baby!Tim Potter1-34/+37
Synopsis: change every disk access function to work through a vfs_ops structure contained in the connection_struct. (This used to be commit 3aad500c0fb61232ed3431ff4b743b5d18ec852f)
2000-01-16fixed some typos in access_table() which, amaziingly enough, make noAndrew Tridgell1-3/+3
difference to the result. (This used to be commit 9e28b7220bc293e386fec30c2d2e7e401b61b1f7)
2000-01-16made access_table() a pure logic function - makes it simpler to applyAndrew Tridgell1-16/+26
maths to (This used to be commit 0ad62f128d1c26b8f7e71bc045c6f4a584f8d374)
2000-01-16as obelix would say "these romans are crazy"Andrew Tridgell1-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 (This used to be commit 31a5857ce4f03eb53ff8ea96c5f1ce335941336d)
2000-01-16rewrote the access_table() code to get it right for *.exe, *.dll,Andrew Tridgell1-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. (This used to be commit 5b9be3feca26f1f20fe3f32ba90769cc78f9bb6b)
2000-01-14Added "inherit permissions" patch.Jeremy Allison1-1/+1
Fixed locking bug found by Andrew. Jeremy. (This used to be commit 38dffd360dc2e44bfc9e751f017e24f81ff0f2fa)
2000-01-13changes to reflect the new syntax of the locking calls.Andrew Tridgell1-2/+2
(This used to be commit 44117df2c908d473b3e1a1020b22af6d584809ef)
2000-01-08fix a error in access_table revealed by the new deny test in smbtorture. We ↵Andrew Tridgell1-3/+5
now exactly match NT for normal files. We still don't match for *.exe files though (This used to be commit 3f7fea58e8da6d98acadaabf0498ea2e88ea5678)
2000-01-08Fixed deny mode bug :Jeremy Allison1-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. (This used to be commit 974af581fe428fd0233c2516b16a5132b0e1b583)
1999-12-21converted all our existing shared memory code to use a tdb databaseAndrew Tridgell1-17/+16
instead of either sysv or mmap shared memory or lock files. this means we can now completely remove locking_shm.c locking_slow.c shmem.c shmem_sysv.c and lots of other things also got simpler locking.c got a bit larger, but is much better compartmentalised now (This used to be commit e48c2d9937eea0667b8cd3332e49c06314ef31e7)
1999-12-13first pass at updating head branch to be to be the same as the SAMBA_2_0 branchAndrew Tridgell1-130/+256
(This used to be commit 453a822a76780063dff23526c35408866d0c0154)
1999-04-05Fix incorrect conversion of fd_attempt_open() calls to vfs_ops.open().Tim Potter1-9/+12
Use VFS I/O for fd_attempt_open() and check_access_allowed_for_current_user(). (This used to be commit abf31ca66f3dab1b8bd7772f83e736e41afb4b1e)
1999-04-04Use VFS operations for file I/O.Tim Potter1-22/+32
Changed arg to fd_attempt_close() from fd to fsp_struct. (This used to be commit c40124bc9a2ebccf0bb56b1fafa81a551d934aa5)
1998-12-07fixed warnings (and potential errors) due to integer overflow whenAndrew Tridgell1-1/+2
creating locking masks (This used to be commit 5e2844d5edb15de29b976d2ff077ffbe012b860c)
1998-11-25Makefile.in: Added maintainer mode fixes.Jeremy Allison1-2/+2
aclocal.m4: Added AC_LIBTESTFUNC. configure.in: Fixed -lsecurity -lsec problems. client.c: dos_ fixes. groupdb/aliasunix.c: Dead code removal. include/includes.h: Added default PRINTCAP_NAME. lib/genrand.c: dos_ fixes. lib/replace.c: Added strtoul. lib/system.c: dos_ fixes. lib/util.c: dos_ fixes. lib/util_sid.c: Signed/unsigned fixes. lib/util_str.c: removed bad const. locking/locking_slow.c: dos_ fixes. printing/printing.c: dos_ fixes. rpc_server/srv_samr.c: Dead code removal. rpc_server/srv_sid.c: global_myworkgroup defined with wrong size AGAIN ! smbd/dir.c: dos_ fixes. smbd/open.c: dos_ fixes. smbd/oplock.c: dos_ fixes. smbd/reply.c smbd/server.c smbd/service.c smbd/uid.c: dos_ fixes. Jeremy. (This used to be commit 6acb4b68f68d516e2ac3c47e500f5600d653435e)