samba-in-kubernetes / samba-operator

An operator for a Samba as a service on PVCs in kubernetes
Apache License 2.0
120 stars 24 forks source link

Fix annoying 'dos charset 'CP850' unavailable' warnings #226

Closed phlogistonjohn closed 2 years ago

phlogistonjohn commented 2 years ago

Tools like smbclient and net are generating dos charset warnings when run. Looks somewhat like:

# smbclient -U foo -L //localhost
lp_load_ex: changing to config backend registry
Password for [WORKGROUP\foo]:
dos charset 'CP850' unavailable - using ASCII                      <-------- HERE
session setup failed: NT_STATUS_LOGON_FAILURE

It's minor but unnecessary as it can be eliminated by setting an smb.conf option (dos charset AFAICT). Let's set that option and eliminate an annoyance.

gd commented 2 years ago

We can certainly do that but I am wondering why the CP850 codepage (which is typically compiled in) is not available in the first place.

phlogistonjohn commented 2 years ago

Let me know if there are any commands we can run to investigate. Otherwise, I'd like to try and squish the annoying message and then we can open a new issue to investigate deeper.

anoopcs9 commented 2 years ago

We can certainly do that but I am wondering why the CP850 codepage (which is typically compiled in) is not available in the first place.

I dug into this little deeper and here are my findings:

CP850 and IBM850 can be used interchangeably as they are aliases to each other.

charset detection is mostly driven by an on-demand initialization function _get_convhandle() in Samba which basically attempts to find DEFAULT_DOS_CHARSET(CP850) unless explicitly specified via dos charset smb.conf option. DEFAULT_DOS_CHARSET is a compile/build time macro defined to indicate the charset found. Further in its absence DEFAULT_DOS_CHARSET is set to ASCII.

I verified using sample program that independent library files, in this case for IBM850, are required for individual charsets. In Fedora glibc-gconv-extra package provides IBM850.so. Even though Samba rpms are built with IBM850 our smbclient images based on CentOS Stream 8(and server images based on Fedora 35 too) doesn't have this package installed by default and thus we end up with the warning for smbclient(and in server logs).

phlogistonjohn commented 2 years ago

Wow. Love the in depth analysis @anoopcs9. Between all that, and this seems very much an smb1 thing I'm strongly in favor of suppressing the error message by defaulting to ascii. Hopefully as samba continues to deprecate/drop support for smb1 this goes away entirely.

In the meantime I'm planning on merging #229 later today unless I hear some clear NAKs.

synarete commented 2 years ago

@anoopcs9 Impressive!