From 1c77c7f3d5b6cb29fac4606299c237c0e299f836 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Fri, 16 Jan 2009 16:41:36 -0500 Subject: Treat file names in POSIX-like case-sensitive fashion by default *** THIS COMMIT CAUSES A CHANGE OF DEFAULT BEHAVIOR IN libsmbclient!!! *** - libsmbclient now calls cli_set_case_sensitive() for a new CLI. By default, it requests case-sensitive, but the old behavior of case-insensitive can be requested with smbc_setOptionCaseSensitive(context, False); The change of behavior is considered a bug fix, as it was previously possible to accidentally overwrite a file that had the same case-insensitive name but a different case-sensitive name as a previously-existing file, while creating a new file. Derrell --- source3/libsmb/libsmb_server.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source3/libsmb/libsmb_server.c') diff --git a/source3/libsmb/libsmb_server.c b/source3/libsmb/libsmb_server.c index f4714346d1..e2cc07118b 100644 --- a/source3/libsmb/libsmb_server.c +++ b/source3/libsmb/libsmb_server.c @@ -356,6 +356,13 @@ again: return NULL; } + /* POSIX-like - always request case-sensitivity by default. */ + if (smbc_getOptionCaseSensitive(context)) { + cli_set_case_sensitive(c, True); + } else { + cli_set_case_sensitive(c, False); + } + if (smbc_getOptionUseKerberos(context)) { c->use_kerberos = True; } -- cgit From 6d300399b52e0921ce205ef2f053b722b21edeeb Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Sat, 17 Jan 2009 13:33:25 -0500 Subject: Determine case sensitivity based on file system attributes. - Most of the time, we can determine from the file system we're connecting to whether it supports case sensitivity. In those cases, we now set the internal case sensitivity flag automatically. For those cases where the request to retrieve file system attributes fails, we'll use the user-specified option value. Derrell --- source3/libsmb/libsmb_server.c | 71 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 63 insertions(+), 8 deletions(-) (limited to 'source3/libsmb/libsmb_server.c') diff --git a/source3/libsmb/libsmb_server.c b/source3/libsmb/libsmb_server.c index e2cc07118b..0ece5bb649 100644 --- a/source3/libsmb/libsmb_server.c +++ b/source3/libsmb/libsmb_server.c @@ -245,6 +245,8 @@ SMBC_server(TALLOC_CTX *ctx, int tried_reverse = 0; int port_try_first; int port_try_next; + int is_ipc = (share != NULL && strcmp(share, "IPC$") == 0); + uint32 fs_attrs = 0; const char *username_used; NTSTATUS status; @@ -310,6 +312,38 @@ SMBC_server(TALLOC_CTX *ctx, srv = NULL; } + /* Determine if this share supports case sensitivity */ + if (is_ipc) { + DEBUG(4, + ("IPC$ so ignore case sensitivity\n")); + } else if (!cli_get_fs_attr_info(c, &fs_attrs)) { + DEBUG(4, ("Could not retrieve " + "case sensitivity flag: %s.\n", + cli_errstr(c))); + + /* + * We can't determine the case sensitivity of + * the share. We have no choice but to use the + * user-specified case sensitivity setting. + */ + if (smbc_getOptionCaseSensitive(context)) { + cli_set_case_sensitive(c, True); + } else { + cli_set_case_sensitive(c, False); + } + } else { + DEBUG(4, + ("Case sensitive: %s\n", + (fs_attrs & FILE_CASE_SENSITIVE_SEARCH + ? "True" + : "False"))); + cli_set_case_sensitive( + c, + (fs_attrs & FILE_CASE_SENSITIVE_SEARCH + ? True + : False)); + } + /* * Regenerate the dev value since it's based on both * server and share @@ -356,13 +390,6 @@ again: return NULL; } - /* POSIX-like - always request case-sensitivity by default. */ - if (smbc_getOptionCaseSensitive(context)) { - cli_set_case_sensitive(c, True); - } else { - cli_set_case_sensitive(c, False); - } - if (smbc_getOptionUseKerberos(context)) { c->use_kerberos = True; } @@ -377,7 +404,7 @@ again: * Force use of port 139 for first try if share is $IPC, empty, or * null, so browse lists can work */ - if (share == NULL || *share == '\0' || strcmp(share, "IPC$") == 0) { + if (share == NULL || *share == '\0' || is_ipc) { port_try_first = 139; port_try_next = 445; } else { @@ -483,6 +510,34 @@ again: DEBUG(4,(" tconx ok\n")); + /* Determine if this share supports case sensitivity */ + if (is_ipc) { + DEBUG(4, ("IPC$ so ignore case sensitivity\n")); + } else if (!cli_get_fs_attr_info(c, &fs_attrs)) { + DEBUG(4, ("Could not retrieve case sensitivity flag: %s.\n", + cli_errstr(c))); + + /* + * We can't determine the case sensitivity of the share. We + * have no choice but to use the user-specified case + * sensitivity setting. + */ + if (smbc_getOptionCaseSensitive(context)) { + cli_set_case_sensitive(c, True); + } else { + cli_set_case_sensitive(c, False); + } + } else { + DEBUG(4, ("Case sensitive: %s\n", + (fs_attrs & FILE_CASE_SENSITIVE_SEARCH + ? "True" + : "False"))); + cli_set_case_sensitive(c, + (fs_attrs & FILE_CASE_SENSITIVE_SEARCH + ? True + : False)); + } + if (context->internal->smb_encryption_level) { /* Attempt UNIX smb encryption. */ if (!NT_STATUS_IS_OK(cli_force_encryption(c, -- cgit