Bug 11791 - NetBIOS name truncation to 15 characters not used everywhere
Summary: NetBIOS name truncation to 15 characters not used everywhere
Status: NEW
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: File services (show other bugs)
Version: 4.1.23
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Samba QA Contact
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-03-14 08:41 UTC by Steffe
Modified: 2016-03-14 08:41 UTC (History)
0 users

See Also:


Attachments
Logs (3.03 KB, application/zip)
2016-03-14 08:41 UTC, Steffe
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Steffe 2016-03-14 08:41:32 UTC
Created attachment 11916 [details]
Logs

If your computer has a long (>15 characters) host name, it needs to be truncated to be used as NetBIOS name. This worked fine in Samba 3, but seems broken in Samba 4.1 despite a bunch of patches on the subject.

For the following test, I have set "netbios name = thisisaverylonghostname" in smb.conf, then I do "nmbd -d 3 -i"

On Samba 4.1.23, I get the following result (some details left out):

root@accc8e35fce4:/mnt/flash/etc/samba# nmbd -d3 -i
nmbd version 4.1.23 started.
...
add_name_to_subnet: Added netbios name *<00> with first IP 192.168.0.232 ttl=0 nb_flags= 0 to subnet 192.168.0.232
add_name_to_subnet: Added netbios name *<20> with first IP 192.168.0.232 ttl=0 nb_flags= 0 to subnet 192.168.0.232
add_name_to_subnet: Added netbios name __SAMBA__<20> with first IP 192.168.0.232 ttl=0 nb_flags= 0 to subnet 192.168.0.232
add_name_to_subnet: Added netbios name __SAMBA__<00> with first IP 192.168.0.232 ttl=0 nb_flags= 0 to subnet 192.168.0.232
create_server_on_workgroup: Created server entry THISISAVERYLONG of type 40809a03 (Samba 4.1.23) on workgroup WORKGROUP.
initiate_myworkgroup_startup: Added server name entry THISISAVERYLONG on subnet 192.168.0.232
...
check_for_master_browser_fail: Forcing election on workgroup WORKGROUP subnet 192.168.0.232
check_elections: >>> Starting election for workgroup WORKGROUP on subnet 192.168.0.232 <<<
write_browse_list: Wrote browse list into file /var/lib/samba/browse.dat
send_election_dgram: Sending election packet for workgroup WORKGROUP on subnet 169.254.184.146
E2BIG: convert_string(UTF-8,ASCII): srclen=24 destlen=16 - 'THISISAVERYLONGHOSTNAME'
send_election_dgram: Sending election packet for workgroup WORKGROUP on subnet 192.168.0.232
...
run_elections: >>> Won election for workgroup WORKGROUP on subnet 192.168.0.232 <<<
become_local_master_browser: Error - cannot find server THISISAVERYLONGHOSTNAME in workgroup WORKGROUP on subnet 192.168.0.232

<theory>It first registers its name with the string "THISISAVERYLONG" which is the truncated version of the netbios name. It then runs the election using "THISISAVERYLONGHOSTNAME" which is the non-truncated version of the netbios name. It wins the election, but then it is unable to find the master browser, because it is specified as "THISISAVERYLONGHOSTNAME", and we can not look that name up since we have registered "THISISAVERYLONG" as the actual name.</theory>

In this example I set the netbios name manually in smb.conf, but this problem happens on servers where the host name is longer than 15 characters.

I have also reproduced this on Samba 4.3.3. If I step down to Samba 3.6.24, the truncated version of the netbios name is used in both places, and everything works great!

I have attached full logs both from Samba 4.1.23 and Samba 3.6.24, if you compare them, you can see the difference in how Samba 3 and Samba 4.1 uses the netbios names, and that it is successful in one of the cases but not in the other.

// Steffe