smbd: Fix a profile problem
[vlendec/samba-autobuild/.git] / source3 / smbd / filename.c
1 /*
2    Unix SMB/CIFS implementation.
3    filename handling routines
4    Copyright (C) Andrew Tridgell 1992-1998
5    Copyright (C) Jeremy Allison 1999-2007
6    Copyright (C) Ying Chen 2000
7    Copyright (C) Volker Lendecke 2007
8
9    This program is free software; you can redistribute it and/or modify
10    it under the terms of the GNU General Public License as published by
11    the Free Software Foundation; either version 3 of the License, or
12    (at your option) any later version.
13
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18
19    You should have received a copy of the GNU General Public License
20    along with this program.  If not, see <http://www.gnu.org/licenses/>.
21 */
22
23 /*
24  * New hash table stat cache code added by Ying Chen.
25  */
26
27 #include "includes.h"
28 #include "system/filesys.h"
29 #include "fake_file.h"
30 #include "smbd/smbd.h"
31 #include "smbd/globals.h"
32
33 static NTSTATUS build_stream_path(TALLOC_CTX *mem_ctx,
34                                   connection_struct *conn,
35                                   const char *orig_path,
36                                   struct smb_filename *smb_fname);
37
38 /****************************************************************************
39  Mangle the 2nd name and check if it is then equal to the first name.
40 ****************************************************************************/
41
42 static bool mangled_equal(const char *name1,
43                         const char *name2,
44                         const struct share_params *p)
45 {
46         char mname[13];
47
48         if (!name_to_8_3(name2, mname, False, p)) {
49                 return False;
50         }
51         return strequal(name1, mname);
52 }
53
54 /****************************************************************************
55  Cope with the differing wildcard and non-wildcard error cases.
56 ****************************************************************************/
57
58 static NTSTATUS determine_path_error(const char *name,
59                         bool allow_wcard_last_component)
60 {
61         const char *p;
62
63         if (!allow_wcard_last_component) {
64                 /* Error code within a pathname. */
65                 return NT_STATUS_OBJECT_PATH_NOT_FOUND;
66         }
67
68         /* We're terminating here so we
69          * can be a little slower and get
70          * the error code right. Windows
71          * treats the last part of the pathname
72          * separately I think, so if the last
73          * component is a wildcard then we treat
74          * this ./ as "end of component" */
75
76         p = strchr(name, '/');
77
78         if (!p && (ms_has_wild(name) || ISDOT(name))) {
79                 /* Error code at the end of a pathname. */
80                 return NT_STATUS_OBJECT_NAME_INVALID;
81         } else {
82                 /* Error code within a pathname. */
83                 return NT_STATUS_OBJECT_PATH_NOT_FOUND;
84         }
85 }
86
87 static NTSTATUS check_for_dot_component(const struct smb_filename *smb_fname)
88 {
89         /* Ensure we catch all names with in "/."
90            this is disallowed under Windows and
91            in POSIX they've already been removed. */
92         const char *p = strstr(smb_fname->base_name, "/."); /*mb safe*/
93         if (p) {
94                 if (p[2] == '/') {
95                         /* Error code within a pathname. */
96                         return NT_STATUS_OBJECT_PATH_NOT_FOUND;
97                 } else if (p[2] == '\0') {
98                         /* Error code at the end of a pathname. */
99                         return NT_STATUS_OBJECT_NAME_INVALID;
100                 }
101         }
102         return NT_STATUS_OK;
103 }
104
105 /****************************************************************************
106  Optimization for common case where the missing part
107  is in the last component and the client already
108  sent the correct case.
109  Returns NT_STATUS_OK to mean continue the tree walk
110  (possibly with modified start pointer).
111  Any other NT_STATUS_XXX error means terminate the path
112  lookup here.
113 ****************************************************************************/
114
115 static NTSTATUS check_parent_exists(TALLOC_CTX *ctx,
116                                 connection_struct *conn,
117                                 bool posix_pathnames,
118                                 const struct smb_filename *smb_fname,
119                                 char **pp_dirpath,
120                                 char **pp_start)
121 {
122         struct smb_filename parent_fname;
123         const char *last_component = NULL;
124         NTSTATUS status;
125         int ret;
126
127         ZERO_STRUCT(parent_fname);
128         if (!parent_dirname(ctx, smb_fname->base_name,
129                                 &parent_fname.base_name,
130                                 &last_component)) {
131                 return NT_STATUS_NO_MEMORY;
132         }
133
134         /*
135          * If there was no parent component in
136          * smb_fname->base_name of the parent name
137          * contained a wildcard then don't do this
138          * optimization.
139          */
140         if ((smb_fname->base_name == last_component) ||
141                         ms_has_wild(parent_fname.base_name)) {
142                 return NT_STATUS_OK;
143         }
144
145         if (posix_pathnames) {
146                 ret = SMB_VFS_LSTAT(conn, &parent_fname);
147         } else {
148                 ret = SMB_VFS_STAT(conn, &parent_fname);
149         }
150
151         /* If the parent stat failed, just continue
152            with the normal tree walk. */
153
154         if (ret == -1) {
155                 return NT_STATUS_OK;
156         }
157
158         status = check_for_dot_component(&parent_fname);
159         if (!NT_STATUS_IS_OK(status)) {
160                 return status;
161         }
162
163         /* Parent exists - set "start" to be the
164          * last compnent to shorten the tree walk. */
165
166         /*
167          * Safe to use discard_const_p
168          * here as last_component points
169          * into our smb_fname->base_name.
170          */
171         *pp_start = discard_const_p(char, last_component);
172
173         /* Update dirpath. */
174         TALLOC_FREE(*pp_dirpath);
175         *pp_dirpath = talloc_strdup(ctx, parent_fname.base_name);
176         if (!*pp_dirpath) {
177                 return NT_STATUS_NO_MEMORY;
178         }
179
180         DEBUG(5,("check_parent_exists: name "
181                 "= %s, dirpath = %s, "
182                 "start = %s\n",
183                 smb_fname->base_name,
184                 *pp_dirpath,
185                 *pp_start));
186
187         return NT_STATUS_OK;
188 }
189
190 /****************************************************************************
191 This routine is called to convert names from the dos namespace to unix
192 namespace. It needs to handle any case conversions, mangling, format changes,
193 streams etc.
194
195 We assume that we have already done a chdir() to the right "root" directory
196 for this service.
197
198 The function will return an NTSTATUS error if some part of the name except for
199 the last part cannot be resolved, else NT_STATUS_OK.
200
201 Note NT_STATUS_OK doesn't mean the name exists or is valid, just that we
202 didn't get any fatal errors that should immediately terminate the calling SMB
203 processing whilst resolving.
204
205 If the UCF_SAVE_LCOMP flag is passed in, then the unmodified last component
206 of the pathname is set in smb_filename->original_lcomp.
207
208 If UCF_ALWAYS_ALLOW_WCARD_LCOMP is passed in, then a MS wildcard was detected
209 and should be allowed in the last component of the path only.
210
211 If the orig_path was a stream, smb_filename->base_name will point to the base
212 filename, and smb_filename->stream_name will point to the stream name.  If
213 orig_path was not a stream, then smb_filename->stream_name will be NULL.
214
215 On exit from unix_convert, the smb_filename->st stat struct will be populated
216 if the file exists and was found, if not this stat struct will be filled with
217 zeros (and this can be detected by checking for nlinks = 0, which can never be
218 true for any file).
219 ****************************************************************************/
220
221 NTSTATUS unix_convert(TALLOC_CTX *ctx,
222                       connection_struct *conn,
223                       const char *orig_path,
224                       struct smb_filename **smb_fname_out,
225                       uint32_t ucf_flags)
226 {
227         struct smb_filename *smb_fname = NULL;
228         char *start, *end;
229         char *dirpath = NULL;
230         char *stream = NULL;
231         bool component_was_mangled = False;
232         bool name_has_wildcard = False;
233         bool posix_pathnames = false;
234         bool allow_wcard_last_component =
235             (ucf_flags & UCF_ALWAYS_ALLOW_WCARD_LCOMP);
236         bool save_last_component = ucf_flags & UCF_SAVE_LCOMP;
237         NTSTATUS status;
238         int ret = -1;
239
240         *smb_fname_out = NULL;
241
242         smb_fname = talloc_zero(ctx, struct smb_filename);
243         if (smb_fname == NULL) {
244                 return NT_STATUS_NO_MEMORY;
245         }
246
247         if (conn->printer) {
248                 /* we don't ever use the filenames on a printer share as a
249                         filename - so don't convert them */
250                 if (!(smb_fname->base_name = talloc_strdup(smb_fname,
251                                                            orig_path))) {
252                         status = NT_STATUS_NO_MEMORY;
253                         goto err;
254                 }
255                 goto done;
256         }
257
258         DEBUG(5, ("unix_convert called on file \"%s\"\n", orig_path));
259
260         /*
261          * Conversion to basic unix format is already done in
262          * check_path_syntax().
263          */
264
265         /*
266          * Names must be relative to the root of the service - any leading /.
267          * and trailing /'s should have been trimmed by check_path_syntax().
268          */
269
270 #ifdef DEVELOPER
271         SMB_ASSERT(*orig_path != '/');
272 #endif
273
274         /*
275          * If we trimmed down to a single '\0' character
276          * then we should use the "." directory to avoid
277          * searching the cache, but not if we are in a
278          * printing share.
279          * As we know this is valid we can return true here.
280          */
281
282         if (!*orig_path) {
283                 if (!(smb_fname->base_name = talloc_strdup(smb_fname, "."))) {
284                         status = NT_STATUS_NO_MEMORY;
285                         goto err;
286                 }
287                 if (SMB_VFS_STAT(conn, smb_fname) != 0) {
288                         status = map_nt_error_from_unix(errno);
289                         goto err;
290                 }
291                 DEBUG(5, ("conversion finished \"\" -> %s\n",
292                           smb_fname->base_name));
293                 goto done;
294         }
295
296         if (orig_path[0] == '.' && (orig_path[1] == '/' ||
297                                 orig_path[1] == '\0')) {
298                 /* Start of pathname can't be "." only. */
299                 if (orig_path[1] == '\0' || orig_path[2] == '\0') {
300                         status = NT_STATUS_OBJECT_NAME_INVALID;
301                 } else {
302                         status =determine_path_error(&orig_path[2],
303                             allow_wcard_last_component);
304                 }
305                 goto err;
306         }
307
308         /* Start with the full orig_path as given by the caller. */
309         if (!(smb_fname->base_name = talloc_strdup(smb_fname, orig_path))) {
310                 DEBUG(0, ("talloc_strdup failed\n"));
311                 status = NT_STATUS_NO_MEMORY;
312                 goto err;
313         }
314
315         /*
316          * Large directory fix normalization. If we're case sensitive, and
317          * the case preserving parameters are set to "no", normalize the case of
318          * the incoming filename from the client WHETHER IT EXISTS OR NOT !
319          * This is in conflict with the current (3.0.20) man page, but is
320          * what people expect from the "large directory howto". I'll update
321          * the man page. Thanks to jht@samba.org for finding this. JRA.
322          */
323
324         if (conn->case_sensitive && !conn->case_preserve &&
325                         !conn->short_case_preserve) {
326                 if (!strnorm(smb_fname->base_name, lp_defaultcase(SNUM(conn)))) {
327                         DEBUG(0, ("strnorm %s failed\n", smb_fname->base_name));
328                         status = NT_STATUS_INVALID_PARAMETER;
329                         goto err;
330                 }
331         }
332
333         /*
334          * Ensure saved_last_component is valid even if file exists.
335          */
336
337         if(save_last_component) {
338                 end = strrchr_m(smb_fname->base_name, '/');
339                 if (end) {
340                         smb_fname->original_lcomp = talloc_strdup(smb_fname,
341                                                                   end + 1);
342                 } else {
343                         smb_fname->original_lcomp =
344                             talloc_strdup(smb_fname, smb_fname->base_name);
345                 }
346                 if (smb_fname->original_lcomp == NULL) {
347                         status = NT_STATUS_NO_MEMORY;
348                         goto err;
349                 }
350         }
351
352         posix_pathnames = (lp_posix_pathnames() ||
353                                 (ucf_flags & UCF_POSIX_PATHNAMES));
354
355         /*
356          * Strip off the stream, and add it back when we're done with the
357          * base_name.
358          */
359         if (!posix_pathnames) {
360                 stream = strchr_m(smb_fname->base_name, ':');
361
362                 if (stream != NULL) {
363                         char *tmp = talloc_strdup(smb_fname, stream);
364                         if (tmp == NULL) {
365                                 status = NT_STATUS_NO_MEMORY;
366                                 goto err;
367                         }
368                         /*
369                          * Since this is actually pointing into
370                          * smb_fname->base_name this truncates base_name.
371                          */
372                         *stream = '\0';
373                         stream = tmp;
374                 }
375         }
376
377         start = smb_fname->base_name;
378
379         /*
380          * If we're providing case insensitive semantics or
381          * the underlying filesystem is case insensitive,
382          * then a case-normalized hit in the stat-cache is
383          * authoratitive. JRA.
384          *
385          * Note: We're only checking base_name.  The stream_name will be
386          * added and verified in build_stream_path().
387          */
388
389         if((!conn->case_sensitive || !(conn->fs_capabilities &
390                                        FILE_CASE_SENSITIVE_SEARCH)) &&
391             stat_cache_lookup(conn, posix_pathnames, &smb_fname->base_name, &dirpath, &start,
392                               &smb_fname->st)) {
393                 goto done;
394         }
395
396         /*
397          * Make sure "dirpath" is an allocated string, we use this for
398          * building the directories with talloc_asprintf and free it.
399          */
400
401         if ((dirpath == NULL) && (!(dirpath = talloc_strdup(ctx,"")))) {
402                 DEBUG(0, ("talloc_strdup failed\n"));
403                 status = NT_STATUS_NO_MEMORY;
404                 goto err;
405         }
406
407         /*
408          * If we have a wildcard we must walk the path to
409          * find where the error is, even if case sensitive
410          * is true.
411          */
412
413         name_has_wildcard = ms_has_wild(smb_fname->base_name);
414         if (name_has_wildcard && !allow_wcard_last_component) {
415                 /* Wildcard not valid anywhere. */
416                 status = NT_STATUS_OBJECT_NAME_INVALID;
417                 goto fail;
418         }
419
420         DEBUG(5,("unix_convert begin: name = %s, dirpath = %s, start = %s\n",
421                  smb_fname->base_name, dirpath, start));
422
423         if (!name_has_wildcard) {
424                 /*
425                  * stat the name - if it exists then we can add the stream back (if
426                  * there was one) and be done!
427                  */
428
429                 if (posix_pathnames) {
430                         ret = SMB_VFS_LSTAT(conn, smb_fname);
431                 } else {
432                         ret = SMB_VFS_STAT(conn, smb_fname);
433                 }
434
435                 if (ret == 0) {
436                         status = check_for_dot_component(smb_fname);
437                         if (!NT_STATUS_IS_OK(status)) {
438                                 goto fail;
439                         }
440                         /* Add the path (not including the stream) to the cache. */
441                         stat_cache_add(orig_path, smb_fname->base_name,
442                                        conn->case_sensitive);
443                         DEBUG(5,("conversion of base_name finished %s -> %s\n",
444                                  orig_path, smb_fname->base_name));
445                         goto done;
446                 }
447
448                 /* Stat failed - ensure we don't use it. */
449                 SET_STAT_INVALID(smb_fname->st);
450
451                 if (errno == ENOENT) {
452                         /* Optimization when creating a new file - only
453                            the last component doesn't exist.
454                            NOTE : check_parent_exists() doesn't preserve errno.
455                         */
456                         int saved_errno = errno;
457                         status = check_parent_exists(ctx,
458                                                 conn,
459                                                 posix_pathnames,
460                                                 smb_fname,
461                                                 &dirpath,
462                                                 &start);
463                         errno = saved_errno;
464                         if (!NT_STATUS_IS_OK(status)) {
465                                 goto fail;
466                         }
467                 }
468
469                 /*
470                  * A special case - if we don't have any wildcards or mangling chars and are case
471                  * sensitive or the underlying filesystem is case insensitive then searching
472                  * won't help.
473                  */
474
475                 if ((conn->case_sensitive || !(conn->fs_capabilities &
476                                         FILE_CASE_SENSITIVE_SEARCH)) &&
477                                 !mangle_is_mangled(smb_fname->base_name, conn->params)) {
478
479                         status = check_for_dot_component(smb_fname);
480                         if (!NT_STATUS_IS_OK(status)) {
481                                 goto fail;
482                         }
483
484                         /*
485                          * The stat failed. Could be ok as it could be
486                          * a new file.
487                          */
488
489                         if (errno == ENOTDIR || errno == ELOOP) {
490                                 status = NT_STATUS_OBJECT_PATH_NOT_FOUND;
491                                 goto fail;
492                         } else if (errno == ENOENT) {
493                                 /*
494                                  * Was it a missing last component ?
495                                  * or a missing intermediate component ?
496                                  */
497                                 struct smb_filename parent_fname;
498                                 const char *last_component = NULL;
499
500                                 ZERO_STRUCT(parent_fname);
501                                 if (!parent_dirname(ctx, smb_fname->base_name,
502                                                         &parent_fname.base_name,
503                                                         &last_component)) {
504                                         status = NT_STATUS_NO_MEMORY;
505                                         goto fail;
506                                 }
507                                 if (posix_pathnames) {
508                                         ret = SMB_VFS_LSTAT(conn, &parent_fname);
509                                 } else {
510                                         ret = SMB_VFS_STAT(conn, &parent_fname);
511                                 }
512                                 if (ret == -1) {
513                                         if (errno == ENOTDIR ||
514                                                         errno == ENOENT ||
515                                                         errno == ELOOP) {
516                                                 status = NT_STATUS_OBJECT_PATH_NOT_FOUND;
517                                                 goto fail;
518                                         }
519                                 }
520
521                                 /*
522                                  * Missing last component is ok - new file.
523                                  * Also deal with permission denied elsewhere.
524                                  * Just drop out to done.
525                                  */
526                                 goto done;
527                         }
528                 }
529         } else {
530                 /*
531                  * We have a wildcard in the pathname.
532                  *
533                  * Optimization for common case where the wildcard
534                  * is in the last component and the client already
535                  * sent the correct case.
536                  * NOTE : check_parent_exists() doesn't preserve errno.
537                  */
538                 int saved_errno = errno;
539                 status = check_parent_exists(ctx,
540                                         conn,
541                                         posix_pathnames,
542                                         smb_fname,
543                                         &dirpath,
544                                         &start);
545                 errno = saved_errno;
546                 if (!NT_STATUS_IS_OK(status)) {
547                         goto fail;
548                 }
549         }
550
551         /*
552          * is_mangled() was changed to look at an entire pathname, not
553          * just a component. JRA.
554          */
555
556         if (mangle_is_mangled(start, conn->params)) {
557                 component_was_mangled = True;
558         }
559
560         /*
561          * Now we need to recursively match the name against the real
562          * directory structure.
563          */
564
565         /*
566          * Match each part of the path name separately, trying the names
567          * as is first, then trying to scan the directory for matching names.
568          */
569
570         for (; start ; start = (end?end+1:(char *)NULL)) {
571                 /*
572                  * Pinpoint the end of this section of the filename.
573                  */
574                 /* mb safe. '/' can't be in any encoded char. */
575                 end = strchr(start, '/');
576
577                 /*
578                  * Chop the name at this point.
579                  */
580                 if (end) {
581                         *end = 0;
582                 }
583
584                 if (save_last_component) {
585                         TALLOC_FREE(smb_fname->original_lcomp);
586                         smb_fname->original_lcomp = talloc_strdup(smb_fname,
587                                                         end ? end + 1 : start);
588                         if (!smb_fname->original_lcomp) {
589                                 DEBUG(0, ("talloc failed\n"));
590                                 status = NT_STATUS_NO_MEMORY;
591                                 goto err;
592                         }
593                 }
594
595                 /* The name cannot have a component of "." */
596
597                 if (ISDOT(start)) {
598                         if (!end)  {
599                                 /* Error code at the end of a pathname. */
600                                 status = NT_STATUS_OBJECT_NAME_INVALID;
601                         } else {
602                                 status = determine_path_error(end+1,
603                                                 allow_wcard_last_component);
604                         }
605                         goto fail;
606                 }
607
608                 /* The name cannot have a wildcard if it's not
609                    the last component. */
610
611                 name_has_wildcard = ms_has_wild(start);
612
613                 /* Wildcards never valid within a pathname. */
614                 if (name_has_wildcard && end) {
615                         status = NT_STATUS_OBJECT_NAME_INVALID;
616                         goto fail;
617                 }
618
619                 /* Skip the stat call if it's a wildcard end. */
620                 if (name_has_wildcard) {
621                         DEBUG(5,("Wildcard %s\n",start));
622                         goto done;
623                 }
624
625                 /*
626                  * Check if the name exists up to this point.
627                  */
628
629                 if (posix_pathnames) {
630                         ret = SMB_VFS_LSTAT(conn, smb_fname);
631                 } else {
632                         ret = SMB_VFS_STAT(conn, smb_fname);
633                 }
634
635                 if (ret == 0) {
636                         /*
637                          * It exists. it must either be a directory or this must
638                          * be the last part of the path for it to be OK.
639                          */
640                         if (end && !S_ISDIR(smb_fname->st.st_ex_mode)) {
641                                 /*
642                                  * An intermediate part of the name isn't
643                                  * a directory.
644                                  */
645                                 DEBUG(5,("Not a dir %s\n",start));
646                                 *end = '/';
647                                 /*
648                                  * We need to return the fact that the
649                                  * intermediate name resolution failed. This
650                                  * is used to return an error of ERRbadpath
651                                  * rather than ERRbadfile. Some Windows
652                                  * applications depend on the difference between
653                                  * these two errors.
654                                  */
655                                 status = NT_STATUS_OBJECT_PATH_NOT_FOUND;
656                                 goto fail;
657                         }
658
659                 } else {
660                         char *found_name = NULL;
661
662                         /* Stat failed - ensure we don't use it. */
663                         SET_STAT_INVALID(smb_fname->st);
664
665                         /*
666                          * Reset errno so we can detect
667                          * directory open errors.
668                          */
669                         errno = 0;
670
671                         /*
672                          * Try to find this part of the path in the directory.
673                          */
674
675                         if (name_has_wildcard ||
676                             (get_real_filename(conn, dirpath, start,
677                                                talloc_tos(),
678                                                &found_name) == -1)) {
679                                 char *unmangled;
680
681                                 if (end) {
682                                         /*
683                                          * An intermediate part of the name
684                                          * can't be found.
685                                          */
686                                         DEBUG(5,("Intermediate not found %s\n",
687                                                         start));
688                                         *end = '/';
689
690                                         /*
691                                          * We need to return the fact that the
692                                          * intermediate name resolution failed.
693                                          * This is used to return an error of
694                                          * ERRbadpath rather than ERRbadfile.
695                                          * Some Windows applications depend on
696                                          * the difference between these two
697                                          * errors.
698                                          */
699
700                                         /*
701                                          * ENOENT, ENOTDIR and ELOOP all map
702                                          * to NT_STATUS_OBJECT_PATH_NOT_FOUND
703                                          * in the filename walk.
704                                          */
705
706                                         if (errno == ENOENT ||
707                                                         errno == ENOTDIR ||
708                                                         errno == ELOOP) {
709                                                 status =
710                                                 NT_STATUS_OBJECT_PATH_NOT_FOUND;
711                                         }
712                                         else {
713                                                 status =
714                                                 map_nt_error_from_unix(errno);
715                                         }
716                                         goto fail;
717                                 }
718
719                                 /*
720                                  * ENOENT/EACCESS are the only valid errors
721                                  * here. EACCESS needs handling here for
722                                  * "dropboxes", i.e. directories where users
723                                  * can only put stuff with permission -wx.
724                                  */
725                                 if ((errno != 0) && (errno != ENOENT)
726                                     && ((ucf_flags & UCF_CREATING_FILE) &&
727                                         (errno != EACCES))) {
728                                         /*
729                                          * ENOTDIR and ELOOP both map to
730                                          * NT_STATUS_OBJECT_PATH_NOT_FOUND
731                                          * in the filename walk.
732                                          */
733                                         if (errno == ENOTDIR ||
734                                                         errno == ELOOP) {
735                                                 status =
736                                                 NT_STATUS_OBJECT_PATH_NOT_FOUND;
737                                         } else {
738                                                 status =
739                                                 map_nt_error_from_unix(errno);
740                                         }
741                                         goto fail;
742                                 }
743
744                                 /*
745                                  * Just the last part of the name doesn't exist.
746                                  * We need to strupper() or strlower() it as
747                                  * this conversion may be used for file creation
748                                  * purposes. Fix inspired by
749                                  * Thomas Neumann <t.neumann@iku-ag.de>.
750                                  */
751                                 if (!conn->case_preserve ||
752                                     (mangle_is_8_3(start, False,
753                                                    conn->params) &&
754                                                  !conn->short_case_preserve)) {
755                                         if (!strnorm(start,
756                                                         lp_defaultcase(SNUM(conn)))) {
757                                                 DEBUG(0, ("strnorm %s failed\n",
758                                                         start));
759                                                 status = NT_STATUS_INVALID_PARAMETER;
760                                                 goto err;
761                                         }
762                                 }
763
764                                 /*
765                                  * check on the mangled stack to see if we can
766                                  * recover the base of the filename.
767                                  */
768
769                                 if (mangle_is_mangled(start, conn->params)
770                                     && mangle_lookup_name_from_8_3(ctx,
771                                                         start,
772                                                         &unmangled,
773                                                         conn->params)) {
774                                         char *tmp;
775                                         size_t start_ofs =
776                                             start - smb_fname->base_name;
777
778                                         if (*dirpath != '\0') {
779                                                 tmp = talloc_asprintf(
780                                                         smb_fname, "%s/%s",
781                                                         dirpath, unmangled);
782                                                 TALLOC_FREE(unmangled);
783                                         }
784                                         else {
785                                                 tmp = unmangled;
786                                         }
787                                         if (tmp == NULL) {
788                                                 DEBUG(0, ("talloc failed\n"));
789                                                 status = NT_STATUS_NO_MEMORY;
790                                                 goto err;
791                                         }
792                                         TALLOC_FREE(smb_fname->base_name);
793                                         smb_fname->base_name = tmp;
794                                         start =
795                                             smb_fname->base_name + start_ofs;
796                                         end = start + strlen(start);
797                                 }
798
799                                 DEBUG(5,("New file %s\n",start));
800                                 goto done;
801                         }
802
803
804                         /*
805                          * Restore the rest of the string. If the string was
806                          * mangled the size may have changed.
807                          */
808                         if (end) {
809                                 char *tmp;
810                                 size_t start_ofs =
811                                     start - smb_fname->base_name;
812
813                                 if (*dirpath != '\0') {
814                                         tmp = talloc_asprintf(smb_fname,
815                                                 "%s/%s/%s", dirpath,
816                                                 found_name, end+1);
817                                 }
818                                 else {
819                                         tmp = talloc_asprintf(smb_fname,
820                                                 "%s/%s", found_name,
821                                                 end+1);
822                                 }
823                                 if (tmp == NULL) {
824                                         DEBUG(0, ("talloc_asprintf failed\n"));
825                                         status = NT_STATUS_NO_MEMORY;
826                                         goto err;
827                                 }
828                                 TALLOC_FREE(smb_fname->base_name);
829                                 smb_fname->base_name = tmp;
830                                 start = smb_fname->base_name + start_ofs;
831                                 end = start + strlen(found_name);
832                                 *end = '\0';
833                         } else {
834                                 char *tmp;
835                                 size_t start_ofs =
836                                     start - smb_fname->base_name;
837
838                                 if (*dirpath != '\0') {
839                                         tmp = talloc_asprintf(smb_fname,
840                                                 "%s/%s", dirpath,
841                                                 found_name);
842                                 } else {
843                                         tmp = talloc_strdup(smb_fname,
844                                                 found_name);
845                                 }
846                                 if (tmp == NULL) {
847                                         DEBUG(0, ("talloc failed\n"));
848                                         status = NT_STATUS_NO_MEMORY;
849                                         goto err;
850                                 }
851                                 TALLOC_FREE(smb_fname->base_name);
852                                 smb_fname->base_name = tmp;
853                                 start = smb_fname->base_name + start_ofs;
854
855                                 /*
856                                  * We just scanned for, and found the end of
857                                  * the path. We must return a valid stat struct
858                                  * if it exists. JRA.
859                                  */
860
861                                 if (posix_pathnames) {
862                                         ret = SMB_VFS_LSTAT(conn, smb_fname);
863                                 } else {
864                                         ret = SMB_VFS_STAT(conn, smb_fname);
865                                 }
866
867                                 if (ret != 0) {
868                                         SET_STAT_INVALID(smb_fname->st);
869                                 }
870                         }
871
872                         TALLOC_FREE(found_name);
873                 } /* end else */
874
875 #ifdef DEVELOPER
876                 /*
877                  * This sucks!
878                  * We should never provide different behaviors
879                  * depending on DEVELOPER!!!
880                  */
881                 if (VALID_STAT(smb_fname->st)) {
882                         bool delete_pending;
883                         uint32_t name_hash;
884
885                         status = file_name_hash(conn,
886                                         smb_fname_str_dbg(smb_fname),
887                                         &name_hash);
888                         if (!NT_STATUS_IS_OK(status)) {
889                                 goto fail;
890                         }
891
892                         get_file_infos(vfs_file_id_from_sbuf(conn,
893                                                              &smb_fname->st),
894                                        name_hash,
895                                        &delete_pending, NULL);
896                         if (delete_pending) {
897                                 status = NT_STATUS_DELETE_PENDING;
898                                 goto fail;
899                         }
900                 }
901 #endif
902
903                 /*
904                  * Add to the dirpath that we have resolved so far.
905                  */
906
907                 if (*dirpath != '\0') {
908                         char *tmp = talloc_asprintf(ctx,
909                                         "%s/%s", dirpath, start);
910                         if (!tmp) {
911                                 DEBUG(0, ("talloc_asprintf failed\n"));
912                                 status = NT_STATUS_NO_MEMORY;
913                                 goto err;
914                         }
915                         TALLOC_FREE(dirpath);
916                         dirpath = tmp;
917                 }
918                 else {
919                         TALLOC_FREE(dirpath);
920                         if (!(dirpath = talloc_strdup(ctx,start))) {
921                                 DEBUG(0, ("talloc_strdup failed\n"));
922                                 status = NT_STATUS_NO_MEMORY;
923                                 goto err;
924                         }
925                 }
926
927                 /*
928                  * Cache the dirpath thus far. Don't cache a name with mangled
929                  * or wildcard components as this can change the size.
930                  */
931                 if(!component_was_mangled && !name_has_wildcard) {
932                         stat_cache_add(orig_path, dirpath,
933                                         conn->case_sensitive);
934                 }
935
936                 /*
937                  * Restore the / that we wiped out earlier.
938                  */
939                 if (end) {
940                         *end = '/';
941                 }
942         }
943
944         /*
945          * Cache the full path. Don't cache a name with mangled or wildcard
946          * components as this can change the size.
947          */
948
949         if(!component_was_mangled && !name_has_wildcard) {
950                 stat_cache_add(orig_path, smb_fname->base_name,
951                                conn->case_sensitive);
952         }
953
954         /*
955          * The name has been resolved.
956          */
957
958         DEBUG(5,("conversion finished %s -> %s\n", orig_path,
959                  smb_fname->base_name));
960
961  done:
962         /* Add back the stream if one was stripped off originally. */
963         if (stream != NULL) {
964                 smb_fname->stream_name = stream;
965
966                 /* Check path now that the base_name has been converted. */
967                 status = build_stream_path(ctx, conn, orig_path, smb_fname);
968                 if (!NT_STATUS_IS_OK(status)) {
969                         goto fail;
970                 }
971         }
972         TALLOC_FREE(dirpath);
973         *smb_fname_out = smb_fname;
974         return NT_STATUS_OK;
975  fail:
976         DEBUG(10, ("dirpath = [%s] start = [%s]\n", dirpath, start));
977         if (*dirpath != '\0') {
978                 smb_fname->base_name = talloc_asprintf(smb_fname, "%s/%s",
979                                                        dirpath, start);
980         } else {
981                 smb_fname->base_name = talloc_strdup(smb_fname, start);
982         }
983         if (!smb_fname->base_name) {
984                 DEBUG(0, ("talloc_asprintf failed\n"));
985                 status = NT_STATUS_NO_MEMORY;
986                 goto err;
987         }
988
989         *smb_fname_out = smb_fname;
990         TALLOC_FREE(dirpath);
991         return status;
992  err:
993         TALLOC_FREE(smb_fname);
994         return status;
995 }
996
997 /****************************************************************************
998  Ensure a path is not vetod.
999 ****************************************************************************/
1000
1001 NTSTATUS check_veto_path(connection_struct *conn, const char *name)
1002 {
1003         if (IS_VETO_PATH(conn, name))  {
1004                 /* Is it not dot or dot dot. */
1005                 if (!(ISDOT(name) || ISDOTDOT(name))) {
1006                         DEBUG(5,("check_veto_path: file path name %s vetoed\n",
1007                                                 name));
1008                         return map_nt_error_from_unix(ENOENT);
1009                 }
1010         }
1011         return NT_STATUS_OK;
1012 }
1013
1014 /****************************************************************************
1015  Check a filename - possibly calling check_reduced_name.
1016  This is called by every routine before it allows an operation on a filename.
1017  It does any final confirmation necessary to ensure that the filename is
1018  a valid one for the user to access.
1019 ****************************************************************************/
1020
1021 NTSTATUS check_name(connection_struct *conn, const char *name)
1022 {
1023         NTSTATUS status = check_veto_path(conn, name);
1024
1025         if (!NT_STATUS_IS_OK(status)) {
1026                 return status;
1027         }
1028
1029         if (!lp_widelinks(SNUM(conn)) || !lp_symlinks(SNUM(conn))) {
1030                 status = check_reduced_name(conn,name);
1031                 if (!NT_STATUS_IS_OK(status)) {
1032                         DEBUG(5,("check_name: name %s failed with %s\n",name,
1033                                                 nt_errstr(status)));
1034                         return status;
1035                 }
1036         }
1037
1038         return NT_STATUS_OK;
1039 }
1040
1041 /****************************************************************************
1042  Must be called as root. Creates the struct privilege_paths
1043  attached to the struct smb_request if this call is successful.
1044 ****************************************************************************/
1045
1046 static NTSTATUS check_name_with_privilege(connection_struct *conn,
1047                 struct smb_request *smbreq,
1048                 const char *name)
1049 {
1050         NTSTATUS status = check_veto_path(conn, name);
1051
1052         if (!NT_STATUS_IS_OK(status)) {
1053                 return status;
1054         }
1055         return check_reduced_name_with_privilege(conn,
1056                         name,
1057                         smbreq);
1058 }
1059
1060 /****************************************************************************
1061  Check if two filenames are equal.
1062  This needs to be careful about whether we are case sensitive.
1063 ****************************************************************************/
1064
1065 static bool fname_equal(const char *name1, const char *name2,
1066                 bool case_sensitive)
1067 {
1068         /* Normal filename handling */
1069         if (case_sensitive) {
1070                 return(strcmp(name1,name2) == 0);
1071         }
1072
1073         return(strequal(name1,name2));
1074 }
1075
1076 /****************************************************************************
1077  Scan a directory to find a filename, matching without case sensitivity.
1078  If the name looks like a mangled name then try via the mangling functions
1079 ****************************************************************************/
1080
1081 static int get_real_filename_full_scan(connection_struct *conn,
1082                                        const char *path, const char *name,
1083                                        bool mangled,
1084                                        TALLOC_CTX *mem_ctx, char **found_name)
1085 {
1086         struct smb_Dir *cur_dir;
1087         const char *dname = NULL;
1088         char *talloced = NULL;
1089         char *unmangled_name = NULL;
1090         long curpos;
1091
1092         /* handle null paths */
1093         if ((path == NULL) || (*path == 0)) {
1094                 path = ".";
1095         }
1096
1097         /* If we have a case-sensitive filesystem, it doesn't do us any
1098          * good to search for a name. If a case variation of the name was
1099          * there, then the original stat(2) would have found it.
1100          */
1101         if (!mangled && !(conn->fs_capabilities & FILE_CASE_SENSITIVE_SEARCH)) {
1102                 errno = ENOENT;
1103                 return -1;
1104         }
1105
1106         /*
1107          * The incoming name can be mangled, and if we de-mangle it
1108          * here it will not compare correctly against the filename (name2)
1109          * read from the directory and then mangled by the name_to_8_3()
1110          * call. We need to mangle both names or neither.
1111          * (JRA).
1112          *
1113          * Fix for bug found by Dina Fine. If in case sensitive mode then
1114          * the mangle cache is no good (3 letter extension could be wrong
1115          * case - so don't demangle in this case - leave as mangled and
1116          * allow the mangling of the directory entry read (which is done
1117          * case insensitively) to match instead. This will lead to more
1118          * false positive matches but we fail completely without it. JRA.
1119          */
1120
1121         if (mangled && !conn->case_sensitive) {
1122                 mangled = !mangle_lookup_name_from_8_3(talloc_tos(), name,
1123                                                        &unmangled_name,
1124                                                        conn->params);
1125                 if (!mangled) {
1126                         /* Name is now unmangled. */
1127                         name = unmangled_name;
1128                 }
1129         }
1130
1131         /* open the directory */
1132         if (!(cur_dir = OpenDir(talloc_tos(), conn, path, NULL, 0))) {
1133                 DEBUG(3,("scan dir didn't open dir [%s]\n",path));
1134                 TALLOC_FREE(unmangled_name);
1135                 return -1;
1136         }
1137
1138         /* now scan for matching names */
1139         curpos = 0;
1140         while ((dname = ReadDirName(cur_dir, &curpos, NULL, &talloced))) {
1141
1142                 /* Is it dot or dot dot. */
1143                 if (ISDOT(dname) || ISDOTDOT(dname)) {
1144                         TALLOC_FREE(talloced);
1145                         continue;
1146                 }
1147
1148                 /*
1149                  * At this point dname is the unmangled name.
1150                  * name is either mangled or not, depending on the state
1151                  * of the "mangled" variable. JRA.
1152                  */
1153
1154                 /*
1155                  * Check mangled name against mangled name, or unmangled name
1156                  * against unmangled name.
1157                  */
1158
1159                 if ((mangled && mangled_equal(name,dname,conn->params)) ||
1160                         fname_equal(name, dname, conn->case_sensitive)) {
1161                         /* we've found the file, change it's name and return */
1162                         *found_name = talloc_strdup(mem_ctx, dname);
1163                         TALLOC_FREE(unmangled_name);
1164                         TALLOC_FREE(cur_dir);
1165                         if (!*found_name) {
1166                                 errno = ENOMEM;
1167                                 TALLOC_FREE(talloced);
1168                                 return -1;
1169                         }
1170                         TALLOC_FREE(talloced);
1171                         return 0;
1172                 }
1173                 TALLOC_FREE(talloced);
1174         }
1175
1176         TALLOC_FREE(unmangled_name);
1177         TALLOC_FREE(cur_dir);
1178         errno = ENOENT;
1179         return -1;
1180 }
1181
1182 /****************************************************************************
1183  Wrapper around the vfs get_real_filename and the full directory scan
1184  fallback.
1185 ****************************************************************************/
1186
1187 int get_real_filename(connection_struct *conn, const char *path,
1188                       const char *name, TALLOC_CTX *mem_ctx,
1189                       char **found_name)
1190 {
1191         int ret;
1192         bool mangled;
1193
1194         mangled = mangle_is_mangled(name, conn->params);
1195
1196         if (mangled) {
1197                 return get_real_filename_full_scan(conn, path, name, mangled,
1198                                                    mem_ctx, found_name);
1199         }
1200
1201         /* Try the vfs first to take advantage of case-insensitive stat. */
1202         ret = SMB_VFS_GET_REAL_FILENAME(conn, path, name, mem_ctx, found_name);
1203
1204         /*
1205          * If the case-insensitive stat was successful, or returned an error
1206          * other than EOPNOTSUPP then there is no need to fall back on the
1207          * full directory scan.
1208          */
1209         if (ret == 0 || (ret == -1 && errno != EOPNOTSUPP)) {
1210                 return ret;
1211         }
1212
1213         return get_real_filename_full_scan(conn, path, name, mangled, mem_ctx,
1214                                            found_name);
1215 }
1216
1217 static NTSTATUS build_stream_path(TALLOC_CTX *mem_ctx,
1218                                   connection_struct *conn,
1219                                   const char *orig_path,
1220                                   struct smb_filename *smb_fname)
1221 {
1222         NTSTATUS status;
1223         unsigned int i, num_streams = 0;
1224         struct stream_struct *streams = NULL;
1225
1226         if (SMB_VFS_STAT(conn, smb_fname) == 0) {
1227                 DEBUG(10, ("'%s' exists\n", smb_fname_str_dbg(smb_fname)));
1228                 return NT_STATUS_OK;
1229         }
1230
1231         if (errno != ENOENT) {
1232                 DEBUG(10, ("vfs_stat failed: %s\n", strerror(errno)));
1233                 status = map_nt_error_from_unix(errno);
1234                 goto fail;
1235         }
1236
1237         /* Fall back to a case-insensitive scan of all streams on the file. */
1238         status = vfs_streaminfo(conn, NULL, smb_fname->base_name, mem_ctx,
1239                                 &num_streams, &streams);
1240
1241         if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
1242                 SET_STAT_INVALID(smb_fname->st);
1243                 return NT_STATUS_OK;
1244         }
1245
1246         if (!NT_STATUS_IS_OK(status)) {
1247                 DEBUG(10, ("vfs_streaminfo failed: %s\n", nt_errstr(status)));
1248                 goto fail;
1249         }
1250
1251         for (i=0; i<num_streams; i++) {
1252                 DEBUG(10, ("comparing [%s] and [%s]: ",
1253                            smb_fname->stream_name, streams[i].name));
1254                 if (fname_equal(smb_fname->stream_name, streams[i].name,
1255                                 conn->case_sensitive)) {
1256                         DEBUGADD(10, ("equal\n"));
1257                         break;
1258                 }
1259                 DEBUGADD(10, ("not equal\n"));
1260         }
1261
1262         /* Couldn't find the stream. */
1263         if (i == num_streams) {
1264                 SET_STAT_INVALID(smb_fname->st);
1265                 TALLOC_FREE(streams);
1266                 return NT_STATUS_OK;
1267         }
1268
1269         DEBUG(10, ("case insensitive stream. requested: %s, actual: %s\n",
1270                 smb_fname->stream_name, streams[i].name));
1271
1272
1273         TALLOC_FREE(smb_fname->stream_name);
1274         smb_fname->stream_name = talloc_strdup(smb_fname, streams[i].name);
1275         if (smb_fname->stream_name == NULL) {
1276                 status = NT_STATUS_NO_MEMORY;
1277                 goto fail;
1278         }
1279
1280         SET_STAT_INVALID(smb_fname->st);
1281
1282         if (SMB_VFS_STAT(conn, smb_fname) == 0) {
1283                 DEBUG(10, ("'%s' exists\n", smb_fname_str_dbg(smb_fname)));
1284         }
1285         status = NT_STATUS_OK;
1286  fail:
1287         TALLOC_FREE(streams);
1288         return status;
1289 }
1290
1291 /**
1292  * Go through all the steps to validate a filename.
1293  *
1294  * @param ctx           talloc_ctx to allocate memory with.
1295  * @param conn          connection struct for vfs calls.
1296  * @param dfs_path      Whether this path requires dfs resolution.
1297  * @param smbreq        SMB request if we're using privileges.
1298  * @param name_in       The unconverted name.
1299  * @param ucf_flags     flags to pass through to unix_convert().
1300  *                      UCF_ALWAYS_ALLOW_WCARD_LCOMP will be OR'd in if
1301  *                      p_cont_wcard != NULL and is true and
1302  *                      UCF_COND_ALLOW_WCARD_LCOMP.
1303  * @param p_cont_wcard  If not NULL, will be set to true if the dfs path
1304  *                      resolution detects a wildcard.
1305  * @param pp_smb_fname  The final converted name will be allocated if the
1306  *                      return is NT_STATUS_OK.
1307  *
1308  * @return NT_STATUS_OK if all operations completed succesfully, appropriate
1309  *         error otherwise.
1310  */
1311 static NTSTATUS filename_convert_internal(TALLOC_CTX *ctx,
1312                                 connection_struct *conn,
1313                                 bool dfs_path,
1314                                 struct smb_request *smbreq,
1315                                 const char *name_in,
1316                                 uint32_t ucf_flags,
1317                                 bool *ppath_contains_wcard,
1318                                 struct smb_filename **pp_smb_fname)
1319 {
1320         NTSTATUS status;
1321         bool allow_wcards = (ucf_flags & (UCF_COND_ALLOW_WCARD_LCOMP|UCF_ALWAYS_ALLOW_WCARD_LCOMP));
1322         char *fname = NULL;
1323
1324         *pp_smb_fname = NULL;
1325
1326         status = resolve_dfspath_wcard(ctx, conn,
1327                                 dfs_path,
1328                                 name_in,
1329                                 allow_wcards,
1330                                 !conn->sconn->using_smb2,
1331                                 &fname,
1332                                 ppath_contains_wcard);
1333         if (!NT_STATUS_IS_OK(status)) {
1334                 DEBUG(10,("filename_convert_internal: resolve_dfspath failed "
1335                         "for name %s with %s\n",
1336                         name_in,
1337                         nt_errstr(status) ));
1338                 return status;
1339         }
1340
1341         if (is_fake_file_path(name_in)) {
1342                 SMB_STRUCT_STAT st;
1343                 ZERO_STRUCT(st);
1344                 st.st_ex_nlink = 1;
1345                 *pp_smb_fname = synthetic_smb_fname_split(ctx,
1346                                                           name_in,
1347                                                           &st);
1348                 if (*pp_smb_fname == NULL) {
1349                         return NT_STATUS_NO_MEMORY;
1350                 }
1351                 return NT_STATUS_OK;
1352         }
1353
1354         /*
1355          * If the caller conditionally allows wildcard lookups, only add the
1356          * always allow if the path actually does contain a wildcard.
1357          */
1358         if (ucf_flags & UCF_COND_ALLOW_WCARD_LCOMP &&
1359             ppath_contains_wcard != NULL && *ppath_contains_wcard) {
1360                 ucf_flags |= UCF_ALWAYS_ALLOW_WCARD_LCOMP;
1361         }
1362
1363         status = unix_convert(ctx, conn, fname, pp_smb_fname, ucf_flags);
1364         if (!NT_STATUS_IS_OK(status)) {
1365                 DEBUG(10,("filename_convert_internal: unix_convert failed "
1366                         "for name %s with %s\n",
1367                         fname,
1368                         nt_errstr(status) ));
1369                 return status;
1370         }
1371
1372         if ((ucf_flags & UCF_UNIX_NAME_LOOKUP) &&
1373                         VALID_STAT((*pp_smb_fname)->st) &&
1374                         S_ISLNK((*pp_smb_fname)->st.st_ex_mode)) {
1375                 return check_veto_path(conn, (*pp_smb_fname)->base_name);
1376         }
1377
1378         if (!smbreq) {
1379                 status = check_name(conn, (*pp_smb_fname)->base_name);
1380         } else {
1381                 status = check_name_with_privilege(conn, smbreq, (*pp_smb_fname)->base_name);
1382         }
1383         if (!NT_STATUS_IS_OK(status)) {
1384                 DEBUG(3,("filename_convert_internal: check_name failed "
1385                         "for name %s with %s\n",
1386                         smb_fname_str_dbg(*pp_smb_fname),
1387                         nt_errstr(status) ));
1388                 TALLOC_FREE(*pp_smb_fname);
1389                 return status;
1390         }
1391
1392         return status;
1393 }
1394
1395 /*
1396  * Go through all the steps to validate a filename.
1397  * Non-root version.
1398  */
1399
1400 NTSTATUS filename_convert(TALLOC_CTX *ctx,
1401                                 connection_struct *conn,
1402                                 bool dfs_path,
1403                                 const char *name_in,
1404                                 uint32_t ucf_flags,
1405                                 bool *ppath_contains_wcard,
1406                                 struct smb_filename **pp_smb_fname)
1407 {
1408         return filename_convert_internal(ctx,
1409                                         conn,
1410                                         dfs_path,
1411                                         NULL,
1412                                         name_in,
1413                                         ucf_flags,
1414                                         ppath_contains_wcard,
1415                                         pp_smb_fname);
1416 }
1417
1418 /*
1419  * Go through all the steps to validate a filename.
1420  * root (privileged) version.
1421  */
1422
1423 NTSTATUS filename_convert_with_privilege(TALLOC_CTX *ctx,
1424                                 connection_struct *conn,
1425                                 struct smb_request *smbreq,
1426                                 const char *name_in,
1427                                 uint32_t ucf_flags,
1428                                 bool *ppath_contains_wcard,
1429                                 struct smb_filename **pp_smb_fname)
1430 {
1431         return filename_convert_internal(ctx,
1432                                         conn,
1433                                         smbreq->flags2 & FLAGS2_DFS_PATHNAMES,
1434                                         smbreq,
1435                                         name_in,
1436                                         ucf_flags,
1437                                         ppath_contains_wcard,
1438                                         pp_smb_fname);
1439 }