From ed4da609282b8b978be134fc4af1c5ccd3dbc903 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 15 Apr 2009 13:01:09 +0200 Subject: [PATCH] Do not use the file system GET_REAL_FILENAME for mangled names --- source/smbd/filename.c | 60 ++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 53 insertions(+), 7 deletions(-) diff --git a/source/smbd/filename.c b/source/smbd/filename.c index 003cb0f..d404b90 100644 --- a/source/smbd/filename.c +++ b/source/smbd/filename.c @@ -33,6 +33,13 @@ static NTSTATUS build_stream_path(TALLOC_CTX *mem_ctx, const char *streamname, SMB_STRUCT_STAT *pst, char **path); +static int get_real_filename_mangled(connection_struct *conn, const char *path, + const char *name, TALLOC_CTX *mem_ctx, + char **found_name); +static int get_real_filename_internal(connection_struct *conn, + const char *path, const char *name, + bool mangled, + TALLOC_CTX *mem_ctx, char **found_name); /**************************************************************************** Mangle the 2nd name and check if it is then equal to the first name. @@ -447,7 +454,7 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx, */ if (name_has_wildcard || - (SMB_VFS_GET_REAL_FILENAME( + (get_real_filename_mangled( conn, dirpath, start, talloc_tos(), &found_name) == -1)) { char *unmangled; @@ -789,15 +796,12 @@ static bool fname_equal(const char *name1, const char *name2, If the name looks like a mangled name then try via the mangling functions ****************************************************************************/ -int get_real_filename(connection_struct *conn, const char *path, - const char *name, TALLOC_CTX *mem_ctx, - char **found_name) +static int get_real_filename_mangled(connection_struct *conn, const char *path, + const char *name, TALLOC_CTX *mem_ctx, + char **found_name) { - struct smb_Dir *cur_dir; - const char *dname; bool mangled; char *unmangled_name = NULL; - long curpos; mangled = mangle_is_mangled(name, conn->params); @@ -837,9 +841,37 @@ int get_real_filename(connection_struct *conn, const char *path, if (!mangled) { /* Name is now unmangled. */ name = unmangled_name; + } else { + /* + * If we have mangled names, do not ask the VFS'es + * GET_REAL_FILENAME. The Unix file system below does + * not know about Samba's style of mangling. + * + * Boolean flags passed down are evil, the alternative + * would be to pass a comparison function down into + * the loop in get_real_filename_internal(). For now, + * do the quick&dirty boolean flag approach. + */ + return get_real_filename_internal(conn, path, name, + true, + mem_ctx, found_name); } } + return SMB_VFS_GET_REAL_FILENAME(conn, path, name, mem_ctx, + found_name); +} + +static int get_real_filename_internal(connection_struct *conn, + const char *path, const char *name, + bool mangled, + TALLOC_CTX *mem_ctx, char **found_name) +{ + struct smb_Dir *cur_dir; + const char *dname; + char *unmangled_name = NULL; + long curpos; + /* open the directory */ if (!(cur_dir = OpenDir(talloc_tos(), conn, path, NULL, 0))) { DEBUG(3,("scan dir didn't open dir [%s]\n",path)); @@ -887,6 +919,20 @@ int get_real_filename(connection_struct *conn, const char *path, return -1; } + + +int get_real_filename(connection_struct *conn, + const char *path, const char *name, + TALLOC_CTX *mem_ctx, char **found_name) +{ + /* + * This is the default VFS function. If we end up here, we know we + * don't have mangled names around. + */ + return get_real_filename_internal(conn, path, name, false, + mem_ctx, found_name); +} + static NTSTATUS build_stream_path(TALLOC_CTX *mem_ctx, connection_struct *conn, const char *orig_path, -- 1.6.2.1