Change get_real_filename() to unix syscall conventions, make it non-static
authorVolker Lendecke <vl@samba.org>
Wed, 10 Dec 2008 02:03:51 +0000 (03:03 +0100)
committerVolker Lendecke <vl@samba.org>
Wed, 10 Dec 2008 16:45:43 +0000 (17:45 +0100)
It sets errno, so it might as well return 0/-1.

source3/smbd/filename.c

index a5800aa85b35b2b2156fb1f596668fa8833611b4..c803e406491585922c25b65fd6a0c94710c7813c 100644 (file)
@@ -26,9 +26,9 @@
 
 #include "includes.h"
 
-static bool get_real_filename(connection_struct *conn, const char *path,
-                             const char *name, TALLOC_CTX *mem_ctx,
-                             char **found_name);
+static int get_real_filename(connection_struct *conn, const char *path,
+                            const char *name, TALLOC_CTX *mem_ctx,
+                            char **found_name);
 static NTSTATUS build_stream_path(TALLOC_CTX *mem_ctx,
                                  connection_struct *conn,
                                  const char *orig_path,
@@ -434,8 +434,9 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
                         */
 
                        if (name_has_wildcard ||
-                           !get_real_filename(conn, dirpath, start,
-                                              talloc_tos(), &found_name)) {
+                           (get_real_filename(
+                                    conn, dirpath, start,
+                                    talloc_tos(), &found_name) == -1)) {
                                char *unmangled;
 
                                if (end) {
@@ -769,9 +770,9 @@ static bool fname_equal(const char *name1, const char *name2,
  If the name looks like a mangled name then try via the mangling functions
 ****************************************************************************/
 
-static bool get_real_filename(connection_struct *conn, const char *path,
-                             const char *name, TALLOC_CTX *mem_ctx,
-                             char **found_name)
+int get_real_filename(connection_struct *conn, const char *path,
+                     const char *name, TALLOC_CTX *mem_ctx,
+                     char **found_name)
 {
        struct smb_Dir *cur_dir;
        const char *dname;
@@ -792,7 +793,7 @@ static bool get_real_filename(connection_struct *conn, const char *path,
         */
        if (!mangled && !(conn->fs_capabilities & FILE_CASE_SENSITIVE_SEARCH)) {
                errno = ENOENT;
-               return False;
+               return -1;
        }
 
        /*
@@ -824,7 +825,7 @@ static bool get_real_filename(connection_struct *conn, const char *path,
        if (!(cur_dir = OpenDir(talloc_tos(), conn, path, NULL, 0))) {
                DEBUG(3,("scan dir didn't open dir [%s]\n",path));
                TALLOC_FREE(unmangled_name);
-               return(False);
+               return -1;
        }
 
        /* now scan for matching names */
@@ -855,16 +856,16 @@ static bool get_real_filename(connection_struct *conn, const char *path,
                        TALLOC_FREE(cur_dir);
                        if (!*found_name) {
                                errno = ENOMEM;
-                               return False;
+                               return -1;
                        }
-                       return(True);
+                       return 0;
                }
        }
 
        TALLOC_FREE(unmangled_name);
        TALLOC_FREE(cur_dir);
        errno = ENOENT;
-       return False;
+       return -1;
 }
 
 static NTSTATUS build_stream_path(TALLOC_CTX *mem_ctx,