Help with Samba: "usershares are currently disabled"

Hello,

absolutely new to NixOS and having an issue with Samba.

I started with the Samba wiki entry, copying & pasting the server example (adapting the paths).

After setting Credential used to access SMB shares I can connect to shared resources on other computers. So far, so good.

Issue starts when I try to share from NixOS.

Tried with Dolphin, but in the “Share” tab shows a “Samba is not installed on your system” message. I then installed kdeApplications.kdenetwork-filesharing (is this necessary?), and the issue persists.

A few attempts that I did.

# systemctl restart samba from the Wiki page fails. Perhaps Samba is actually not installed!, but the command # systemctl restart samba-smbd works. Nothing changes, but I assume now that Samba is installed. And it seems to be the case.

/etc/samba/samba.conf exists:

$ ls /etc/samba/smb.conf                
/etc/samba/smb.conf

services are enabled:

$ systemctl list-unit-files | grep samba
samba-nmbd.service                                               enabled        
samba-setup.service                                              linked         
samba-smbd.service                                               enabled        
samba-winbindd.service                                           enabled        
samba.target                                                     enabled

Probably not necessary, but I tried with smbpasswd etc.

Rebooted. Nothing. Tried something else:

$ net rpc user   
Enter WORKGROUP\max's password: 
max
$ net rpc share list -U max
Enter WORKGROUP\max's password: 
private
public
IPC$

Last try:

$ net usershare info --long
net usershare: usershares are currently disabled

Interesting… Can be this the problem?
After searching in the Wiki, Google, etc I have no clues: how to enable usershares in NixOS (if this is the point)?

If it can help, I have a gist with the excerpt that I use,

$  nix --version          
nix (Nix) 2.2.2
system.stateVersion = "19.03";
1 Like

Did you manage to get this working? I think I am getting into the same problem.

If you can list the shares from the local system it might be an issue with the firewall.
Check the firewall (“iptables -vnL” as root) to see if the dropped packages increase while you’re connecting from another system. Depending on your configuration that could also be logged, so also check “journalctl -f” as root while connecting.

Check the samba logs (not sure where they are on NixOS by default) for any indication of connection errors.

Thank you, and sorry for the late reply.

No, I can not list the shares neither from the local host.

I disabled the firewall. After restarting, with journalctl -f I still get (for localhost):

Jan 23 16:02:24 max-nixos smbd[8434]: [2020/01/23 16:02:24.207737,  0] ../../lib/util/access.c:365(allow_access)
Jan 23 16:02:24 max-nixos smbd[8434]:   Denied connection from 192.168.0.161 (192.168.0.161)
Jan 23 16:02:24 max-nixos smbd[8435]: [2020/01/23 16:02:24.211631,  0] ../../lib/util/access.c:365(allow_access)
Jan 23 16:02:24 max-nixos smbd[8435]:   Denied connection from 192.168.0.161 (192.168.0.161)
Jan 23 16:02:24 max-nixos xsession[2902]: kio_smb: open  "smb://"

From another host:

Jan 23 16:08:48 max-nixos smbd[16666]: [2020/01/23 16:08:48.279444,  0] ../../lib/util/access.c:365(allow_access)
Jan 23 16:08:48 max-nixos smbd[16666]:   Denied connection from 192.168.0.160 (192.168.0.160)
Jan 23 16:08:48 max-nixos smbd[16667]: [2020/01/23 16:08:48.280500,  0] ../../lib/util/access.c:365(allow_access)
Jan 23 16:08:48 max-nixos smbd[16667]:   Denied connection from 192.168.0.160 (192.168.0.160)

After systemctl restart samba-smbd.service a few times

Jan 23 16:14:24 max-nixos nmbd[23433]: [2020/01/23 16:14:24.747511,  0] ../../source3/nmbd/nmbd_become_lmb.c:397(become_local_master_stage2)
Jan 23 16:14:24 max-nixos nmbd[23433]:   *****
Jan 23 16:14:24 max-nixos nmbd[23433]: 
Jan 23 16:14:24 max-nixos nmbd[23433]:   Samba name server MAX-NIXOS is now a local master browser for workgroup WORKGROUP on subnet 172.17.0.1
Jan 23 16:14:24 max-nixos nmbd[23433]: 
Jan 23 16:14:24 max-nixos nmbd[23433]:   *****
Jan 23 16:14:24 max-nixos nmbd[23433]: [2020/01/23 16:14:24.747668,  0] ../../source3/nmbd/nmbd_become_lmb.c:397(become_local_master_stage2)
Jan 23 16:14:24 max-nixos nmbd[23433]:   *****
Jan 23 16:14:24 max-nixos nmbd[23433]: 
Jan 23 16:14:24 max-nixos nmbd[23433]:   Samba name server MAX-NIXOS is now a local master browser for workgroup WORKGROUP on subnet 192.168.0.161
Jan 23 16:14:24 max-nixos nmbd[23433]: 
Jan 23 16:14:24 max-nixos nmbd[23433]:   *****

Any idea?

Sorry for the late reply. Not really, I am back today to NiXOS and exploring @tokudan suggestion, but so far no news :slight_smile:

@breakds @tokudan thanks both. Solved. At some point I added #hosts deny = 0.0.0.0/0 and left the hosts allow before that line :man_facepalming:

@breakds check if it also your case.

Edit: then stopped to work again, silently failing :smiley:

I guess you didn’t mean you’ve got it to work with Dolphin. As can be seen in https://cgit.kde.org/kdenetwork-filesharing.git/tree/samba/filepropertiesplugin/sambausershareplugin.cpp , its Samba plugin currently looks for smbd in /usr to detect if Samba is installed. Empty /usr/sbin/smbd can be created as a temporary workaround.

1 Like