I noticed machines with a description that contains one apostrophe (') were neither displayed in the Windows network neighbourhood nor smbclient -L //PDC listed them anymore since I updated to samba 3. I analyzed the problem. It traced down to the following change from samba 2.2.x to 3.0 in lib/util_str.c:next_token(): - if (*s == '\"') { + if (*s == '\"' || *s == '\'') { quoted = !quoted; } else { len++; *pbuf++ = *s; } This function is used in lanman.c:get_server_info(), to tokenize lines from browse.dat. My browse.dat contained: "KANGAROO" 40011003 "Peter's Workstation" "MAIN" This caused the line to be tokenized incorrectly into <KANGAROO> <40011003> <Peters> <Workstation MAIN> instead of <KANGAROO> <40011003> <Peter's Workstation> <MAIN>. This caused !strequal(domain, s->domain) (ie !strequal("MAIN", "Workstation MAIN")) in lanman.c:get_server_info() to be true, so it set ok = False, which finally caused the entry to be omitted from the server list. This bug might cause other severe problems in code that uses next_token(). Suggestion: a) investigate if ' is really required as a quote char. b) if yes, make sure ' is only balanced by another ', not ", and " only by ", not ', for example (code has not been tested): - BOOL quoted; + int qchar = 0; ... - if (*s == '\"' || *s == '\'') { - quoted = !quoted; + if ((*s == '\"' || *s == '\'') && (!qchar || qchar == *s)) { + qchar = !qchar ? *s : 0; } else { len++; *pbuf++ = *s; } c) if no, revert back to 2.2 code: - if (*s == '\"' || *s == '\'') { + if (*s == '\"') { quoted = !quoted; } else { len++; *pbuf++ = *s; } The workaround is, of course, to remove ' characters from machine descriptions.
*** Bug 1004 has been marked as a duplicate of this bug. ***
*** Bug 989 has been marked as a duplicate of this bug. ***
*** Bug 1420 has been marked as a duplicate of this bug. ***
I'm reverting the original change to next_token() and changing print_parameter() to surround values in a list with " "s rather than ' 's. I think this is the easiest solution.
Only fixes the single quote instance of the bug. If I change the name of my computer to Peter"s Workstation (with double instead of single quoted) the problem reappears. A possible solution is to escape the quotes ala Peter\"s workstation before writing wins.dat and then unescaping in lib/util_str.c:next_token().
I've been having a single quote problem with smbclient 3.0.2a, similar to this. If I try to do any operations (ls, get, cd, etc) on a file whose name contains a single quote in the interactive smbclient, the interpreter discards my single quote. I can't seem to make any way of escaping it work. I've tried the backslash, enclosing it in double quotes, everything I can think of. The patch listed here seems to fix the problem, but I'm not sure what else it might break.
jeremy, still want to fix this? Thanks.
Can we get this bug fix into the next release? I have software that uses smbclient and depends on this fix, so it's kind of a pain when I have to patch smbclient on every host I install my software on.
If it's still broken in 3.5, please reopen. 3.0 isn't supported anymore.