Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1156391

Summary: netbios name truncating doesn't work
Product: Red Hat Enterprise Linux 7 Reporter: Robin Hack <rhack>
Component: sambaAssignee: Andreas Schneider <asn>
Status: CLOSED ERRATA QA Contact: Robin Hack <rhack>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.1CC: asn, gdeschner, jarrpa, sbose
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: samba-4.1.12-6.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-03-05 09:23:33 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
My smb.conf none

Description Robin Hack 2014-10-24 11:25:29 UTC
Created attachment 950329 [details]
My smb.conf

Cut and paste from upstream bugzilla:

Hi.

It looks like nmbd cripples netbios name is too long and needs to be truncate.

[global]
	netbios name = Xabcdefghijklmnopqrstuvwxyz

Logs:

(most interesting are parts with:
Oct 24 07:10:20 unused-4-106 nmbd[20240]: register_name: NetBIOS name XABCDEFGHIJKLMNOPQRSTUVWXYZ is too long. Truncating to (yes here is nothing)
Oct 24 07:10:43 unused-4-106 nmbd[20240]: Samba name server XABCDEFGHIJKLMNOPQRSTUVWXYZ is now a local master browser for workgroup APPLEGROUP on subnet 192.168.254.76


Oct 24 07:10:20 unused-4-106 nmbd[20239]: [2014/10/24 07:10:20.840695,  0, pid=20239, effective(0, 0), real(0, 0)] ../source3/nmbd/nmbd.c:945(main)
Oct 24 07:10:20 unused-4-106 nmbd[20239]: standard input is not a socket, assuming -D option
Oct 24 07:10:20 unused-4-106 nmbd[20240]: [2014/10/24 07:10:20.845337,  0, pid=20240, effective(0, 0), real(0, 0)] ../source3/nmbd/nmbd_nameregister.c:492(register_name)
Oct 24 07:10:20 unused-4-106 nmbd[20240]: register_name: NetBIOS name XABCDEFGHIJKLMNOPQRSTUVWXYZ is too long. Truncating to
Oct 24 07:10:20 unused-4-106 nmbd[20240]: [2014/10/24 07:10:20.845485,  0, pid=20240, effective(0, 0), real(0, 0)] ../source3/nmbd/nmbd_nameregister.c:492(register_name)
Oct 24 07:10:20 unused-4-106 nmbd[20240]: register_name: NetBIOS name XABCDEFGHIJKLMNOPQRSTUVWXYZ is too long. Truncating to
Oct 24 07:10:20 unused-4-106 nmbd[20240]: [2014/10/24 07:10:20.845623,  0, pid=20240, effective(0, 0), real(0, 0)] ../source3/nmbd/nmbd_nameregister.c:492(register_name)
Oct 24 07:10:20 unused-4-106 nmbd[20240]: register_name: NetBIOS name XABCDEFGHIJKLMNOPQRSTUVWXYZ is too long. Truncating to
Oct 24 07:10:20 unused-4-106 nmbd[20240]: [2014/10/24 07:10:20.846109,  0, pid=20240, effective(0, 0), real(0, 0)] ../source3/nmbd/nmbd_nameregister.c:492(register_name)
Oct 24 07:10:20 unused-4-106 nmbd[20240]: register_name: NetBIOS name XABCDEFGHIJKLMNOPQRSTUVWXYZ is too long. Truncating to
Oct 24 07:10:20 unused-4-106 nmbd[20240]: [2014/10/24 07:10:20.846220,  0, pid=20240, effective(0, 0), real(0, 0)] ../source3/nmbd/nmbd_nameregister.c:492(register_name)
Oct 24 07:10:20 unused-4-106 nmbd[20240]: register_name: NetBIOS name XABCDEFGHIJKLMNOPQRSTUVWXYZ is too long. Truncating to
Oct 24 07:10:20 unused-4-106 nmbd[20240]: [2014/10/24 07:10:20.846333,  0, pid=20240, effective(0, 0), real(0, 0)] ../source3/nmbd/nmbd_nameregister.c:492(register_name)
Oct 24 07:10:20 unused-4-106 nmbd[20240]: register_name: NetBIOS name XABCDEFGHIJKLMNOPQRSTUVWXYZ is too long. Truncating to
Oct 24 07:10:20 unused-4-106 nmbd[20240]: [2014/10/24 07:10:20.849986,  0, pid=20240, effective(0, 0), real(0, 0)] ../lib/util/become_daemon.c:136(daemon_ready)
Oct 24 07:10:20 unused-4-106 nmbd[20240]: STATUS=daemon 'nmbd' finished starting up and ready to serve connectionsread_udp_v4_socket: ip 192.168.254.76 port 35072 read: 68
Oct 24 07:10:20 unused-4-106 systemd: Started Samba NMB Daemon.
Oct 24 07:10:43 unused-4-106 nmbd[20240]: [2014/10/24 07:10:43.934065,  0, pid=20240, effective(0, 0), real(0, 0)] ../source3/nmbd/nmbd_become_lmb.c:397(become_local_master_stage2)
Oct 24 07:10:43 unused-4-106 nmbd[20240]: *****
Oct 24 07:10:43 unused-4-106 nmbd[20240]: 
Oct 24 07:10:43 unused-4-106 nmbd[20240]: Samba name server XABCDEFGHIJKLMNOPQRSTUVWXYZ is now a local master browser for workgroup APPLEGROUP on subnet 192.168.254.76
Oct 24 07:10:43 unused-4-106 nmbd[20240]: 
Oct 24 07:10:43 unused-4-106 nmbd[20240]: *****
Oct 24 07:10:43 unused-4-106 nmbd[20240]: [2014/10/24 07:10:43.935006,  0, pid=20240, effective(0, 0), real(0, 0)] ../source3/nmbd/nmbd_become_lmb.c:397(become_local_master_stage2)
Oct 24 07:10:43 unused-4-106 nmbd[20240]: *****
Oct 24 07:10:43 unused-4-106 nmbd[20240]: 
Oct 24 07:10:43 unused-4-106 nmbd[20240]: Samba name server XABCDEFGHIJKLMNOPQRSTUVWXYZ is now a local master browser for workgroup APPLEGROUP on subnet 10.34.4.106
Oct 24 07:10:43 unused-4-106 nmbd[20240]: 
Oct 24 07:10:43 unused-4-106 nmbd[20240]: *****

Analyse:
source3/nmbd/nmbd_nameregister.c:

# gdb --args nmbd -F -d 10 -S
(gdb) break register_name
(gdb) run

    477 void register_name(struct subnet_record *subrec,
    478                    const char *name, int type, uint16 nb_flags,
    479                    register_name_success_function success_fn,
    480                    register_name_fail_function fail_fn,
    481                    struct userdata_struct *userdata)
    482 {
    483         struct nmb_name nmbname;
    484         nstring nname;
    485 
    486         errno = 0;
    487         push_ascii_nstring(nname, name);

(gdb) print nname
$1 = "\000ABCDEFGHIJKLMNO"
(gdb) print name
$2 = 0x55555579bdf0 "XABCDEFGHIJKLMNOPQRSTUVWXYZ"

... errno is E2BIG ...

    488         if (errno == E2BIG) {
    489                 unstring tname;
    490                 pull_ascii_nstring(tname, sizeof(tname), nname);

(gdb) print nname
$4 = "\000ABCDEFGHIJKLMNO"
(gdb) print tname
$5 = "\000\000\000\000\000\000\000\000\373\254\242\364\377\177\000\000L\000\000\000UU\000\000\220\234yUUU\000\000\220\234yUUU\000\000\000HE\250\362\277\230:\220\234yUUU\000\000\060\356yUUU\000"

    491                 DEBUG(0,("register_name: NetBIOS name %s is too long. Truncating to %s\n",
    492                         name, tname));
    493                 make_nmb_name(&nmbname, tname, type);

(gdb) print nmbname
$7 = {name = '\000' <repeats 15 times>, scope = '\000' <repeats 63 times>, name_type = 32}

    494         } else {
    495                 make_nmb_name(&nmbname, name, type);
    496         }

Comment 2 Andreas Schneider 2014-10-27 16:24:04 UTC
This happens cause the commit d546adeab54af123eff66cee61a487c88b6ba61b changed the behaviour of the push_ascii_nstring() function. Need to talk to jra.

Comment 6 errata-xmlrpc 2015-03-05 09:23:33 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2015-0409.html