summaryrefslogtreecommitdiff
path: root/source3/libsmb
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2009-01-18 16:19:39 +0100
committerJelmer Vernooij <jelmer@samba.org>2009-01-18 16:19:39 +0100
commitbfbb0fb17f4eedb8f22d0694c5d4a3b82dfe189b (patch)
tree068b3849e31c7b90a465be8172aac7c2b472d205 /source3/libsmb
parent5cf9989a70a23e5b955b7229fa95d3e604b1883d (diff)
parentc45b6ec29a5b3a39b83209e970b645e5ed0a411c (diff)
downloadsamba-bfbb0fb17f4eedb8f22d0694c5d4a3b82dfe189b.tar.gz
samba-bfbb0fb17f4eedb8f22d0694c5d4a3b82dfe189b.tar.bz2
samba-bfbb0fb17f4eedb8f22d0694c5d4a3b82dfe189b.zip
Merge branch 'master' of ssh://git.samba.org/data/git/samba
Diffstat (limited to 'source3/libsmb')
-rw-r--r--source3/libsmb/libsmb_context.c1
-rw-r--r--source3/libsmb/libsmb_dir.c2
-rw-r--r--source3/libsmb/libsmb_path.c10
-rw-r--r--source3/libsmb/libsmb_server.c64
-rw-r--r--source3/libsmb/libsmb_setget.c26
5 files changed, 96 insertions, 7 deletions
diff --git a/source3/libsmb/libsmb_context.c b/source3/libsmb/libsmb_context.c
index 66329e2860..c2c33e5302 100644
--- a/source3/libsmb/libsmb_context.c
+++ b/source3/libsmb/libsmb_context.c
@@ -69,6 +69,7 @@ smbc_new_context(void)
smbc_setOptionFullTimeNames(context, False);
smbc_setOptionOpenShareMode(context, SMBC_SHAREMODE_DENY_NONE);
smbc_setOptionSmbEncryptionLevel(context, SMBC_ENCRYPTLEVEL_NONE);
+ smbc_setOptionCaseSensitive(context, False);
smbc_setOptionBrowseMaxLmbCount(context, 3); /* # LMBs to query */
smbc_setOptionUrlEncodeReaddirEntries(context, False);
smbc_setOptionOneSharePerServer(context, False);
diff --git a/source3/libsmb/libsmb_dir.c b/source3/libsmb/libsmb_dir.c
index 770014b6f6..e9b7b4f95a 100644
--- a/source3/libsmb/libsmb_dir.c
+++ b/source3/libsmb/libsmb_dir.c
@@ -895,7 +895,7 @@ smbc_readdir_internal(SMBCCTX * context,
/* url-encode the name. get back remaining buffer space */
max_namebuf_len =
- SMBC_urlencode(dest->name, src->name, max_namebuf_len);
+ smbc_urlencode(dest->name, src->name, max_namebuf_len);
/* We now know the name length */
dest->namelen = strlen(dest->name);
diff --git a/source3/libsmb/libsmb_path.c b/source3/libsmb/libsmb_path.c
index 2c3a5f8866..6d69924231 100644
--- a/source3/libsmb/libsmb_path.c
+++ b/source3/libsmb/libsmb_path.c
@@ -41,7 +41,7 @@ hex2int( unsigned int _char )
}
/*
- * SMBC_urldecode()
+ * smbc_urldecode()
* and urldecode_talloc() (internal fn.)
*
* Convert strings of %xx to their single character equivalent. Each 'x' must
@@ -122,7 +122,7 @@ urldecode_talloc(TALLOC_CTX *ctx, char **pp_dest, const char *src)
}
int
-SMBC_urldecode(char *dest,
+smbc_urldecode(char *dest,
char *src,
size_t max_dest_len)
{
@@ -138,7 +138,7 @@ SMBC_urldecode(char *dest,
}
/*
- * SMBC_urlencode()
+ * smbc_urlencode()
*
* Convert any characters not specifically allowed in a URL into their %xx
* equivalent.
@@ -146,7 +146,7 @@ SMBC_urldecode(char *dest,
* Returns the remaining buffer length.
*/
int
-SMBC_urlencode(char *dest,
+smbc_urlencode(char *dest,
char *src,
int max_dest_len)
{
@@ -286,7 +286,7 @@ SMBC_parse_path(TALLOC_CTX *ctx,
DEBUG(4, ("Found options '%s'", q));
/* Copy the options */
- if (*pp_options != NULL) {
+ if (pp_options && *pp_options != NULL) {
TALLOC_FREE(*pp_options);
*pp_options = talloc_strdup(ctx, q);
}
diff --git a/source3/libsmb/libsmb_server.c b/source3/libsmb/libsmb_server.c
index f4714346d1..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
@@ -370,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 {
@@ -476,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,
diff --git a/source3/libsmb/libsmb_setget.c b/source3/libsmb/libsmb_setget.c
index d0823bd77e..9de49a5b3f 100644
--- a/source3/libsmb/libsmb_setget.c
+++ b/source3/libsmb/libsmb_setget.c
@@ -194,6 +194,32 @@ smbc_setOptionSmbEncryptionLevel(SMBCCTX *c, smbc_smb_encrypt_level level)
}
/**
+ * Get whether to treat file names as case-sensitive if we can't determine
+ * when connecting to the remote share whether the file system is case
+ * sensitive. This defaults to FALSE since it's most likely that if we can't
+ * retrieve the file system attributes, it's a very old file system that does
+ * not support case sensitivity.
+ */
+smbc_bool
+smbc_getOptionCaseSensitive(SMBCCTX *c)
+{
+ return c->internal->case_sensitive;
+}
+
+/**
+ * Set whether to treat file names as case-sensitive if we can't determine
+ * when connecting to the remote share whether the file system is case
+ * sensitive. This defaults to FALSE since it's most likely that if we can't
+ * retrieve the file system attributes, it's a very old file system that does
+ * not support case sensitivity.
+ */
+void
+smbc_setOptionCaseSensitive(SMBCCTX *c, smbc_bool b)
+{
+ c->internal->case_sensitive = b;
+}
+
+/**
* Get from how many local master browsers should the list of workgroups be
* retrieved. It can take up to 12 minutes or longer after a server becomes a
* local master browser, for it to have the entire browse list (the list of