1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-27 03:21:53 +03:00
Commit Graph

146 Commits

Author SHA1 Message Date
Tim Prouty
10324b177e s3: Allow filename_convert() to pass through unix_convert_flags and let the caller know if the path has a wildcard
This also eliminates the need for resolve_dfspath().
2009-07-24 15:10:45 -07:00
Tim Prouty
07d3b69b55 s3: Change unix_convert to use an smb_filename struct internally
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-22 11:48:22 -07:00
Tim Prouty
00e267008d s3: Remove the now unused fname parameter from filename_convert() 2009-07-21 12:04:59 -07:00
Tim Prouty
841efce8b5 s3: Separate out a new file: filename_utils.c
This is to ease the linking pain of everything that links LOCKING_OBJ
2009-07-20 17:26:57 -07:00
Tim Prouty
82c3f505fe s3: Move is_ntfs_stream*() to filename.c 2009-07-20 17:26:57 -07:00
Tim Prouty
de3246eae2 s3: Add ability to pass NULL to filename_convert for the char *fname
The goal is to eventually remove the need for the char **fname argument
once all callers have standardized on smb_filename.
2009-07-06 15:38:40 -07:00
Tim Prouty
e129384d7c s3: Plumb smb_filename through SMB_VFS_STAT and SMB_VFS_LSTAT
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-24 21:15:25 -07:00
Volker Lendecke
8d1b81926d Fix Coverity IDs 922 and 933
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-19 16:25:10 +02:00
Jeremy Allison
34267482d5 Replace the boilerplate calls to :
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-18 13:13:38 -07:00
Tim Prouty
4e3656b8d1 s3: Change SMB_VFS_OPEN to take an smb_filename struct
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-17 20:11:53 -07:00
Tim Prouty
9d7c4ad748 s3: Add smb_filename utility functions and fix a bug in copy_smb_filename 2009-06-12 16:14:44 -07:00
Tim Prouty
bddd7ad3dc s3: Add utility function for copying an smb_filename struct 2009-06-10 13:13:27 -07:00
Jeremy Allison
34c2172ae8 Simplify the dropbox patch 2009-05-30 11:30:16 +02:00
Volker Lendecke
590a3afc8a Re-Add the "dropbox" functionality with -wx rights on a directory 2009-05-29 16:57:47 -07:00
Volker Lendecke
49ca690b4b Introduce "struct stat_ex" as a replacement for SMB_STRUCT_STAT
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-26 17:48:23 +02:00
Tim Prouty
c1a21d085d s3: Change unix_convert (and its callers) to use struct smb_filename
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-20 17:40:15 -07:00
Volker Lendecke
c291a55a35 Do not call SMB_VFS_GET_REAL_FILENAME if the name is mangled
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-09 14:09:41 +02:00
tprouty
69d61453df s3: Fix trans2 path to use case-insensitive stat optimization
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-05-05 16:43:53 -07:00
Volker Lendecke
1722859abd Revert "Do not use the file system GET_REAL_FILENAME for mangled names"
This reverts commit b5b6ecb58a.
2009-04-23 14:54:52 +02:00
Volker Lendecke
b5b6ecb58a Do not use the file system GET_REAL_FILENAME for mangled names 2009-04-20 14:05:13 +02:00
Steven Danneman
25d345eb39 Pass stat buffer down through all levels of VFS_READDIR wrappers
* 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-09 23:56:16 -08:00
Jeremy Allison
e7c09d8b10 Fix bug #Bug 6090 renaming or deleting a "not matching/resolving" symlink is 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.
2009-02-04 16:33:52 -08:00
Volker Lendecke
21b9dec990 Pass the get_real_filename operation through the VFS
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-10 18:05:26 +01:00
Volker Lendecke
31543640e6 Change get_real_filename() to unix syscall conventions, make it non-static
It sets errno, so it might as well return 0/-1.
2008-12-10 17:45:43 +01:00
Volker Lendecke
c7521b25e9 Apply some const 2008-12-10 17:45:43 +01:00
Volker Lendecke
6bb2fff0c1 Rename "scan_directory" to "get_real_filename" 2008-12-10 17:45:43 +01:00
Jeremy Allison
93fd28a350 Re-structure Volker's patch to "Fix trans2findfirst for the large directory optimization". Makes the change clearer.
Jeremy.
2008-11-18 10:57:54 -08:00
Volker Lendecke
6ce29dc9ad Fix trans2findfirst for the large directory optimization
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-11-18 17:04:47 +01:00
Jeremy Allison
d275cc762d Fix bug #5783 FindFirst fails where search pattern == mangled filename.
That was an old and subtle bug.
Jeremy.
2008-09-23 15:05:45 -07:00
Michael Adam
ac9f55b910 Fix unix_convert() for "*" after changing map_nt_error_from_unix().
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 ec5956ab0d)
2008-08-12 21:37:30 +02:00
Stefan Metzmacher
851cadba51 locking: combine get_delete_on_close_flag() and get_write_time() into get_file_infos()
This means we need to fetch the record only once.

metze
(This used to be commit 4130b87329)
2008-04-07 12:29:29 +02:00
Jeremy Allison
0bb6fb7b6f Couple of minor fixes for POSIX pathname processing in the
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 7bb7a0def6)
2008-01-19 21:53:49 -08:00
Volker Lendecke
1069cfe4ad Add streams support
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 6022873cc1)
2008-01-19 23:25:36 +01:00
Volker Lendecke
ec412b60ea Convert OpenDir to talloc, use talloc_tos()
This cuts some mallocs on NtCreate&X
(This used to be commit 8e64107b78)
2008-01-12 21:04:06 +01:00
Jeremy Allison
f980d3ea14 If we detect a case insensitive filesystem make
sure we don't search directories on name misses
for non-mangled names.
Jeremy
(This used to be commit 120048d2f4)
2007-12-22 17:38:18 -08:00
James Peach
596018455a Use filesystem capabilities to support case-insensitive filesystems.
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 9e8b8f8c16)
2007-12-22 14:55:37 -08:00
Jeremy Allison
30191d1a57 RIP BOOL. Convert BOOL -> bool. I found a few interesting
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 f35a266b3c)
2007-10-18 17:40:25 -07:00
Jeremy Allison
b91b785306 r25167: Fix breakage from mangling rewrite. Use the
new name if unmangling succeeded, not if it
failed. Jerry - please re-test, this should
fix your bug.
Jeremy.
(This used to be commit c215d6e849)
2007-10-10 12:30:47 -05:00
Jeremy Allison
eacd314057 r25138: More pstring elimination. Add a TALLOC_CTX parameter
to unix_convert().
Jeremy.
(This used to be commit 39c211a702)
2007-10-10 12:30:44 -05:00
Jeremy Allison
3a9d382164 r25111: Move to talloced pathnames on most code paths.
There are now ony 17 pstrings left in reply.c,
and these will be easy to remove (and I'll be
doing that shortly). Had to fix an interesting
bug in pull_ucs2_base_talloc() when a source
string is not null terminated :-).
Jeremy.
(This used to be commit 0c9a8c4dff)
2007-10-10 12:30:41 -05:00
Jeremy Allison
132ee3990a r25009: Large patch discussed with Volker. Move unix_convert to a talloc-based
interface. More development will come on top of this. Remove the
"mangled map" parameter.
Jeremy.
(This used to be commit dee8beba7a)
2007-10-10 12:30:32 -05:00
Jeremy Allison
3b0422ee01 r24811: Simple reformatting to fit the 80 columns rule.
Jeremy.
(This used to be commit 0cdf046dae)
2007-10-10 12:30:24 -05:00
Volker Lendecke
a9184f49d3 r24595: Fix Coverity ID 393
In this error case we would have used "start" not having it initialized
(This used to be commit 751834fff9)
2007-10-10 12:30:08 -05:00
Volker Lendecke
f5ab9ddd76 r24549: Fix unix_convert to return the already converted part
This API will change anyway when moving away from pstrings.

It took so long to fix, because that rename bug I just fixed gave make
test failures that had nothing to do with this one.

I have samba4 tests for both bugs, will check them in when the build
farm has caught up
(This used to be commit d4f442ed9b)
2007-10-10 12:29:56 -05:00
Volker Lendecke
bcc7bdcfe3 r24497: Revert r24485 -- this needs more thought
(This used to be commit 01f701ba1e)
2007-10-10 12:29:52 -05:00
Volker Lendecke
93fc3a0248 r24485: Even in the failure case unix_convert must pass the already converted
part of the string to the caller.
(This used to be commit 301ae3d68b)
2007-10-10 12:29:51 -05:00
Stefan Metzmacher
4b15f31f10 r24120: add a file_id_create() hook into the VFS layer
it's needed for some cluster filesystems to
overload this function.

metze
(This used to be commit cdaa24e804)
2007-10-10 12:29:08 -05:00
Volker Lendecke
d537225c4c r23879: Fix two memleaks, found by the IBM checker
(This used to be commit 4d1b33f513)
2007-10-10 12:28:37 -05:00
Volker Lendecke
e84f8662e6 r23878: Fix an error return, found by the IBM checker
(This used to be commit a369c67f66)
2007-10-10 12:28:37 -05:00
Jeremy Allison
b114d3dc70 r23846: Belt-and-braces on the msdfs bug. Ensure ELOOP maps
correctly.
Jeremy.
(This used to be commit f2cf4b6b9d)
2007-10-10 12:28:34 -05:00