[PATCH] Fix MSDFS with POSIX paths in vfs_dfs_samba4

Jeremy Allison jra at samba.org
Fri Jun 5 16:35:46 MDT 2015


On Fri, Jun 05, 2015 at 02:52:33PM +0100, Robin McCorkell wrote:
> Damn, this isn't working as posix_pathnames isn't an smb.conf parameter,
> it's a floating function with a static bool behind it. I tried to use
> lp_posix_pathnames() instead, but got linker errors. Anyone got any ideas
> what I should do? Should we always try to parse POSIX-style paths,
> regardless of the value of lp_posix_pathnames() ? Or is checking the result
> of that function absolutely crucial?

Hi Robin,

Thanks for your patches ! In path processing, both
'/' and '\\' can be used as a directory separator,
so the best thing to do is just check for both.

Note that / cannot be the second byte in a multi-byte
character sequence, but \ can be, so when checking
for \ use the _m functions (or step through the path
one mb-character at a time using next_codepoint().

Hope this helps. Let me know if you want any more
help in finishing up this patch and I'll work directly
with you on it.

Cheers,

Jeremy.


> Robin McCorkell
> Karoshi Client maintainer, The Linux Schools Project
> 
> http://www.linuxschools.com
> https://github.com/the-linux-schools-project
> 
> On 5 June 2015 at 13:48, Robin McCorkell <rmccorkell at karoshi.org.uk> wrote:
> 
> > Allow for POSIX path separators when parsing a DFS query string
> >
> > The source3 code supports forward slashes, but a missing check in the
> > source4
> > code prevents POSIX paths being used when the server is in AD mode.
> >
> > This is a tweaked resubmission of my patch on 27 February, with an
> > lpcfg_*()
> > check added.
> > ---
> >  dfs_server/dfs_server_ad.c | 11 ++++++++---
> >  1 file changed, 8 insertions(+), 3 deletions(-)
> >
> > diff --git a/dfs_server/dfs_server_ad.c b/dfs_server/dfs_server_ad.c
> > index 3d93e19..cb1ef51 100644
> > --- a/dfs_server/dfs_server_ad.c
> > +++ b/dfs_server/dfs_server_ad.c
> > @@ -801,6 +801,7 @@ NTSTATUS dfs_server_ad_get_referrals(struct
> > loadparm_context *lp_ctx,
> >         const char *netbios_name;
> >         const char *dns_name;
> >         const char **netbios_aliases;
> > +       char path_separator = '\\';
> >
> >         if (!lpcfg_host_msdfs(lp_ctx)) {
> >                 return NT_STATUS_FS_DRIVER_REQUIRED;
> > @@ -828,16 +829,20 @@ NTSTATUS dfs_server_ad_get_referrals(struct
> > loadparm_context *lp_ctx,
> >                 return NT_STATUS_NO_MEMORY;
> >         }
> >
> > -       while(*server_name && *server_name == '\\') {
> > +       if (lpcfg_posix_pathnames(lp_ctx) && *server_name == '/') {
> > +               path_separator = '/';
> > +       }
> > +
> > +       while(*server_name && *server_name == path_separator) {
> >                 server_name++;
> >         }
> >
> > -       dfs_name = strchr(server_name, '\\');
> > +       dfs_name = strchr(server_name, path_separator);
> >         if (dfs_name != NULL) {
> >                 dfs_name[0] = '\0';
> >                 dfs_name++;
> >
> > -               link_path = strchr(dfs_name, '\\');
> > +               link_path = strchr(dfs_name, path_separator);
> >                 if (link_path != NULL) {
> >                         link_path[0] = '\0';
> >                         link_path++;
> > --
> > 1.9.1
> >
> >


More information about the samba-technical mailing list