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

87 Commits

Author SHA1 Message Date
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
Jeremy Allison
3d6f4a7af7 Fix bug #6330 - DFS doesn't work on AIX. Jeremy. 2009-05-08 11:39:05 -07:00
Günther Deschner
fe839b65a7 s3-printing: Fix driver upload for Xerox 4110 PS printer driver.
We need to allow to set filesystem capabilities from the default vfs in
create_conn_struct() in order to find mixed-case filenames. Thanks Volker!

This one was hard to find, so a little longer explanation:

When a Windows client tries to upload e.g. the Xerox 4110 PS driver, the client
first uploads the driver files to the [print$] share. Some of them (in this case
the Windows Postscript drivers) are with uppercase filenames while some of them
(like the PPD file) are in lowercase. After the driver upload the client issues
the spoolss_AddPrinterDriverEx() call with level 6. There the client tries to
add the PPD file with an uppercase filename (while having stored it in lowercase
on the server). The internal spoolss add driver functions then could not find the
appropriate filename while trying to move them to the version subdirectory (in
this case W32X86/3) and fails then entire spoolss_AddPrinterDriverEx() call.
With this fix, the convert_unix_name() name finds the correct file and
the spoolss_AddPrinterDriverEx() succeeds.

Guenther
2009-05-04 12:12:14 +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
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
Volker Lendecke
ed27d91068 Add auth_serversupplied_info to create_conn_struct
srvsvc needs it, as will printing
2008-11-23 22:41:59 +01:00
Yasuma Takeda
293372ff8d Fix bug #5909 - MS-DFS does not work on Vista, if link name includes multibyte character. 2008-11-20 11:38:37 -08:00
Volker Lendecke
49403ee82f Make create_conn_struct() public
(This used to be commit e115e25822)
2008-07-27 17:56:48 +02:00
Volker Lendecke
344941bb49 Move the responsibility to keep the cwd from srv_dfs_nt to msdfs.c
(This used to be commit 7db382588a)
2008-06-24 10:31:35 +02:00
Volker Lendecke
13ebf889b3 Remove the "exists" parameter from create_msdfs_link
Jeremy, setting "exists" to True in _dfs_Add prevented the initial creation of
a new symlink for me, because the SMB_VFS_UNLINK failed. This also exists in
3.2. I only check it into 3.3 as I would like you to look at it first.

Thanks,

Volker
(This used to be commit f58b098a41)
2008-06-22 20:45:53 +02:00
Volker Lendecke
a7e284c62d Reduce memory usage in form_junctions() a little bit
(This used to be commit d031e6d8ca)
2008-06-22 20:45:53 +02:00
Volker Lendecke
b4587a7c78 Fix an abort in junction_to_local_path
(This used to be commit 587bd636cb)
2008-06-22 18:37:41 +02:00
Volker Lendecke
65f7457583 Fix a crash in _dfs_Enum
(cherry picked from commit 4a99647629)
(This used to be commit 86cae83a7d)
2008-06-22 13:08:47 +02:00
Volker Lendecke
62f69165f6 Fix an uninitialized variable access in callers of parse_msdfs_symlink
At least form_junctions() does not initialize refcount, and I don't see it in
get_referred_path(). For the latters, the callers might initialize it. But even
if they did, I think parse_msdfs_symlink() should unconditionally return the
number of referrals it found. I don't think it makes sense to count them up
from somewhere else.
(This used to be commit 7317211348)
2008-06-22 13:07:51 +02:00
Volker Lendecke
a8ae3bc317 Fix a double-closedir() in form_junctions()
(This used to be commit 1d7ad0dea7)
2008-06-21 16:49:00 +02:00
Volker Lendecke
50ab871813 Remove some references to get_current_username() and current_user_info
(This used to be commit 344d69f95e)
2008-05-25 11:43:57 +02:00
Jeremy Allison
c7f5d24d81 Restructuring of code to fix #5460. Remove search
by name code from conn, we were already doing the
same check in the dfs_redirect() function, so move
it into parse_dfs_path() instead.
Jeremy.
(This used to be commit 8a7c6df122)
2008-05-19 13:11:00 -07:00
Jeremy Allison
b8398d19af Fix debug message.
Jeremy.
(This used to be commit 08d168f0e5)
2008-05-13 15:25:26 -07:00
Jeremy Allison
b833615721 Second part of patch for bug #5460. Cope with pathnames
that don't look like \xxx\yyy, cope with arbitrary length.
Jeremy.
(This used to be commit 635035d999)
2008-05-13 15:02:11 -07:00
Jeremy Allison
bafe8d22fd Fix bug #5460. The problem is RHEL5.0 shipped a CIFS client
that sets the DFS bit on pathnames but doesn't
send DFS paths. This causes lookups to fail as
the smbd/msdfs.c code now just eats the first
two parts of the pathname and uses the rest as
the local path. The previous hostname check
used to protect us from that as we knew that
when the hostname was invalid it was a local
path (and a broken client).
I didn't want to put that check back in, but
came up with another idea - even though the
hostname can be a different one, the sharename
must be valid on this machine. So we can check
for a valid sharename instead.
Jeremy.
(This used to be commit e1cda82f6f)
2008-05-13 14:01:19 -07:00
Volker Lendecke
768c0d6b22 Fix dfs_Enum: In form_junctions, correctly check for malloc failure
(This used to be commit 1b1614c326)
2008-05-05 12:45:12 +02:00
Volker Lendecke
d62563342e Remove connection_struct->mem_ctx, connection_struct is its own parent
(This used to be commit 559180f7d3)
2008-05-05 11:23:13 +02:00
Jeremy Allison
3ebb6be00d Fix MSDFS bug noticed by Ofir Azoulay <Ofir.Azoulay@expand.com>.
There is no reason to ensure the target host is ourselves, and
this breaks MS clients in some cases.
Jeremy.
(This used to be commit c19fdf43d1)
2008-04-02 11:23:36 -07:00
Volker Lendecke
587cf54c61 strtok -> strtok_r
(This used to be commit fd34ce4370)
2008-01-23 15:08:04 +01:00
Jeremy Allison
acf15ae730 Don't build rpctorture anymore - not maintained. Just remove.
Remove all vestiges of pstring (except for smbctool as noted
in previous commit).
Jeremy
(This used to be commit 4c32a22ac5)
2007-12-07 12:26:32 -08:00
Jeremy Allison
2b3c44e4fb Always define PATH_MAX. Makes code simpler (removes
a bunch of #defines). Remove pstring from msdfs.c.
Jeremy.
(This used to be commit e203ba2227)
2007-11-10 22:31:34 -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
Volker Lendecke
aea0d4b9a0 r25327: Normalize the path we return for 'msdfs proxy'
We now accept both \\server\tmp and \server\tmp. There are other places
where this might be necessary, but at least the functionality is a bit
easier now.
(This used to be commit 25cc27df97)
2007-10-10 12:31:00 -05:00
Volker Lendecke
e0402fa870 r25324: Fix "msdfs proxy"
Jeremy, please check!
(This used to be commit d4eddf88d2)
2007-10-10 12:30:59 -05:00
Volker Lendecke
ad97bcf813 r25184: Fix some C++ warnings and an uninitialized variable
(This used to be commit b64df8a3c5)
2007-10-10 12:30:49 -05:00
Jeremy Allison
bb4773e30f r25173: Use the append_buffer version in a loop.
Jeremy.
(This used to be commit 37cf2c2727)
2007-10-10 12:30:48 -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
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
d75a38ae26 r24253: From Jan Martin <Jan.Martin@rwedea.com>.
----------------------------------------------------------
In rare cases, Samba 3.0.25b shows directory contents at the wrong
position in the file tree when displaying a subdirectory of a DFS link.

The problem occurs whenever Windows XP asks for a DFS referral for a
subdirectory of a DFS link with a trailing backslash.
Windows does not do this very often, but we saw it several times per day
on our central DFS server.

smbd/msdfs.c, dfs_path_lookup() does the following with the requested
path:
- in line 390, the local copy 'localpath' is 'unix_convert'ed; the
trailing backslash is removed inside unix_convert
- in lines 417-20, 'dfspath' (another copy of the requested path) is
mangled another way without removing trailing backslashes

That's why the following loop (lines 435-461) that is meant to
synchronously cut off the last path component from both strings until it
comes to a DFS link, does not handle both strings the same.  When the
original path ended with a backslash, 'canon_dfspath' has always one
component more than 'localpath', so that *consumedcntp gets too big in
line 446. This value is reported to the client.
----------------------------------------------------------

Bug #4860.

Jeremy.
(This used to be commit 42d1c6713a)
2007-10-10 12:29:21 -05:00
Jeremy Allison
188b84f9d0 r23843: Fix bug #4777, reported by Bill Marshall <bmarsh@us.ibm.com>.
Doing a DFS traverse through a deep link could fail (not using
explorer).
Jeremy.
(This used to be commit cd93f0cb00)
2007-10-10 12:28:33 -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
43e51b3989 r23522: Save us a kilobyte stack space in a hot code path: I can't see a reason
why check_path_syntax should not be able to run in-line. The destination
pointer either walks side by side with the source pointer or is
decremented. So as far as I can see s>=d is true throughout the whole
routine.

Jeremy, I'm checking this only into 3_0 for now. Please review and ack
or directly merge this to 3_0_26.

Thanks,

Volker
(This used to be commit 34a13c82a3)
2007-10-10 12:23:25 -05:00
Jeremy Allison
56a5d05b8b r22590: Make TALLOC_ARRAY consistent across all uses.
That should be it....
Jeremy.
(This used to be commit 603233a98b)
2007-10-10 12:19:49 -05:00
Jeremy Allison
cab91684e5 r22064: Fix the DFS code to work better with Vista clients. Allow
"host msdfs = true" to be set in the [global] section
and allow Vista to see shares with "msdfs root = yes"
and "msdfs root = no" off the same server. Down
to an error message really :-).
Jeremy.
(This used to be commit 1a0f69bb21)
2007-10-10 12:19:08 -05:00
Stefan Metzmacher
56ba447668 r22001: change prototype of dump_data(), so that it takes unsigned char * now,
which matches what samba4 has.

also fix all the callers to prevent compiler warnings

metze
(This used to be commit fa322f0cc9)
2007-10-10 12:18:59 -05:00
Jeremy Allison
9527f93272 r21961: Repair bug introduced by rev. 21960.
We need to do the initial strtok to set up the internal state.
Jeremy.
(This used to be commit 8c7042b419)
2007-10-10 12:18:53 -05:00
Volker Lendecke
eca13022ef r21960: Fix bugs 4463,4464,4465,4466. Thanks Jason :-)
(This used to be commit a2e27c4431)
2007-10-10 12:18:52 -05:00
Jeremy Allison
bf26a7632e r21942: Hoist by our own petard :-). Older smbclient binaries
were not able to connect to the rewritten dfs code as
they set the dfs flag bit but then send local paths.

Now that our dfs code is a *lot* more robust in
detecting this sort of braindamage we can just
call into it directly on getting a DFS flag
and let the parser sort it out without having
to check it's actually connecting to a dfs
enabled share (I'm proud of this code :-).

Jeremy.
(This used to be commit 8c4d929c76)
2007-10-10 12:18:51 -05:00
Jeremy Allison
a5dd4355cd r21803: Missed part of patch to make self-referrals work.
Jeremy.
(This used to be commit b1fa55e513)
2007-10-10 12:18:35 -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
db32963181 r21759: Fix the same bug in a more elegant way, strrchr_m
is an expensive call....
Jeremy.
(This used to be commit 321a136dbc)
2007-10-10 12:18:28 -05:00
Jeremy Allison
c4ea95fd30 r21758: Fix a very specific dfs bug when passing in POSIX
pathnames. When we're working out how much we've
consumed we need to backtrack by either a '/' or '\\'
component, as both are valid separators.
Jeremy.
(This used to be commit 1722ea20db)
2007-10-10 12:18:28 -05:00