unicode conversion of libsmb/

Andrew Tridgell tridge at samba.org
Wed Feb 21 04:28:23 GMT 2001


I've just completed a unicode conversion of the cli_ SMB client
library in the head branch. All our client code should now try to
negotiate unicode if the server supports it. For debugging you can
force ascii by setting an environment variable CLI_FORCE_ASCII

The main reason for this email is to discuss the method I used and the
possible applicability of the method to the Samba server code. What I
did was to replace code like this:

        pstrcpy(p,user);
        unix_to_dos(p,True);
	strupper(p);

with this:

	p += clistr_push(cli, p, user, -1, CLISTR_CONVERT|CLISTR_UPPER|CLISTR_TERMINATE);

then there is a similar function clistr_pull() that pulls strings out
of packets. These functions determine whether unicode should be used
based on the negotiated capabilities of the server. The clistr_*
functions also handle any alignment that is necessary.

This method only does on-the-wire unicode. Internally everything is
still stored in unix code page ascii. It also doesn't solve our string
allocation nightmare. I took this approach because I decided that
approaching these 3 problems separately would make each tractable in a
reasonable amount of time, whereas we have previously tried to solve
all 3 at once and got a bit stuck.

The next possible steps are:

- apply a similar method to converting the on-the-wire format in smbd
- think about internal storage of unicode in the client code
- think about fixing the pstring/fstring stack allocation

I'd also appreciate it if people could test the
smbclient/smbpasswd/smbcacls etc utils in head and make sure they
still work for you. With NT as a server they should use unicode. With
Samba they will use ascii.

Cheers, Tridge




More information about the samba-technical mailing list