FYI Samba permission error for the linux junkies among us

AndyInNYC

Active Member
Joined
May 23, 2013
Messages
772
Reaction score
124
I've moved my call recordings onto my server machine and created a samba share. On the PBX, I've added an fstab entry to mount the share. I've changed the location in the gui. Unfortunately, writing the file to the location fails due to a permission error - and I don't get why.

in the asterisk cli I get the following:

Code:
[2019-10-15 23:30:19] WARNING[2603][C-0000000c]: file.c:1229 ast_writefile: Unable to open file /mnt/Phone/2019/10/15/out-9177230665-1000-20191015-233019-1571196619.21.wav: Permission denied

my PBX has the following entry
Code:
//192.168.40.28/PhoneRecordings /mnt/Phone cifs username=server,password=password,iocharset=utf8,sec=ntlm  0  0

my server machine (at .28) has the following entry in smb.conf

Code:
[PhoneRecordings]
path = "/media/RAID/Phone System Calls - Backup"
browseable = yes
available = yes
valid users = root server
guest ok = Yes
force user = root
encrypt passwords = true
browseable = yes
security = user
guest ok = no
read only = no
create mask = 0755
writable = yes
write list = server root

The location is mounted:
ls /mnt/Phone shows all the calls

if I ssh in to the PBX and type:
nano /mnt/Phone/NewFile
I can save the new file - somehow I have write permission, but not from inside asterisk?

/mnt/Phone is owned by root.
Code:
root@pbx:/etc $ ls -l /mnt/Phone
total 0
drwxr-xr-x  5 root root 0 Aug 17 17:23 2014
drwxr-xr-x 14 root root 0 Aug 17 19:48 2015
drwxr-xr-x 14 root root 0 Aug 17 21:45 2016
drwxr-xr-x 14 root root 0 Aug 17 22:54 2017
drwxr-xr-x 14 root root 0 Aug 17 23:31 2018
drwxrwxrwx 12 root root 0 Oct  1 10:25 2019

2019 looks correct too:
Code:
root@pbx:/etc $ ls -l /mnt/Phone/2019
total 0
drwxrwx--- 23 root root 0 Jan 31  2019 01
drwxrwx--- 23 root root 0 Feb 28  2019 02
drwxrwx--- 25 root root 0 Mar 30  2019 03
drwxrwx--- 25 root root 0 Apr 27 10:55 04
drwxrwx--- 23 root root 0 May 31 09:15 05
drwxrwx--- 21 root root 0 Jun 29 13:56 06
drwxrwx--- 25 root root 0 Jul 31 09:20 07
drwxrwx--- 28 root root 0 Aug 30 10:26 08
drwxr-xr-x 13 root root 0 Sep 16 10:02 09
drwxr-x---  2 root root 0 Oct  1 10:25 10

I ran the following commands - which didn't really help from the directory with the calls (/media/RAID/Phone System Calls - Backup)
sudo chown -R root:root .
sudo chmod 777 .

The results are reflected above.

Still no help actually writing the file

I'm missing something stupid (my normal operating mode, it seems), but don't know what.

Anyone see anything obvious?

Andrew
 

AndyInNYC

Active Member
Joined
May 23, 2013
Messages
772
Reaction score
124
I created 2 users on the server machine:
sudo useradd -s /bin/true asterisk
sudo useradd -s /bin/true Asterisk

added samba passwords

sudo smbpasswd -a Asterisk
sudo smbpasswd -a asterisk

added both in the smb.conf file which now reads:
Code:
[PhoneRecordings]
path = "/media/RAID/Phone System Calls - Backup"
browseable = yes
available = yes
valid users = root server Asterisk asterisk
guest ok = Yes
force user = root
encrypt passwords = true
browseable = yes
security = user
guest ok = no
read only = no
create mask = 0755
writable = yes
write list = server root Asterisk asterisk

Restarted samba.

Still no joy and same permissions error. What am I *still* doing wrong?

The goal is NOT to change the ownership of the directory (hence the 'force user'), but to allow asterisk to read/write.

Thanks for the assistance.


Andrew
 

dicko

Still learning but earning
Joined
Oct 30, 2015
Messages
1,607
Reaction score
826
create mask = 0755 ? try 775 perhaps
 

jerrm

Guru
Joined
Sep 23, 2015
Messages
838
Reaction score
405
Try in fstab (or equivalent manual umount/mount):

Code:
//192.168.40.28/PhoneRecordings /mnt/Phone cifs username=server,password=password,iocharset=utf8,sec=ntlm,uid=asterisk,gid=asterisk  0  0
 

AndyInNYC

Active Member
Joined
May 23, 2013
Messages
772
Reaction score
124
No, the server is Ubuntu 16.04. It serves files to the various Windows machines throughout the house. There are shares for automated backup, movies, photos, work & projects, etc. I'm also rsyncing to a backup server also in the basement.

Andrew
 

dicko

Still learning but earning
Joined
Oct 30, 2015
Messages
1,607
Reaction score
826
I would mount that Ubuntu directory using sshfs (using ssh keys) to your PBX and take it from there.
 
Last edited:

AndyInNYC

Active Member
Joined
May 23, 2013
Messages
772
Reaction score
124
My post seems to have disappeared. Some combination of the change in fstab and the change in the mask worked. Calls are being written to the directory.

I'll look up sshfs - never heard of it before.


Andrew
 

dicko

Still learning but earning
Joined
Oct 30, 2015
Messages
1,607
Reaction score
826
It neither suffers the consequence af a stale NFS mount or the overhead/limitations of CIFS
 

jerrm

Guru
Joined
Sep 23, 2015
Messages
838
Reaction score
405
It neither suffers the consequence af a stale NFS mount or the overhead/limitations of CIFS
Wouldn't want to live without sshfs, but if the Samba server already exists as a permanent fixture I would expect it perform better (though mostly irrelevant for call recordings).
 

dicko

Still learning but earning
Joined
Oct 30, 2015
Messages
1,607
Reaction score
826
You need samba only for windoze , in your case your samba server is Linux. And in your case why use samba when there is better alternative.
 

AndyInNYC

Active Member
Joined
May 23, 2013
Messages
772
Reaction score
124
I have Windows machines throughout the house - kids, wife, etc. I have certain old media boxes which play better with Samba than with other connection protocols.

It's also the hammer I have, so I'm using it. Right now, it's pounding nails quite nicely recording calls <g>.

Andrew
 

krzykat

Telecom Strategist
Joined
Aug 2, 2008
Messages
3,145
Reaction score
1,235
@dicko, you have previously stated:


"You can change it to any “mounted” file system on any path you choose, but that location needs to be writable by the asterisk user and ALWAYS available
with specific reference to:
cache_record_files
and
record_cache_dir
if you use anything but “perfect” network connected file-systems, then you will need those set appropriatly above any other consideration."

I thought that if I set:

cache_record_files = yes
record_cache_dir = <some local directory>
mixmon_dir = <remote_directory>

Then I would be good. I would assume that it would cache write the files to the record_cache_dir ... and then when it could - it would write to mixmon_dir. If it wasn't available, I assumed it would just grow there until mixmon_dir was available and write then. But I recently had my mixmon_dir become unavailable and I got hosed.
 

dicko

Still learning but earning
Joined
Oct 30, 2015
Messages
1,607
Reaction score
826
Exactly, both nfs and samba/CFS can and under the right circumstances, WILL do that. sshfs when disappeared is more Linux compliant
 
Last edited:

krzykat

Telecom Strategist
Joined
Aug 2, 2008
Messages
3,145
Reaction score
1,235
sshfs when disappeared is more Linux compliant

I am using sshfs - and I still got hosed when the network connection to the remote directory was interrupted.

Here is my sshfs:

sshfs -o reconnect -o allow_other,default_permissions,ServerAliveInterval=5,ServerAliveCountMax=3 asterisk@remote_server.fqdn.com:/mnt/Vol1/pbx/call_recordings/"$srv" /remote_recordings -p 12220

You see anything wrong with that?
 

Members online

Forum statistics

Threads
25,778
Messages
167,504
Members
19,198
Latest member
serhii
Get 3CX - Absolutely Free!

Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.
Top