Can't access to other user's mounted disk via samba

Issues related to applications and software problems and general support
Post Reply
valanatos
Posts: 2
Joined: 2022/01/01 16:25:45

Can't access to other user's mounted disk via samba

Post by valanatos » 2022/01/01 16:51:13

Hello,

I am new person in CentOS so please help :)

I have one hard drive mounted with root and I'm trying to share it with samba (the path: /run/media/root/Collector/Share)
However, when I assign it in config file as a path

Code: Select all

[Anonymous]
	guest ok = Yes
	path = /run/media/root/Collector/Share
	read only = No
and try to connect it from Windows it fails with "You don't have permission to access" error

When I try the same way with local folder (the path: /srv/samba/anonymous), it works perfectly

Code: Select all

[Anonymous]
	guest ok = Yes
	path = /srv/samba/anonymous
	read only = No
ls -al returns Anonymous has access to this folder

Code: Select all

[root@localhost ~]# ls -al /run/media/root/Collector/Share
total 16
drwxr-xr-x. 4 nobody nobody 4096 Jan  1 19:36 .
drwxr-xr-x. 4 nobody nobody 4096 Jan  1 19:36 ..
drwxr-xr-x. 7 nobody nobody 4096 Jan  1 19:36 Content
drwxr-xr-x. 2 nobody nobody 4096 Jan  1 15:01 External
What I do wrong?

valanatos
Posts: 2
Joined: 2022/01/01 16:25:45

Re: Can't access to other user's mounted disk via samba

Post by valanatos » 2022/01/02 09:44:13

UPDATE

I found that this hard drive should be mounted like this : https://codingbee.net/rhcsa/rhcsa-mounting-a-partition
Done.

And weird thing appears: when I mount this device in my samba shared folder this folder becomes unaccessable from other machines. When I unmount it, everything becomes ok, I can connect and create/delete files there

I found that something with access rights may cause it, but I don't understand what definitely it is.

User avatar
TrevorH
Site Admin
Posts: 33220
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Can't access to other user's mounted disk via samba

Post by TrevorH » 2022/01/02 18:11:52

More likely you are hitting selinux which tries to prevent bad people from Doing Stuff(TM). Read /etc/samba/smb.conf.example which has a whole bunch of comments at the top telling you how to allow samba shares with selinux enabled.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

pjsr2
Posts: 614
Joined: 2014/03/27 20:11:07

Re: Can't access to other user's mounted disk via samba

Post by pjsr2 » 2022/01/03 13:22:14

The directory /run/media/<username> is typically used as the directory where removable devices (USB disks, DVD/CD) are automatically mounted by the desktop when a removable device is attached while a user is logged in on the local desktop of a computer. The logged in user becomes the owner of the device and read/write permissions and SELinux context are set accordingly. The assumed usage is that the device is then available to the logged in user for the duration of the desktop setting and not fully accessible by other users.

If you want to share (part of) the removable drive to users on another computer through Samba, you should not let the drive be automatically mounted by the desktop. Unmount the drive and mount it under /media, either manually or through a suitable automount configuration and picking suitable user access options when mounting the drive.

Also, as @TrevorH already pointed out: look at the comments in /etc/samba/smb.conf.example.

Post Reply