# Samba48 don't work on FreeBSD 11.1



## herpestes (May 24, 2018)

On the FreeBSD 9.x server, I had samba installed. Then I updated the server to version 10.4, then 11.1 and I can not run samba 48.
How to install from ports I have an error: 

```
[3314/3839] Linking default/nsswitch/libpamwinbind.so
runner cc default/lib/util/tiniparser_5.o default/lib/util/tini_4.o default/nsswitch/pam_winbind_15.o -o /usr/ports/net/samba48/work/samba-4.8.0/bin/default/nsswitch/libpamwinbind.so -L/usr/local/lib -fstack-protector -Wl,-z,relro,-z,now -lpthread -Wl,-no-undefined -Wl,--export-dynamic -Wl,--as-needed -shared -Ldefault/lib/replace -Ldefault/nsswitch -Ldefault/nsswitch/libwbclient -Wl,-Bdynamic -lwbclient -lwinbind-client-samba4 -lreplace-samba4 -lrt -lcrypt -ltalloc -lpam
default/nsswitch/pam_winbind_15.o: In function `_pam_winbind_init_context':
/usr/ports/net/samba48/work/samba-4.8.0/bin/../nsswitch/pam_winbind.c:589: undefined reference to `wbcCtxCreate'
default/nsswitch/pam_winbind_15.o: In function `winbind_upn_to_username':
/usr/ports/net/samba48/work/samba-4.8.0/bin/../nsswitch/pam_winbind.c:2476: undefined reference to `wbcCtxLookupName'
/usr/ports/net/samba48/work/samba-4.8.0/bin/../nsswitch/pam_winbind.c:2483: undefined reference to `wbcCtxLookupSid'
default/nsswitch/pam_winbind_15.o: In function `winbind_auth_request':
/usr/ports/net/samba48/work/samba-4.8.0/bin/../nsswitch/pam_winbind.c:1834: undefined reference to `wbcCtxLogonUser'
default/nsswitch/pam_winbind_15.o: In function `_pam_delete_cred':
/usr/ports/net/samba48/work/samba-4.8.0/bin/../nsswitch/pam_winbind.c:2588: undefined reference to `wbcCtxLogoffUserEx'
default/nsswitch/pam_winbind_15.o: In function `valid_user':
/usr/ports/net/samba48/work/samba-4.8.0/bin/../nsswitch/pam_winbind.c:2086: undefined reference to `wbcCtxGetpwnam'
default/nsswitch/pam_winbind_15.o: In function `winbind_chauthtok_request':
/usr/ports/net/samba48/work/samba-4.8.0/bin/../nsswitch/pam_winbind.c:1978: undefined reference to `wbcCtxChangeUserPasswordEx'
default/nsswitch/pam_winbind_15.o: In function `_pam_winbind_free_context':
/usr/ports/net/samba48/work/samba-4.8.0/bin/../nsswitch/pam_winbind.c:552: undefined reference to `wbcCtxFree'
default/nsswitch/pam_winbind_15.o: In function `winbind_get_separator':
/usr/ports/net/samba48/work/samba-4.8.0/bin/../nsswitch/pam_winbind.c:2417: undefined reference to `wbcCtxInterfaceDetails'
default/nsswitch/pam_winbind_15.o: In function `winbind_name_to_sid_string':
/usr/ports/net/samba48/work/samba-4.8.0/bin/../nsswitch/pam_winbind.c:1116: undefined reference to `wbcCtxLookupName'
cc: error: linker command failed with exit code 1 (use -v to see invocation)
Waf: Leaving directory `/usr/ports/net/samba48/work/samba-4.8.0/bin'
Build failed:  -> task failed (err #1):
        {task: cc_link tiniparser_5.o,tini_4.o,pam_winbind_15.o -> libpamwinbind.so}
  File "buildtools/bin/waf", line 76, in <module>
        Scripting.prepare(t, cwd, VERSION, wafdir)
  File "/usr/ports/net/samba48/work/samba-4.8.0/third_party/waf/wafadmin/Scripting.py", line 147, in prepare
        error(str(e))
*** Error code 1

Stop.
make[1]: stopped in /usr/ports/net/samba48
*** Error code 1

Stop.
make: stopped in /usr/ports/net/samba48
```

In turn installing the "pkg install samba48" command, the package installs, but it can not be started, an error occurs: 


```
root@srv:/ # /usr/local/etc/rc.d/samba_server start
Performing sanity check on Samba configuration: FAILED
```

What can I do to run any version of samba? Where to look for a problem? 

Thanks for help


----------



## SirDice (May 24, 2018)

herpestes said:


> On the FreeBSD 9.x server, I had samba installed. Then I updated the server to version 10.4, then 11.1 and I can not run samba 48.


After all those major upgrades, did you reinstall _every_ package/port you have installed?

Really quick and dirty solution: `pkg-static install -f pkg` and `pkg upgrade -f`



herpestes said:


> ```
> root@srv:/ # /usr/local/etc/rc.d/samba_server start
> Performing sanity check on Samba configuration: FAILED
> ```


That looks like a fairly obvious error. You have a problem in your /usr/local/etc/smb4.conf, did you create one?


----------



## ShelLuser (May 24, 2018)

Did you re-install all the ports after you did the major upgrade?  So: when you went from 9 to 10 and then from 10 to 11?  If the answer is no then that's the cause of your problem.

Also: don't mix ports and packages. That only creates more problems, especially if you changed any building options for the ports.

I would try to re-build Samba and all of its dependencies using ports-mgmt/portmaster: `# portmaster -f net/samba48`. That could help out to create the environment in which Samba can be build.

After that you may also need to reconfigure Samba, based on how you configured it. However, my theory is that the current reason why Samba doesn't start is because you changed the port configuration somewhere and now your Samba environment is in an inconsistent state.


----------



## herpestes (May 28, 2018)

I've done the above commands and it still does not work (it's the same) - I can not install samba from the ports tree.
I care the most about Samba, is there any way to install samba?

I thought to delete all the ports, copy the configuration files and re-load all ports - all with the portmaster command like this:

```
Using portmaster to do a complete reinstallation of all your ports:
1. portmaster --list-origins> ~ / installed-port-list
2. Update your ports tree
3. portmaster -ty --clean-distfiles
4. portmaster --check-port-dbdir
5. portmaster -Faf
6. pkg_delete -a
7. rm -rf / usr / local / lib / compat / pkg
8. Back up any files in / usr / local you wish to save,
such as configuration files in / usr / local / etc
9. Manually check / usr / local and / var / db / pkg
to make sure that they are really empty
10. Re-install portmaster
11. portmaster `cat ~ / installed-port-list`
```

Is it good idea ?


----------



## SirDice (May 28, 2018)

There's no reason to use the ports. Just install the package and be done: `pkg install samba48`.

And it doesn't matter how many times you reinstall the package, your smb4.conf won't be fixed. It's your responsibility to create a working configuration.


----------



## herpestes (May 28, 2018)

So this error is an error in the smb4.conf configuration file?


```
root@srv:/ # /usr/local/etc/rc.d/samba_server start
Performing sanity check on Samba configuration: FAILED
```

There is some minimal configuration of this file, because I do not see the default samba configuration file in the /usr/local/etc folder ?


----------



## SirDice (May 28, 2018)

There is no default smb4.conf file.


----------



## ShelLuser (May 28, 2018)

herpestes said:


> So this error is an error in the smb4.conf configuration file?


It means that there is some kind of problem with your configuration. That problem could indeed vary from not being present at all to mistakes in the smb4.conf file.

By default Samba sends its logs to syslog, so I'd start there: check for any relevant entries in /var/log/messages.


----------



## herpestes (May 29, 2018)

In /var/log/messages i don't see anything 

My minimal congiguration file is (smb4.conf):


```
[global]

# workgroup = NT-Domain-Name or Workgroup-Name, eg: MIDEARTH
   workgroup =zp2
   server string = Serwer plikow Samba

#   security = user

#   hosts allow = 192.168.4. 127.

#DISABLE PRINTING
   load printers = no
   printing = bsd
   printcap name = /dev/null
   disable spoolss = yes
   log file = /var/log/samba4/log.%m
   max log size = 50
   interfaces = 192.168.4.0/24
   dns proxy = no

#============================ Share Definitions ==============================
[test]
    comment = Test
    path = /home/test
    read only = no
    public = yes


#[homes]
    comment = Home Directories
    browseable = no
```

And now, when i run command:


```
root@ZP2-SRV:/usr/local/etc # testparm
/usr/local/lib/libwbclient.so.0: version WBCLIENT_0.9 required by /usr/local/lib/samba4/private/libgensec-samba4.so not defined

root@ZP2-SRV:/usr/local/etc # sh /usr/local/etc/rc.d/samba_server start
Performing sanity check on Samba configuration: FAILED
```

I don't have any new idea


----------



## ShelLuser (May 30, 2018)

Obviously something went wrong with one of your upgrades. Either from not fully sorting out a a major OS upgrade or, in my opinion more likely: bad ports housekeeping. When you upgrade your ports do you pay attention to /usr/ports/UPDATING?

Anyway, I get the impression that when you installed samba48 as a package it didn't reinstall all its dependencies. Maybe `pkg install -fR samba48`. Then again, you probably don't need -R, I think I might be picking that up wrong.

To get some confirmation try running `ldd /usr/local/lib/samba4/private/libgensec-samba4.so`, see what that tells you. Anything missing in there is most likely caused by a missing Samba dependency.

Also please share the output of `pkg which /usr/local/lib/libwbclient.so.0`.


----------



## SirDice (May 30, 2018)

herpestes said:


> ```
> #[homes]
> comment = Home Directories
> browseable = no
> ```



This is where your problems start. You're assuming that by disabling the header the whole block is disabled. If you want to disable a section you'll have to remark or remove the whole bit not just the header.


----------



## herpestes (Jun 2, 2018)

I have corrected the configuration file and continue with the same error.
I installed the Samba package again with the command "pkg install -fR samba48" and still the same problem.

Command1:

```
ldd /usr/local/lib/samba4/private/libgensec-samba4.so

/usr/local/lib/samba4/private/libgensec-samba4.so:
        libthr.so.3 => /lib/libthr.so.3 (0x28640000)
        libsamba-util.so.0 => /usr/local/lib/samba4/libsamba-util.so.0 (0x28663000)
        libwbclient.so.0 => /usr/local/lib/libwbclient.so.0 (0x281e1000)
        libcom_err-samba4.so.0 => /usr/local/lib/samba4/private/libcom_err-samba4.so.0 (0x281ef000)
        libsamba-modules-samba4.so => /usr/local/lib/samba4/private/libsamba-modules-samba4.so (0x281f2000)
        libgssapi-samba4.so.2 => /usr/local/lib/samba4/private/libgssapi-samba4.so.2 (0x286e6000)
        libtevent-util.so.0 => /usr/local/lib/samba4/libtevent-util.so.0 (0x281f6000)
        libauthkrb5-samba4.so => /usr/local/lib/samba4/private/libauthkrb5-samba4.so (0x28730000)
        libndr-samba-samba4.so => /usr/local/lib/samba4/private/libndr-samba-samba4.so (0x28754000)
        libsamba-errors.so.1 => /usr/local/lib/samba4/libsamba-errors.so.1 (0x289c8000)
        libasn1util-samba4.so => /usr/local/lib/samba4/private/libasn1util-samba4.so (0x28ab5000)
        libsamba-security-samba4.so => /usr/local/lib/samba4/private/libsamba-security-samba4.so (0x28abd000)
        libsamdb.so.0 => /usr/local/lib/samba4/libsamdb.so.0 (0x28ae4000)
        libsamba-debug-samba4.so => /usr/local/lib/samba4/private/libsamba-debug-samba4.so (0x28b07000)
        libsamba-credentials.so.0 => /usr/local/lib/samba4/libsamba-credentials.so.0 (0x28b0e000)
        libsamba-sockets-samba4.so => /usr/local/lib/samba4/private/libsamba-sockets-samba4.so (0x28b27000)
        libcliauth-samba4.so => /usr/local/lib/samba4/private/libcliauth-samba4.so (0x28b46000)
        libtime-basic-samba4.so => /usr/local/lib/samba4/private/libtime-basic-samba4.so (0x281fa000)
        libgenrand-samba4.so => /usr/local/lib/samba4/private/libgenrand-samba4.so (0x281fd000)
        libkrb5samba-samba4.so => /usr/local/lib/samba4/private/libkrb5samba-samba4.so (0x28b62000)
        libndr.so.0 => /usr/local/lib/samba4/libndr.so.0 (0x28b73000)
        libcommon-auth-samba4.so => /usr/local/lib/samba4/private/libcommon-auth-samba4.so (0x28b94000)
        libsamba-hostconfig.so.0 => /usr/local/lib/samba4/libsamba-hostconfig.so.0 (0x28b9f000)
        libmd.so.6 => /lib/libmd.so.6 (0x28bcc000)
        libtalloc.so.2 => /usr/local/lib/libtalloc.so.2 (0x28be7000)
        libtevent.so.0 => /usr/local/lib/libtevent.so.0 (0x28bf2000)
        libc.so.7 => /lib/libc.so.7 (0x28071000)
        libreplace-samba4.so => /usr/local/lib/samba4/private/libreplace-samba4.so (0x28c00000)
        libsocket-blocking-samba4.so => /usr/local/lib/samba4/private/libsocket-blocking-samba4.so (0x28c07000)
        libsys-rw-samba4.so => /usr/local/lib/samba4/private/libsys-rw-samba4.so (0x28c0a000)
        libkrb5-samba4.so.26 => /usr/local/lib/samba4/private/libkrb5-samba4.so.26 (0x28c0e000)
        libroken-samba4.so.19 => /usr/local/lib/samba4/private/libroken-samba4.so.19 (0x28c9a000)
        libasn1-samba4.so.8 => /usr/local/lib/samba4/private/libasn1-samba4.so.8 (0x28cab000)
        libhcrypto-samba4.so.5 => /usr/local/lib/samba4/private/libhcrypto-samba4.so.5 (0x28d5a000)
        libheimbase-samba4.so.1 => /usr/local/lib/samba4/private/libheimbase-samba4.so.1 (0x28da3000)
        libndr-krb5pac.so.0 => /usr/local/lib/samba4/libndr-krb5pac.so.0 (0x28da7000)
        libgnutls.so.30 => /usr/local/lib/libgnutls.so.30 (0x28dbd000)
        libndr-standard.so.0 => /usr/local/lib/samba4/libndr-standard.so.0 (0x29000000)
        libndr-nbt.so.0 => /usr/local/lib/samba4/libndr-nbt.so.0 (0x28ef6000)
        libz.so.6 => /lib/libz.so.6 (0x28f2b000)
        libsamdb-common-samba4.so => /usr/local/lib/samba4/private/libsamdb-common-samba4.so (0x28f41000)
        libcli-ldap-common-samba4.so => /usr/local/lib/samba4/private/libcli-ldap-common-samba4.so (0x28f7e000)
        libldbsamba-samba4.so => /usr/local/lib/samba4/private/libldbsamba-samba4.so (0x28f8a000)
        libldb.so.1 => /usr/local/lib/libldb.so.1 (0x28fc2000)
        libdbwrap-samba4.so => /usr/local/lib/samba4/private/libdbwrap-samba4.so (0x28fec000)
        libutil-tdb-samba4.so => /usr/local/lib/samba4/private/libutil-tdb-samba4.so (0x28ffb000)
        libiov-buf-samba4.so => /usr/local/lib/samba4/private/libiov-buf-samba4.so (0x29672000)
        libinterfaces-samba4.so => /usr/local/lib/samba4/private/libinterfaces-samba4.so (0x29675000)
        libtdb.so.1 => /usr/local/lib/libtdb.so.1 (0x29679000)
        libMESSAGING-SEND-samba4.so => /usr/local/lib/samba4/private/libMESSAGING-SEND-samba4.so (0x29690000)
        libjansson.so.4 => /usr/local/lib/libjansson.so.4 (0x29694000)
        libserver-role-samba4.so => /usr/local/lib/samba4/private/libserver-role-samba4.so (0x296a3000)
        libcrypt.so.5 => /lib/libcrypt.so.5 (0x296a6000)
        libhx509-samba4.so.5 => /usr/local/lib/samba4/private/libhx509-samba4.so.5 (0x296c4000)
        libwind-samba4.so.0 => /usr/local/lib/samba4/private/libwind-samba4.so.0 (0x29721000)
        libexecinfo.so.1 => /usr/lib/libexecinfo.so.1 (0x2974a000)
        libiconv.so.2 => /usr/local/lib/libiconv.so.2 (0x2974d000)
        libp11-kit.so.0 => /usr/local/lib/libp11-kit.so.0 (0x29842000)
        libunistring.so.2 => /usr/local/lib/libunistring.so.2 (0x29913000)
        libtasn1.so.6 => /usr/local/lib/libtasn1.so.6 (0x29a9d000)
        libnettle.so.6 => /usr/local/lib/libnettle.so.6 (0x29aae000)
        libhogweed.so.4 => /usr/local/lib/libhogweed.so.4 (0x29ae1000)
        libgmp.so.10 => /usr/local/lib/libgmp.so.10 (0x29b0e000)
        libintl.so.8 => /usr/local/lib/libintl.so.8 (0x29b66000)
        libidn2.so.0 => /usr/local/lib/libidn2.so.0 (0x29b6f000)
        libflag-mapping-samba4.so => /usr/local/lib/samba4/private/libflag-mapping-samba4.so (0x29b8c000)
        libtdb-wrap-samba4.so => /usr/local/lib/samba4/private/libtdb-wrap-samba4.so (0x29b8f000)
        libmessages-util-samba4.so => /usr/local/lib/samba4/private/libmessages-util-samba4.so (0x29b93000)
        libmessages-dgm-samba4.so => /usr/local/lib/samba4/private/libmessages-dgm-samba4.so (0x29b96000)
        libserver-id-db-samba4.so => /usr/local/lib/samba4/private/libserver-id-db-samba4.so (0x29ba6000)
        libutil-setid-samba4.so => /usr/local/lib/samba4/private/libutil-setid-samba4.so (0x29bab000)
        libelf.so.2 => /lib/libelf.so.2 (0x29bae000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x29bc4000)
        libffi.so.6 => /usr/local/lib/libffi.so.6 (0x29bd0000)
        libmsghdr-samba4.so => /usr/local/lib/samba4/private/libmsghdr-samba4.so (0x29bd7000)
```

Command2:

```
pkg which /usr/local/lib/libwbclient.so.0

/usr/local/lib/libwbclient.so.0 was not found in the database
```

How can I install libwbclient.so.0?


----------



## ShelLuser (Jun 2, 2018)

herpestes said:


> I have corrected the configuration file and continue with the same error.


In the mean time I have done a bit of investigating of my own and I can now see what's causing all this: incorrect upgrades.

See, this is what `ldd ./libgensec-samba4.so` tells me on a system which only uses binary packages:


```
libsamba-util.so.0 => /usr/local/lib/samba4/libsamba-util.so.0 (0x28259000)
        libwbclient.so.0 => /usr/local/lib/samba4/libwbclient.so.0 (0x282de000)
        libcom_err-samba4.so.0 => /usr/local/lib/samba4/private/libcom_err-samba4.so.0 (0x282f4000)
```
Now, you need to keep in mind that all of this stuff is dynamic. And also the reason why I'm not a fan of GPG2; because one library can mess up the whole program (small side-comment).

See: /usr/local/lib/libwbclient.so.0 on your system is most likely a left over which didn't get removed somehow (probably because not every port got cleanly deinstalled). And because it sits "higher" in the library search path Samba picks up the obsolete library before the official one.

Solution: `# rm /usr/local/lib/libwbclient.so.0`, then re-check using ldd and it should now point to the right library. Once you verified that try restarting Samba and I'm pretty sure things should work now.

For the record:


```
$ pkg which /usr/local/lib/samba4/libwbclient.so
/usr/local/lib/samba4/libwbclient.so was installed by package samba48-4.8.0
```
Hope this helps.


----------



## herpestes (Jun 20, 2018)

Thanks* ShelLuser*
I remove *libwbclient.so.0  *and samba works fine 

By the way, it may be useful to someone. If you can not browse samba resources from a computer with Windows XP, add the following in the configuration file: 

```
lanmanauth = yes
ntlm auth = yes
```

I changed the base from smbpasswd to tdbsam in smb4.conf, but I do not know where the file is in which Samba users are.


----------



## brennan.sebastian (Sep 3, 2018)

Had a similar problem after upgrading to FreeBSD 11.2.


```
# service samba_server onestart
Performing sanity check on Samba configuration: FAILED
```

Solved by doing the following:


```
pkg install -fR samba48

and in /usr/local/etc/smb4.conf

changed:

security = share
to
security = user
```


----------

