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

174 Commits

Author SHA1 Message Date
Aravind Srinivasan
e046b382f2 s3: Add a new VFS op called SMB_VFS_TRANSLATE_NAME
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-28 16:38:57 -07:00
Stefan Metzmacher
59c3f5e3ca s3:smbd: move dptr globals into struct smbd_server_connection
metze
2009-08-07 14:18:17 +02:00
Stefan Metzmacher
c50a03e4e2 s3:smbd: remove dirptr and dirpath from connection_struct
They're both only used in the context of a function,
so we can make them stack variables.

metze
2009-08-07 14:18:17 +02:00
Stefan Metzmacher
862c6aa19f s3:smbd: let get_dir_entry() use smbd_dirptr_get_entry()
metze
2009-08-07 14:18:16 +02:00
Stefan Metzmacher
daa71c4236 s3:smbd: add generic smbd_dirptr_get_entry()
metze
2009-08-07 14:18:15 +02:00
Stefan Metzmacher
8e419aab48 s3:smbd: don't ignore check_descend in get_dir_entry()
metze
2009-08-07 11:10:52 +02:00
Tim Prouty
1a1d10d22f s3: Plumb smb_filename through dos_mode() and related funtions 2009-07-08 21:36:03 -07:00
Tim Prouty
eb8c658fcd s3 file_access: Convert some more functions over to use smb_filneame 2009-06-25 18:25:48 -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
Tim Prouty
36c1019175 s3: Convert is_visible_file to use talloc_asprintf instead of malloc 2009-06-24 21:15:24 -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
Aravind Srinivasan
1718e803dc s3: Always allocate memory in dptr_ReadDirName
This is a follow up to 69d61453df to
adjust the API to allow the lower layers allocate memory.  Now the
memory can explicitly be freed rather than relying on talloc_tos().

Signed-off-by: Tim Prouty <tprouty@samba.org>
2009-05-18 21:50:07 -07: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
6c07b9b7e7 Attempt to fix the build on Solaris 8 2009-02-14 11:42:05 +01:00
Steven Danneman
6272f4c2f4 s3: Added SMB_VFS_INIT_SEARCH_OP to initialize data at the beginning of SMB search requests.
By default this VFS call is a NOOP, but the onefs vfs module takes advantage
of it to initialize direntry search caches at the beginning of each
TRANS2_FIND_FIRST, TRANS2_FIND_NEXT, SMBffirst, SMBsearch, and SMBunique
2009-02-09 23:56:17 -08: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
Stefan Metzmacher
3dde0cbb76 s3:smbd: move all globals and static variables in globals.[ch]
The goal is to move all this variables into a big context structure.

metze
2009-01-08 12:22:21 +01:00
Michael Adam
743d6f707a Make sure to always set errno on error path in OpenDir (and hence scan_directory).
Michael
(This used to be commit 15fc2427f9)
2008-08-12 21:37:37 +02:00
Michael Adam
24e7f40687 smbd/dir.c: remove unneeded stat buf parameter from user_can_read_file()
This is not needed anymore since user_can_access_file_acl() ist used.

Michael
(This used to be commit 3c349f773a)
2008-06-18 00:02:28 +02:00
Michael Adam
b172eb1d47 file_access: remove unneeded stat buf parameter from can_access_file_acl().
This is a security descriptor level function only.

Michael
(This used to be commit 5931540fa1)
2008-06-17 23:58:49 +02:00
Volker Lendecke
3a5e1cacf1 Remove unused "extern struct current_user" from dir.c
(This used to be commit b92cfd19b4)
2008-06-15 11:40:33 +02:00
Jeremy Allison
b430b38220 Remove the "stat_open()" function, flag, and all associated code. It was only
being (correctly) used in the can_read/can_write checks for hide unreadable/unwritable
and this is more properly done using the functions in smbd/file_access.c.
Preparing to do NT access checks on all file access.
Jeremy.
(This used to be commit 6bfb06ad95)
2008-05-02 17:22:10 -07:00
Stefan Metzmacher
19f49de92e smbd: make it possible to disable get_file_infos() on searches
metze
(This used to be commit 404a865a34)
2008-04-07 12:29: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
Stefan Metzmacher
d03453864a smbd: implement the strange write time update logic
We now never call file_ntimes() directly, every update
is done via smb_set_file_time().

This let samba3 pass the BASE-DELAYWRITE test.

The write time is only updated 2 seconds after the
first write() on any open handle to the current time
(not the time of the first write).

Each handle which had write requests updates the write
time to the current time on close().

If the write time is set explicit via setfileinfo or setpathinfo
the write time is visible directly and a following close
on the same handle doesn't update the write time.

metze
(This used to be commit 2eab212ea2)
2008-04-07 12:29:26 +02: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
Volker Lendecke
35c256226f Allocate dirp->name_cache on demand only
(This used to be commit 1a15778331)
2008-01-08 22:18:08 +01:00
Michael Adam
ee24c629a6 Remove superfluous fd parameter from SMB_VFS_FGET_NT_ACL().
Michael
(This used to be commit c0c7c1223d)
2008-01-06 23:07:59 +01: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
Volker Lendecke
15953b82eb Make [f]get_nt_acl return NTSTATUS
(This used to be commit dcbe1bf942)
2007-11-13 15:47:01 +01: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
12f61e09d9 r25117: The mega-patch Jerry was waiting for. Remove all pstrings from
the main server code paths. We should now be able to cope with
paths up to PATH_MAX length now.
Final job will be to add the TALLOC_CTX * parameter to
unix_convert to make it explicit (for Volker).
Jeremy.
(This used to be commit 7f0db75fb0)
2007-10-10 12:30:41 -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
351eb37a25 r25102: Rewrite msdfs code to use talloced filenames. Passes make test
and make valgrindtest. Final step will be to change srvstr_get_path()
to return talloced memory in the major codepaths.
Jeremy.
(This used to be commit cf6b6f9c3a)
2007-10-10 12:30:40 -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
f1041f98ce r24639: Add parameter "directory name cache size" - parameterize
use of directory name cache, 100 by default. Will be needed
to turn this off for *BSD systems.
Jeremy.
(This used to be commit bea8e9840f)
2007-10-10 12:30:13 -05:00
Andrew Tridgell
5e54558c6d r23784: use the GPLv3 boilerplate as recommended by the FSF and the license text
(This used to be commit b0132e94fc)
2007-10-10 12:28:22 -05:00
Jeremy Allison
d824b98f80 r23779: Change from v2 or later to v3 or later.
Jeremy.
(This used to be commit 407e6e695b)
2007-10-10 12:28:20 -05:00
Volker Lendecke
0bc56a2e5f r23724: Reduce access to the global inbuf a tiny bit. Add a struct smb_request
that contains some of the fields from the SMB header, removing the need
to access inbuf directly. This right now is used only in the open file
code & friends, and creating that header is only done when needed. This
needs more work, but it is a start.

Jeremy, I'm only checking this into 3_0, please review before I merge it
to _26.

Volker
(This used to be commit ca988f4e79)
2007-10-10 12:23:48 -05:00
Jeremy Allison
24cdd7c733 r21800: Check-in the DFS rewrite. I am still testing this but it
works from smbclient and Windows, and I am promising to
support and fix both client and server code moving forward.
Still need to test the RPC admin support but I haven't
changed that code.
Jeremy.
(This used to be commit 7a7862c01d)
2007-10-10 12:18:34 -05:00
Jeremy Allison
86e5659aba r21257: Better fix for bug #4188 :
Windows Vista RC1 and RC2 can't delete directory on Samba share
based on work by Joe Meadows <jmeadows@webopolis.com>.
Jeremy.
(This used to be commit 2dab892876)
2007-10-10 12:17:51 -05:00
Jeremy Allison
7a5fa7f12e r21191: Add in the POSIX open/mkdir/unlink calls.
Move more error code returns to NTSTATUS.
Client test code to follow... See if this
passes the build-farm before I add it into
3.0.25.
Jeremy.
(This used to be commit 83dbbdff34)
2007-10-10 12:17:47 -05:00
Jeremy Allison
fd37f98158 r20873: Some correctness fixes w.r.t. Samba4 torture BASE-DELETE.
Allow us to correctly refuse to set delete on close on a
non-empty directory. There are still some delete-on-close
wrinkles to be fixed, but I understand how to do that better
now. I'll fix this tomorrow.
Jeremy.
(This used to be commit 0296358858)
2007-10-10 12:17:16 -05:00
Jeremy Allison
83eb0d1d6d r20844: Somewhat radical change - this may break the build (I will
watch carefully - so I'm doing it in one transaction so I can
roll back).

Change check_name(), reduce_name() and dptr_create() to
return NTSTATUS. This helps a lot in error path processing
and especially in reduce_name() allows us to ditch the flaky
and error-prone saving of errno and return errors directly.

Jeremy.
(This used to be commit 6133a694aa)
2007-10-10 12:17:12 -05:00
Jeremy Allison
8e6390a160 r20411: Fix originally from SATOH Fumiyasu (slightly
modified). Ensure "hide unXXX" parameters don't
hide MSDFS links. Bug #3319.
Jeremy.
(This used to be commit e5466fffc2)
2007-10-10 12:16:47 -05:00
Jeremy Allison
315ad641c3 r18547: Add in fixes to mangling dir code - ensure don't
look in the paths for wcard - always read directly
from incoming packet.
Jeremy.
(This used to be commit 3745a1af4e)
2007-10-10 11:51:48 -05:00
Jeremy Allison
fbdcf2663b r16945: Sync trunk -> 3.0 for 3.0.24 code. Still need
to do the upper layer directories but this is what
everyone is waiting for....

Jeremy.
(This used to be commit 9dafb7f48c)
2007-10-10 11:19:14 -05:00
Jeremy Allison
a24c404967 r16537: Fix for bug #3858, all files in a directory not
being deleted when hide unreadable set to true.

Here's the scoop.

This one is really interesting. The pattern of deleting a directory is to do a
findfirst to get the first part of the list, then for each name returned it
does a open/set delete on close/close -> thus deleting the file. Then it does a
findnext with the last file name THAT IT JUST DELETED ! Now we can handle this
in the findnext in the case where hide unreadable is set to false as we look
back in our cache of names and just seek to the right point. The bug is
actually fixed in the first hunk of this patch - the one that removes the
is_visible_file() check after SearchDir returns false. We don't actually need
it and in this case it's causing the delete to be aborted because it can't find
the name (doh ! it was just deleted). We don't need it as SearchDir is only
ever called from findnext, and findnext should only ever be returning names we
gave it.

The rest of the patch are the debugs I used to find
the problem but they're generically useful.

Phew - that one took a while to track down.....

Jerry, please merge for 3.0.23 final.

Jeremy.
(This used to be commit cd048cb775)
2007-10-10 11:18:57 -05:00
Paul Green
e18c9a926f r15196: Update a comment that I found confusing (I confuse easily).
(This used to be commit eb53f01863)
2007-10-10 11:16:28 -05:00
Jeremy Allison
876f2deb3a r14986: Fix OS/2 directory delete bug found by kukks.
(Thanks a lot for all your hard work on this).
We were caching the results of *all* directory
scans, not just the results that match the
client wildcard. This actually made no sense,
as only matches on the client wildcard can be
returned to the client and so might need to
be searched for in the cache. This fixes the
directory cache to only cache entries that we
return to the client.
Jeremy.
(This used to be commit c88af597d0)
2007-10-10 11:15:55 -05:00