Talk:Samba

From ArchWiki
Latest comment: 11 February by Ebkalderon in topic logging to systemd

comment=systemd.automount

~~~~

The fstab setting "comment=systemd.automount" does not work with mount.cifs "comment" or x-sysmted.* is not mentioned in the man-page of mount.cifs. -- Some1 22:05 22.Nov 2013

smb.conf file required for smbclient?

I get an error (warning) when I try to use smbclient without Samba server on that client? Should the wiki be updated to clarify the necessity of smb.conf on smbclient installs only? The wiki is confusing to me because it appears that smb.conf is not required for smbclient only installs.

Error below:

params.c:OpenConfFile() - Unable to open configuration file "/etc/samba/smb.conf":
	No such file or directory
smbclient: Can't load /etc/samba/smb.conf - run testparm to debug it

Forgive me, this is my first talk entry.Stevepa (talk) 18:43, 2 December 2012 (UTC)Reply[reply]

I tried the smbclient -L command and also got this message. I suspect it is just an overly talkative program rather than an indication of an error. Might be worth mentioning this, unless someone knows how a missing config file could cause a real problem. Vadmium (talk) 01:58, 3 December 2012 (UTC).Reply[reply]
I just solved a long time printing problem by creating an empty file at "/etc/samba/smb.conf". Before this I never managed to use the Samba printers at my university unless I printed through he command line with smbclient -U "username" //printer -c "print file.ps". With all other methods cups would reply with "Can't load /etc/samba/smb.conf - run testparm to debug it". Generating that file (even if it's completely empty) solved that issue. Sounds to me like a bug in cups as there is no reason to require that file, given it's never used. ptersilie (talk)
From my experience /etc/samba/smb.conf is not required, but if it exists and has any configuration settings -- those are honored. I have installed gvfs and gvfs-smb packages (I think that also pulls smbclient as a dependency) to get access to smb:// protocol in Thunar under XFCE. Without /etc/samba/smb.conf i was able to connect to NAS drives via Samba, but I couldn't browse the Network Neighborhood. After some searching I found that I can add client max protocol = NT1 option under [global] section in /etc/samba/smb.conf, but I didn't have the file (because it is not installed, unless you also install Samba server package. I manually added the file (actually got it from Samba git repository https://git.samba.org/samba.git/?p=samba.git;a=blob_plain;f=examples/smb.conf.default;hb=HEAD and made proper modifications. After that Network Neighborhood became visible and I could connect to different Samba hosts on the network, but file browsing on those servers (going from directory to directory) became very, very slow because this early version of the protocol doesn't support any caching and other speed improvements of the later versions. Long story short, I removed the smb.conf file and went back to the old setup -- where I can't browse the network, but when I connect to machines by hand (IP) -- the file browsing is fast. XFCE's Thunar doesn't see the Network Neighborhood though -- some say this is because it uses dated libsmb.so or something like that. If anyone knows how to fix this -- let me know. TL;DR: /etc/samba/smb.conf is not required by smbclient, but it is definitely used if it is there... It probably should be in the standard package. Romstor (talk) 00:33, 3 September 2018 (UTC)Reply[reply]

add documentation for smbclient

Shouldn't the documentation have an entry for this error with smbclient:

directory_create_or_exist: mkdir failed on directory /var/cache/samba: Permission denied

AFAIK it is not recommended to create this directory manually. What I did was start and stop smb once. Tinti (talk) 13:00, 13 December 2019 (UTC)Reply[reply]

permissions

I spend hours to try sharing files for guest access in my /home/[user]/Public. Finally I see something from the page Samba/Tips_and_tricks "Note: Make sure the guest also has permission to visit /path, /path/to and /path/to/public". the access to /home/[user] is forbidden for Groups and Others ! So I use /srv/public instead, but this precious information must be write somewhere. Mikhaddo (talk) 14:24, 3 September 2015 (UTC)Reply[reply]

smb.conf permissions

Would it be appropriate to change the “cp /etc/samba/smb.conf.default /etc/samba/smb.conf” command in the instructions to “cp -a /etc/samba/smb.conf.default /etc/samba/smb.conf” or otherwise have a note to make sure smb.conf is world-readable? On my setup, a plain cp resulted in permissions of 600, and “net usershare” absolutely refused to work with the unhelpful message “usershares are currently disabled” until I finally discovered that the permissions on the config file were incorrect. TravisE (talk) 07:52, 4 November 2015 (UTC)Reply[reply]

To clarify or add on to what user @TravisE said, this is what I had to do to get the client working: basically, you need to create the /etc/samba directory in case you do not have the server installed ("sudo mkdir /etc/samba") and assign it 755 permissions ("sudo chmod 755 /etc/samba"), then you can create an empty file and assign it 644 permissions ("sudo touch /etc/samba/smb.conf ; sudo chmod 644 /etc/samba/smb.conf"). These permissions are default on Fedora, and also seems to work fine for Arch. Is there a bug filed about this already? Google hasn't been much help... --Sagir3 (talk) 00:48, 31 July 2017 (UTC)Reply[reply]

Samba automount

Moved from User talk:Indigo, discussion relates to Samba#As_systemd_unit --Indigo (talk) 18:11, 2 March 2016 (UTC)Reply[reply]

Hi Indigo,

Thanks for the edit and link to the man page, but I'm still hoping for a more easy solution: '.. It only indicates that the network management stack is up after it has been reached. .. services using the network should hence simply place an After=network.target dependency in their unit files, and avoid any Wants=network.target or even Requires=network.target'.

Is there no other method to check if an network service is started? Or should the Requirement line simple be removed?

Thanks! :) Francoism (talk) 20:34, 29 February 2016 (UTC)Reply[reply]

Hi, no problem. There are other methods, but it gets more complicated. So, sorry I am not aware of an easy other method that works with any network management service, let's both have hope :) Network mounts like via samba are susceptible to fail easily, I would not remove Requires= for such (particularly since not everyone uses the listed networkd-online or nm-online). The Requires= actually can be handy as well, because it means you don't need to have the network managemnt started. Once you start mnt-myshare.mount, it would automatically start the Requires= unit. Or, once you stop the required unit, the mount is brought down first. Ok? --Indigo (talk) 21:24, 29 February 2016 (UTC)Reply[reply]
I don't know if the Require line is still needed thought, since it already has set network-online as dep.
An issue could occur when using/restart or switching between multiple network services, resulting in (share) connections getting drop or creating multiple connections.
On testing, I didn't found any (share-)disconnect issues resulting in network failures/changing IP's, restarting backends, etc. The share would simple lose it's connections, and restore the connection when it could reach the server again.
Therefore I would recommend of dropping the Require string, since it should not depend on a (single) backend, but simple on the IP-settings.
Let me know your thoughts. :)
Francoism (talk) 11:43, 2 March 2016 (UTC)Reply[reply]
Well, if you test it and it works with different backends safely on connect/disconnect, sure - the Requires= is not a pre-requisite for the unit to work. I did not want to dive into the topic, but since you ask: my first thought is that this note is a nuisance. It would be cleaner, if a custom systemd unit mnt-myshare.mount works without any "You may have to enable unit xyz...", no matter what service takes care of the network connection. network-online.target is a systemd standard. I have not followed, if all the major network configuration tools now adjusted to adhere to it so that other units can safely depend on ordering behind it only. If yes I wonder, why systemd-networkd-wait-online.service even exists..
My second thought: the mnt-myshare.mount unit's dependencies should ensure that manual stopping of the connection is not possible, if it is in use (e.g. files open via the share). I don't know if that was part of your test; my expectation to a network share these days is that either the service and protocol (samba, cifs) tries to ensure no data is lost or the unit mounting the share.
My third thought (only now that I look at the Samba#Automatic_mounting section): I would never use the mnt-myshare.mount anyway. Why? Because it will try to find the //server/sharename each time any network connection goes up. Imagine you connect to a public hotel/university w/lan (no samba server you need there), samba starts searching, someone in the public network sniffs the query. Next time you connect to the same hotel/university w/lan a named share may be found, samba tries to connect and with that -oops- your share credentials are over the wire. As is, this is classic information leakage. I would always bind such a automount to a particular network connection, i.e. let it have some sort of pre-authentication. Obviously, this last thought makes the whole thing more complicated again. I would not say that the unit must reflect it, but maybe a general warning is a sensible thing to add.
tl;dr: If you tested it and it works without Requires= for other network services than those mentioned in the note, fine with me to remove it. I am not using samba with a systemd installation currently, so I cannot give it a try.
--Indigo (talk) 18:20, 2 March 2016 (UTC)Reply[reply]

Share files without a username and password

Is anyone actually having success with the described methods? Wouldn't it be much easier to suggest the following method with "force user" to share files in a friendly/home network without having filesystem permission headaches?

/etc/samba/smb.conf
[global]
server min protocol = SMB2
workgroup = workgroup
server string = ""
map to guest = bad user

[share]
path = ~/sharepath
read only = no
guest ok = yes
force user = ownerofthehomefolder

Aufkrawall (talk) 15:44, 21 December 2017 (UTC)Reply[reply]

Unfounded warning regarding I/O errors and manual mounting?

https://wiki.archlinux.org/index.php/samba#Manual_mounting

In regards to this warning:

Warning: Using uid and/or gid as mount options may cause I/O errors, it is recommended to set/check correct File permissions and attributes instead.

Searching online I found no information as to why this mentioned warning might happen, and in that case I feel this warning is slightly unfounded. Does anyone have a better explanation as to why using uid and gid would cause I/O errors, and if these errors can be observed in any sort of logs (dmesg, journal?)

I currently use my local client uid and gid with no problems (through fstab), as there is no comparable client/group setup with the samba share on the server side, and if I don't use local uid/gid, the folder is mounted with root permissions. Perhaps there's a way instead to just use user/group text input in mount options?

Ddifof (talk) 02:37, 2 August 2018 (UTC)Reply[reply]

cifs-utils as lightweight alternative to smbclient?

The second sentence of Samba#Client states that cifs-utils is a lightweight alternative to smbclient, but the latter is a dependency of the first, so whether you install the one or the other you always get both – and most importantly it’s not possible (in a supported way) to install just cifs-utils. Dessert (talk) 18:05, 13 September 2020 (UTC)Reply[reply]

cifsd/ksmbd as a samba in-kernel replacement

https://github.com/cifsd-team https://www.phoronix.com/scan.php?page=news_item&px=CIFSD-v2-Linux-Server-Patches —This unsigned comment is by Jpegxguy (talk) 18:16, 22 April 2021 (UTC). Please sign your posts with ~~~~!Reply[reply]

logging to systemd

Instruction to set configuration option "logging" to "systemd" might not be relevant anymore. I can't find a recent reference to it and fresh installation of "smb" logs to systemd.

Kulak (talk) 03:42, 15 July 2023 (UTC)Reply[reply]

The smb.conf(5) man page includes a direct reference to "logging = systemd" in the "Logging" section (online link), so the option still exists and is valid. You are correct that a fresh installation of "smb" logs seems to log to systemd by default, though. Ebkalderon (talk) 01:17, 11 February 2024 (UTC)Reply[reply]

Smbclient Wont Log In To Anything

[someone@someone ~]$ sudo smbclient \\\\10.129.133.80\\ -U WorkShares Password for [MYGROUP\WorkShares]: [someone@someone ~]$ testparm Load smb config files from /etc/samba/smb.conf Loaded services file OK. Weak crypto is allowed by GnuTLS (e.g. NTLM as a compatibility fallback)

Server role: ROLE_STANDALONE

Press enter to see a dump of your service definitions

  1. Global parameters

[global] dns proxy = No log file = /usr/local/samba/var/log.%m max log size = 50 server role = standalone server server string = Samba Server workgroup = MYGROUP idmap config * : backend = tdb


[homes] browseable = No comment = Home Directories read only = No


[printers] browseable = No comment = All Printers path = /usr/spool/samba printable = Yes Ifightformyrights (talk) 11:28, 26 October 2023 (UTC)Reply[reply]

i dont know how to format it so that it wont just all pile up weird like this Ifightformyrights (talk) 11:34, 26 October 2023 (UTC)Reply[reply]