summaryrefslogtreecommitdiff
path: root/source3/smbd/filename.c
AgeCommit message (Collapse)AuthorFilesLines
2009-11-25Make us pass RAW-CHKPATH with a case sensitive share.Jeremy Allison1-42/+105
I know Volker will look at this closely so here's the explaination :-). Originally on a case-sensitive share we simply did a stat (or lstat) call and returned success of fail based on the result. However this failed to take account of incoming paths with a wildcard (which must always fail, and with different error messages depending on whether the wildcard is the last component or in the path). Also it failed to take account of a stat fail with ENOENT due to a missing component of the path as the last component (which is ok as it could be a new file) or if the ENOENT was due to the missing component within the path (not the last component) - which must return the correct error. What this means is that with "case sensitive = yes" we do one more talloc call (to get the parent directory) and one more stat call (on the parent directory) in the case where the stat call fails. I think this is an acceptable overhead to enable case sensitive shares to return the correct error messages for applications. Volker please examine carefully :-). Jeremy.
2009-11-24Remove call into reduce_name if case sensitive. This allows us to passJeremy Allison1-2/+1
RAW-CHKPATH when case sensitive = yes, but isn't the correct way to do it. I'm testing a larger patch to smbd/filename.c that should fix this correctly, and will add a torture test to ensure RAW-CHKPATH is run against a case sensitive share once this is done. Jeremy.
2009-11-24Allow us to pass RAW-CHKPATH with FILE_FLAG_POSIX_SEMANTICS set or withJeremy Allison1-1/+2
wide links = no. Jeremy.
2009-11-23Proper fix for #6898 - Samba duplicates file content on appending. Pointed ↵Jeremy Allison1-1/+2
out by Volker.Restores the pathname handling for FILE_FLAG_POSIX_SEMANTICS but still prevents the O_APPEND problems. Jeremy.
2009-11-23Revert "s3: Make the implicit reference to Protocol in is_in_path() explicit"Volker Lendecke1-2/+1
This reverts commit f7b4151a64d8c6851e62255a7139fd00a5fc63a3.
2009-11-23Revert "s3: Move the global variable Protocol to struct smbd_server_connection"Volker Lendecke1-1/+1
This reverts commit c85a4c9ba4a7de65a7850f6f9708df66bd24deea.
2009-11-21s3: Move the global variable Protocol to struct smbd_server_connectionVolker Lendecke1-1/+1
2009-11-21s3: Make the implicit reference to Protocol in is_in_path() explicitVolker Lendecke1-1/+2
2009-11-18s3: Do not talloc in readdirVolker Lendecke1-6/+7
This is a hot codepath (called from the stat cache)
2009-09-24s3: Add more helpful debugging to some of the streams codeTim Prouty1-1/+1
2009-08-28s3: Add a new VFS op called SMB_VFS_TRANSLATE_NAMEAravind Srinivasan1-1/+5
This vop is designed to work in tandem with SMB_VFS_READDIR to allow vfs modules to make modifications to arbitrary filenames before they're consumed by callers. Subsequently the core directory enumeration code in smbd is now changed to free the memory that may be allocated in a module. This vop enables the new version of catia in the following patch. Signed-off-by: Tim Prouty <tprouty@samba.org>
2009-08-27s3:smbd: teach filename_convert() about fake files (2nd fix for bug #6642)Stefan Metzmacher1-0/+11
metze
2009-07-24s3: Convert a few callers of unix_convert() over to filename_convert()Tim Prouty1-10/+12
This patch also changes the unix convert flags to make sure the correct semantics are preservered for allowing/disallowing wildcards in the last component of the path.
2009-07-24s3: Allow filename_convert() to pass through unix_convert_flags and let the ↵Tim Prouty1-7/+34
caller know if the path has a wildcard This also eliminates the need for resolve_dfspath().
2009-07-22s3: Change unix_convert to use an smb_filename struct internallyTim Prouty1-137/+154
This allows SMB_VFS_[L]STAT to be called directly. Additionally, I changed NTSTATUS result to be named status for consistency. I also removed the stat_cache_add() from build_stream_path() because stat_cache_lookup() is never actually called on a file with a stream. There is no reason why the stat cache couldn't be consulted for streams in the future. Jeremy/Volker, please take a look at this one when you get a chance.
2009-07-21s3: Remove the now unused fname parameter from filename_convert()Tim Prouty1-12/+4
2009-07-20s3: Separate out a new file: filename_utils.cTim Prouty1-219/+0
This is to ease the linking pain of everything that links LOCKING_OBJ
2009-07-20s3: Move is_ntfs_stream*() to filename.cTim Prouty1-0/+24
2009-07-06s3: Add ability to pass NULL to filename_convert for the char *fnameTim Prouty1-7/+11
The goal is to eventually remove the need for the char **fname argument once all callers have standardized on smb_filename.
2009-06-24s3: Plumb smb_filename through SMB_VFS_STAT and SMB_VFS_LSTATTim Prouty1-30/+81
This patch introduces two new temporary helper functions vfs_stat_smb_fname and vfs_lstat_smb_fname. They basically allowed me to call the new smb_filename version of stat, while avoiding plumbing it through callers that are still too inconvenient. As the conversion moves along, I will be able to remove callers of this, with the goal being to remove all callers. There was also a bug in create_synthetic_smb_fname_split (also a temporary utility function) that caused it to incorrectly handle filenames with ':'s in them when in posix mode. This is now fixed.
2009-06-19Fix Coverity IDs 922 and 933Volker Lendecke1-2/+5
In copy_internals(), if the !CAN_WRITE(conn) kicks in, we end up dereferencing a NULL smb_filename. This adds a simple protection around it. Tim, please check! Volker
2009-06-18Replace the boilerplate calls to :Jeremy Allison1-0/+52
resolve_dfspath() -> unix_convert() -> get_full_smb_filename() -> check_name() with a new function filename_convert(). This restores the check_name() calls that had gone missing since the default create_file was changed. All "standard" pathname processing now goes through filename_convert(). I'll take a look at the non-standard pathname processing next. As a benefit, fixed a missing resolve_dfspath() in the trans2 mkdir call. Jeremy.
2009-06-17s3: Change SMB_VFS_OPEN to take an smb_filename structTim Prouty1-3/+2
This was a little messy because of all of the vfs modules I had to touch. Most of them were pretty straight forward, but the streams modules required a little attention to handle smb_filename. Since the use of smb_filename enables the vfs modules to access the raw, over-the-wire stream, a little bit of the handling that was being done by split_ntfs_stream_name has now been shifted into the individual stream modules. It may be a little more code, but overall it gives more flexibility to the streams modules, while also allowing correct stream handling.
2009-06-12s3: Add smb_filename utility functions and fix a bug in copy_smb_filenameTim Prouty1-5/+85
2009-06-10s3: Add utility function for copying an smb_filename structTim Prouty1-0/+39
2009-05-30Simplify the dropbox patchJeremy Allison1-5/+10
2009-05-29Re-Add the "dropbox" functionality with -wx rights on a directoryVolker Lendecke1-3/+3
2009-05-26Introduce "struct stat_ex" as a replacement for SMB_STRUCT_STATVolker Lendecke1-1/+1
This patch introduces struct stat_ex { dev_t st_ex_dev; ino_t st_ex_ino; mode_t st_ex_mode; nlink_t st_ex_nlink; uid_t st_ex_uid; gid_t st_ex_gid; dev_t st_ex_rdev; off_t st_ex_size; struct timespec st_ex_atime; struct timespec st_ex_mtime; struct timespec st_ex_ctime; struct timespec st_ex_btime; /* birthtime */ blksize_t st_ex_blksize; blkcnt_t st_ex_blocks; }; typedef struct stat_ex SMB_STRUCT_STAT; It is really large because due to the friendly libc headers playing macro tricks with fields like st_ino, so I renamed them to st_ex_xxx. Why this change? To support birthtime, we already have quite a few #ifdef's at places where it does not really belong. With a stat struct that we control, we can consolidate the nanosecond timestamps and the birthtime deep in the VFS stat calls. At this moment it is triggered by a request to support the birthtime field for GPFS. GPFS does not extend the system level struct stat, but instead has a separate call that gets us the additional information beyond posix. Without being able to do that within the VFS stat calls, that support would have to be scattered around the main smbd code. It will very likely break all the onefs modules, but I think the changes will be reasonably easy to do.
2009-05-20s3: Change unix_convert (and its callers) to use struct smb_filenameTim Prouty1-77/+98
This is the first of a series of patches that change path based operations to operate on a struct smb_filename instead of a char *. This same concept already exists in source4. My goals for this series of patches are to eventually: 1) Solve the stream vs. posix filename that contains a colon ambiguity that currently exists. 2) Make unix_convert the only function that parses the stream name. 3) Clean up the unix_convert API. 4) Change all path based vfs operation to take a struct smb_filename. 5) Make is_ntfs_stream_name() a constant operation that can simply check the state of struct smb_filename rather than re-parse the filename. 6) Eliminate the need for split_ntfs_stream_name() to exist. My strategy is to start from the inside at unix_convert() and work my way out through the vfs layer, call by call. This first patch does just that, by changing unix_convert and all of its callers to operate on struct smb_filename. Since this is such a large change, I plan on pushing the patches in phases, where each phase keeps full compatibility and passes make test. The API of unix_convert has been simplified from: NTSTATUS unix_convert(TALLOC_CTX *ctx, connection_struct *conn, const char *orig_path, bool allow_wcard_last_component, char **pp_conv_path, char **pp_saved_last_component, SMB_STRUCT_STAT *pst) to: NTSTATUS unix_convert(TALLOC_CTX *ctx, connection_struct *conn, const char *orig_path, struct smb_filename *smb_fname, uint32_t ucf_flags) Currently the smb_filename struct looks like: struct smb_filename { char *base_name; char *stream_name; char *original_lcomp; SMB_STRUCT_STAT st; }; One key point here is the decision to break up the base_name and stream_name. I have introduced a helper function called get_full_smb_filename() that takes an smb_filename struct and allocates the full_name. I changed the callers of unix_convert() to subsequently call get_full_smb_filename() for the time being, but I plan to eventually eliminate get_full_smb_filename().
2009-05-09Do not call SMB_VFS_GET_REAL_FILENAME if the name is mangledVolker Lendecke1-6/+11
The GPFS get_real_file name does not know about mangled names. Tim, if onefs does not either, you need this bugfix :-) In case onefs does 8.3 names, we need to pass the mangled flag down to SMB_VFS_GET_REAL_FILENAME to give GPFS a chance say ENOTSUPP and do the fallback.
2009-05-05s3: Fix trans2 path to use case-insensitive stat optimizationtprouty1-6/+34
Often times before creating a file, a client will first query to see if it already exists. Since some systems have a case-insensitive stat that is called from unix_convert, we can definitively return STATUS_NO_SUCH_FILE to the client without scanning the whole directory. This code path is taken from trans2querypathinfo, but trans2findfirst still does a full directory scan even though the get_real_filename (the case-insensitive stat vfs call) can prevent this. This patch adds the get_real_filename call to the trans2find* path, and also changes the vfs_default behavior for SMB_VFS_GET_REAL_FILENAME. Previously, in the absence of a get_real_filename implementation, we would fallback to the full directory scan. The default behavior now returns -1 and sets errno to EOPNOTSUPP. This allows SMB_VFS_GET_REALFILENAME to be called from trans2* and unix_convert.
2009-04-23Revert "Do not use the file system GET_REAL_FILENAME for mangled names"Volker Lendecke1-23/+7
This reverts commit b5b6ecb58aeba196c28370cde21a0826f81d8da6.
2009-04-20Do not use the file system GET_REAL_FILENAME for mangled namesVolker Lendecke1-7/+23
2009-02-09Pass stat buffer down through all levels of VFS_READDIR wrappersSteven Danneman1-1/+1
* VFS_OP_READDIR can now provide stat information, take advantage of it if it's available * is_visible_file(): optimistically expect the provided stat buffer is already valid * dptr_ReadDirName(): refactor code for easier readability, functionality is the same
2009-02-04Fix bug #Bug 6090 renaming or deleting a "not matching/resolving" symlink is ↵Jeremy Allison1-4/+26
failing. Reported by Kukks. Make sure we correctly use LSTAT in all cases where POSIX pathnames are being used. This matters when dealing with symlinks pointing to invalid paths being renamed or deleted not all deletes and renames are done via an nt_create open. Jeremy.
2008-12-10Pass the get_real_filename operation through the VFSVolker Lendecke1-4/+1
This is done to help file systems that can tell us about the real upper/lower case combination given a case-insensitive file name. The sample I will soon push is the gpfs module (recent gpfs has a get_real_filename function), others might have a similar function to help alleviate the 1million files in a single directory problem. Jeremy, please comment! Thanks, Volker
2008-12-10Change get_real_filename() to unix syscall conventions, make it non-staticVolker Lendecke1-13/+14
It sets errno, so it might as well return 0/-1.
2008-12-10Apply some constVolker Lendecke1-2/+2
2008-12-10Rename "scan_directory" to "get_real_filename"Volker Lendecke1-12/+12
2008-11-18Re-structure Volker's patch to "Fix trans2findfirst for the large directory ↵Jeremy Allison1-26/+21
optimization". Makes the change clearer. Jeremy.
2008-11-18Fix trans2findfirst for the large directory optimizationVolker Lendecke1-0/+5
With case sensitive = yes preserve case = no short preserve case = no default case = upper a "dir FOO.txt" would not find "FOO.TXT" because FOO.txt ends up unconverted in the mask for mask_match. Jeremy, please check! Volker
2008-09-23Fix bug #5783 FindFirst fails where search pattern == mangled filename.Jeremy Allison1-2/+1
That was an old and subtle bug. Jeremy.
2008-08-12Fix unix_convert() for "*" after changing map_nt_error_from_unix().Michael Adam1-1/+1
map_nt_error_from_unix() now assumes that it is called in an error path and returns an error even for a given errno == 0. The original behaviour of unix_convert() used the mapping of errno == 0 ==> NT_STATUS_OK to return success through an error path. I think this must have been an oversight, and unix_convert() worked only by coincidence (or because explicitly using the knowledge of the conceptually wrong working of map_nt_error_from_unix(). This patch puts this straight by not interpreting errno == 0 as an error condition and proceeding in that case. Jeremy - please check! Michael (This used to be commit ec5956ab0df1b3f567470b2481b73da9c3c67371)
2008-04-07locking: combine get_delete_on_close_flag() and get_write_time() into ↵Stefan Metzmacher1-5/+13
get_file_infos() This means we need to fetch the record only once. metze (This used to be commit 4130b873291d39e363184fe4e38dc1f24ebe5056)
2008-01-19Couple of minor fixes for POSIX pathname processing in theJeremy Allison1-8/+10
new stream code. (1) In smbd/filename, don't split the name at ':' if we know it's a posix path (this should be parameterized....). (2). When calling posix_mkdir, we get the flag FILE_FLAG_POSIX_SEMANTICS passed to open_directory(). I know for a posix client lp_posix_pathnames should be true (which is checked for in is_ntfs_stream_name() but we have an explicit flag here, so let's use it. Jeremy. (This used to be commit 7bb7a0def6518784befa75e5303289d2b4d36dd4)
2008-01-19Add streams supportVolker Lendecke1-0/+121
This is the core of the streams support. The main change is that in files_struct there is now a base_fsp pointer that holds the main file open while a stream is open. This is necessary to get the rather strange delete semantics right: You can't delete the main file while a stream is open without FILE_SHARE_DELETE, and while a stream is open a successful unlink of the main file leads to DELETE_PENDING for all further access on the main file or any stream. (This used to be commit 6022873cc155bdbbd3fb620689715f07a24d6ed1)
2008-01-12Convert OpenDir to talloc, use talloc_tos()Volker Lendecke1-3/+3
This cuts some mallocs on NtCreate&X (This used to be commit 8e64107b7846d8f9cce71aabc95b28b7488d01ce)
2007-12-22If we detect a case insensitive filesystem makeJeremy Allison1-4/+11
sure we don't search directories on name misses for non-mangled names. Jeremy (This used to be commit 120048d2f40cf1a0ace2ecde205cbc694d263d69)
2007-12-22Use filesystem capabilities to support case-insensitive filesystems.James Peach1-0/+9
If we know the underlying filesystem is case-insensitive, then we know that it won't help to search for case variations of the requested name. Jeremy, please review (and revert if you disagree). (This used to be commit 9e8b8f8c16612d8a08b55802f4fd9afca5498a7c)
2007-10-18RIP BOOL. Convert BOOL -> bool. I found a few interestingJeremy Allison1-10/+10
bugs in various places whilst doing this (places that assumed BOOL == int). I also need to fix the Samba4 pidl generation (next checkin). Jeremy. (This used to be commit f35a266b3cbb3e5fa6a86be60f34fe340a3ca71f)