# I have the worst luck with Samba. Why?



## Xenomorph (Apr 24, 2015)

The packaged/binary install of samba36 lacks ADS (a "Windows compatible" file server that lacks Windows authentication?), so I had to manually compile it.

The Samba 3.6 setup has worked for me for around ~2 years. However, I tried to move to Samba 4.1 not too long ago, just to make sure that I was up to date and got all the security fixes.

I found that even though net/samba41 includes ADS, it does NOT include the actual modules for it to work with id mapping!
I submitted a bug here:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=197320

I tried to build net/samba41, including several options such as building the "experimental" modules, but also selecting the DEVELOPER option causes it to fail. I submitted another bug:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=194046

Once I get net/samba41 built (without "DEVELOPER"), an update then came out that seemed to break how winbindd starts in /etc/rc.conf. Another bug report submitted:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=198064

The next issue is that some Mac users as well as Windows XP and Windows 2003 users were causing Samba 4.1 and eventually FreeBSD 9.3 to *hang*.

I tried to kill the Samba service, but then I'd run `#  ps aux | grep smb` and see a bunch of stuck processes.

```
myname  2099  0.0  0.0 348732 13352 ??  D  13Apr15  50:35.96 /usr/local/sbin/smbd --daemon --configfile=/usr/local/etc/smb4.conf
```
(D state = "uninterruptible sleep")

I couldn't kill the process or reboot the server. I'd have to hold power to shut off the server.

The Samba logs had no errors, but /var/log/messages had stuff like this over and over:


```
Apr 23 11:07:30 server smbd[8763]: [2015/04/23 11:07:30.315978,  0] ../source3/smbd/reply.c:3119(sendfile_short_send)
Apr 23 11:07:30 server smbd[8763]:  sendfile_short_send: filling truncated file home/user/desktop.ini with zeros !
```

I Googled sendfile_short_send and didn't find ANY other users mentioning that message.

So, I decided to pull Samba 4.1 and install net/samba40. During its build it listed dozens of errors. Apparently some dependencies were not fulfilled by portmaster. No, I did not write down the errors. I was getting a little frustrated and just decided to go back to Samba 3.6.

Build options for Samba 3.6 changed as well! _It didn't work like it did only a few weeks ago._

While I had no issue installing Samba 3.6.24 in the past, trying to build Samba 3.6.25 gives multiple issues.

First:


```
samba36-3.6.25 ADS support requires GSSAPI_BASE, GSSAPI_HEIMDAL, or GSSAPI_MIT.
```

That wasn't an issue in 3.6.24. Going with GSSAPI_BASE seemed to work.

But alas, idmapping wasn't working!

/usr/local/lib/samba/idmap/ad.so was missing, the same file that the Samba 4.1 installation lacked!

You now have to compile Samba 3.6 with the EXP_MODULES option if you want ADS to work. This wasn't the case before.

When did the EXP_MODULES option change? When did the GSSAPI_BASE/kerberos option change?

I saw nothing in /usr/ports/UPDATING about that.

Basically, I'd consider net/samba36, net/samba4, and net/samba41 all broken. Their default build options result in a system that lacks AD authentication, default build options changed between releases, in the case of net/samba4 it doesn't even seem to build, in the case of net/samba41 its functionality after built doesn't match its documentation (such as _not_ requiring winbindd being set in /etc/rc.conf), and net/samba41 has the ability to bring down a FreeBSD 9.3 system.

Why have I had so much bad luck with this? Does this stuff really work flawlessly for everyone else?

Is there somewhere that I can read about the changes that take place with the default build options between samba3.6.24 and samba3.6.25?


----------



## Oko (Apr 25, 2015)

I am not using Samba but this is how I would approach the problem. I would suggest you pick up a spare machine and install FreeNAS 9.3. FreeNAS people have put lots of work into Samba and ironing out the problems you are talking about between 9.2 and 9.3 releases. I am luring/posting on their forums and I saw lots of posts like yours until things have stabilized on 9.2.1.9 which was last 9.2.xxx release. Test your Windows clients with FreeNAS. If FreeNAS works for you dig deep into their Samba configuration files (they use samba41) and use those to reconfigure your vanilla FreeBSD servers. I have two of their turn-key FreeNAS servers in production. While at the beginning it was really helpful what they have done and made deployment easier now it is making my life very difficult (their NFS sever is just sub par) and I wish I have not used turn-key appliance. I have 5 vanilla FreeBSD servers and I could not be happier.

BTW Apple has its own "AFS" network file system (not to be mistaken with AFS which stands for Andrew File System). I have no idea how that shit works but Apple should be able to use NFS without any problems.


----------



## Xenomorph (May 20, 2015)

I haven't tested FreeNAS yet, but I did set up a new FreeBSD 10.1 server w/ Samba 4.1.17.

I figured the issue I had with Samba 4.1 was with FreeBSD 9.3. Nope, same thing was happening with the same clients connecting (Windows XP, Windows 2003, Mac OS X). The server was saying the same thing.

In /var/log/messages:


```
May 20 12:59:41 server smbd[2126]: [2015/05/20 12:59:41.177140,  0] ../source3/smbd/reply.c:3119(sendfile_short_send)
May 20 12:59:41 server smbd[2126]:  sendfile_short_send: filling truncated file data/share/slides.pptx with zeros !
```

Searching for "filling truncated file" still didn't get me any answers. I found this link from 2009:
https://lists.samba.org/archive/samba-cvs/2009-January/089268.html

The snippet of code has a comment that says it is for dealing with "sendfile". I did have "use sendfile = yes" in my config, as part of a "performance recommendation" that I've seen many times. I'm using it on my Samba 3.6 setups, as well.

I don't know if it's the cause, but I removed the "use sendfile" line in my config (it defaults to "no"), restarted the server, and it seems like I can copy/move files without issue. *So far*. I need to test this some more.

Edit, I found some hit saying that "use sendfile" is broken:
https://lists.freebsd.org/pipermail/freebsd-ports/2014-March/091162.html
https://forums.freenas.org/index.ph...rename-delete-play-video-but-cant-copy.24747/

I'm still not sure it is the cause of my issues, but I'm hoping it's fixed by leaving it off.


----------



## soupbowl (Jun 4, 2015)

Sorry, did not see this post for awhile, but I had the same issue and it is caused by the broken send_file, disabling it will remove the issues. But slow down the speeeds


----------

