Cherry-pick a samba fix.

https://attachments.samba.org/attachment.cgi?id=9671

Which is linked from this samba bug:

https://bugzilla.samba.org/show_bug.cgi?id=10415

Possibly related to:

Ticket: #4285