Problem: samba-tool dont work anymore - Unable to load default file

Problem

You get an traceback while using samba-tool

samba-tool user list
ERROR(runtime): uncaught exception - Unable to load default file
 File "/usr/lib/python3/dist-packages/samba/netcmd/__init__.py", line 186, in _run
   return self.run(*args, **kwargs)
 File "/usr/lib/python3/dist-packages/samba/netcmd/user.py", line 488, in run
   lp = sambaopts.get_loadparm()
 File "/usr/lib/python3/dist-packages/samba/getopt.py", line 92, in get_loadparm
   self._lp.load_default()

And in the samba log under /var/log/samba/log.samba you find some like

Unable to load default file

/usr/sbin/samba_dnsupdate: RuntimeError: Unable to load file /etc/samba/smb.conf
[2023/04/11 08:22:59.958045,  0, pid=16619] ../../source4/dsdb/dns/dns_update.c:86(dnsupdate_nameupdate_done)
dnsupdate_nameupdate_done: Failed DNS update with exit code 1

Solution for configs

You will find several configs under /etc/samba/local.config.conf

less /etc/samba/local.config.conf

include = /etc/samba/local.config.d/global.local.config.conf
include = /etc/samba/local.config.d/printer.local.config.conf
include = /etc/samba/local.config.d/printer.epsonxyz.local.config.conf
include = /etc/samba/local.config.d/printer.brotherxyz.local.config.conf

Check if they exist one by one, for example:
ls -lah /etc/samba/local.config.d/global.local.config.conf

If you get one config that’s not exist:
ls -lah /etc/samba/local.config.d/printer.local.config.conf

ls: access to ‘/etc/samba/local.config.d/printer.local.config.conf’ not possible: File or directory not found

Uncomment the config with an # and restart the samba

include = /etc/samba/local.config.d/global.local.config.conf
#include = /etc/samba/local.config.d/printer.local.config.conf
include = /etc/samba/local.config.d/printer.epsonxyz.local.config.conf
include = /etc/samba/local.config.d/printer.brotherxyz.local.config.conf

/etc/inid.d/samba restart

Solution for Shares

Furthermore there is the path for shares there can also be configs that are no longer exist.

/etc/samba/shares.conf

Same check here like

less /etc/samba/shares.conf

include = /etc/samba/shares.conf.d/sharename
include = /etc/samba/shares.conf.d/example-name
include = /etc/samba/shares.conf.d/example-share

also check them with:

ls -lah /etc/samba/shares.conf.d/example-share>

ls: access to ‘/etc/samba/shares.conf.d/example-share’ not possible: File or directory not found

Same thing here, uncomment the none existing shares with an #

include = /etc/samba/shares.conf.d/sharename
include = /etc/samba/shares.conf.d/example-name
#include = /etc/samba/shares.conf.d/example-share

And just restart the samba service

/etc/inid.d/samba restart

Mastodon