Page 1 of 2
IOError: [Errno 13] Permission denied [moving to NAS]
Posted: March 16th, 2013, 7:12 pm
by phillipston
I'm having a problem with my NAS. Here is a few lines of my SABNzbd error log:
Traceback (most recent call last):
File "/usr/share/sabnzbdplus/sabnzbd/misc.py", line 818, in move_to_path
shutil.copyfile(path, new_path)
File "/usr/lib/python2.7/shutil.py", line 83, in copyfile
with open(dst, 'wb') as fdst:
IOError: [Errno 13] Permission denied:
This happens on absolutely every file I try to download. The failure occurs when moving from my temporary download folder (on the local host) to my completed download folder. My completed download folder resides on the NAS. Note that I used to run OpenElec 2.0 and everything worked fine with SABnzbdplus (an older version I'm sure) and my same Synology NAS. When I upgraded to XBMCbuntu, I could only download to my local server, a Zotac Mag. Whenever I change the completed download directory to my Synology NAS, I get the above error.
Here's my basic info:
SAB Version: 0.7.3
OS: Ubuntu, Xbmcbuntu, Ubuntu 12.10, Xbmc frodo
Install-type: linux repository
Skin Plush
Firewall Software: iptables not configured
Are you using IPV6? No
Is the issue reproducible? yes
It is interesting to note that on my NAS the log states that the user made a directory and renamed it (_FAILED...) and the user account was guest. I do not set my SAB user to guest. Don't know what that's about, but anyway, I have checked all of my user privileges for the completed download directory including guest and they all are set to read and write on the NAS.
I can move files from my Windows XP pc to the NAS, using Windows Explorer and WinSCP.
Re: IOError: [Errno 13] Permission denied [moving to NAS]
Posted: March 17th, 2013, 2:51 am
by shypike
I think you know the answer.
SABnzbd does not have permission to write to the "complete" folder.
Try to get ssh access to the NAS and check access rights.
Re: IOError: [Errno 13] Permission denied [moving to NAS]
Posted: March 17th, 2013, 2:59 am
by sander
I would say it is a rights problem. It might be on a subdirectory.
On the XBMCbuntu: what's the output of:
Code: Select all
grep "/" ~/.sabnzbd/sabnzbd.ini | grep dir
df -h
mount
Re: IOError: [Errno 13] Permission denied [moving to NAS]
Posted: March 17th, 2013, 4:30 pm
by phillipston
Sorry, didn't see this thread. I figured it was some kind of permissions thing, but just can't find out where the problem is.
Here is what I have for the requested output:
rickhtpc@Rick-HTPC:~$ grep "/" ~/.sabnzbd/sabnzbd.ini | grep dir
download_dir = Downloads/incomplete
complete_dir = /home/rickhtpc/Movies
script_dir = /home/rickhtpc/.sickbeard/autoProcessTV
dir = ../TV Shows
rickhtpc@Rick-HTPC:~$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 145G 24G 115G 17% /
udev 870M 4.0K 870M 1% /dev
tmpfs 353M 692K 352M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 881M 0 881M 0% /run/shm
none 100M 0 100M 0% /run/user
//192.168.1.6/CinematicRemote 1.8T 519G 1.3T 29% /home/rickhtpc/Movies
/dev/sdb1 7.6G 3.0G 4.6G 40% /media/OPENELEC
rickhtpc@Rick-HTPC:~$ mount
/dev/sda1 on / type ext4 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
udev on /dev type devtmpfs (rw,mode=0755)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755)
none on /run/lock type tmpfs (rw,noexec,nosuid,nodev,size=5242880)
none on /run/shm type tmpfs (rw,nosuid,nodev)
none on /run/user type tmpfs (rw,noexec,nosuid,nodev,size=104857600,mode=0755)
rpc_pipefs on /run/rpc_pipefs type rpc_pipefs (rw)
//192.168.1.6/CinematicRemote on /home/rickhtpc/Movies type cifs (rw)
/dev/sdb1 on /media/OPENELEC type vfat (rw,nosuid,nodev,uid=1000,gid=1000,shortname=mixed,dmask=0077,utf8=1,showexec,uhelper=udisks)
Re: IOError: [Errno 13] Permission denied [moving to NAS]
Posted: March 17th, 2013, 4:32 pm
by phillipston
I also checked access rights on the NAS completed directory and it's 0777.
Re: IOError: [Errno 13] Permission denied [moving to NAS]
Posted: March 17th, 2013, 4:47 pm
by sander
What's the output of:
Code: Select all
ls -al /home/rickhtpc/Movies
cd /home/rickhtpc/Movies
touch hello.txt
Re: IOError: [Errno 13] Permission denied [moving to NAS]
Posted: March 17th, 2013, 5:01 pm
by phillipston
Requested output is:
ls –al /home/rickhtpc/Movies
drwxr-xr-x 2 1025 users 0 Dec 15 20:42 Its a Wonderful Life
.
.
.
This is a very long list of movies. Above is a typical entry.
rickhtpc@Rick-HTPC:~$ cd /home/rickhtpc/Movies
rickhtpc@Rick-HTPC:~/Movies$ touch hello.txt
rickhtpc@Rick-HTPC:~/Movies$
Re: IOError: [Errno 13] Permission denied [moving to NAS]
Posted: March 17th, 2013, 5:06 pm
by sander
PS:
What's the output of:
ls -al /home/rickhtpc/Movies/hello.txt
Re: IOError: [Errno 13] Permission denied [moving to NAS]
Posted: March 17th, 2013, 5:46 pm
by phillipston
rickhtpc@Rick-HTPC:~/Movies$ ls -al /home/rickhtpc/Movies/hello.txt
-rw-rw-r-- 1 1025 users 0 Mar 17 17:59 /home/rickhtpc/Movies/hello.txt
rickhtpc@Rick-HTPC:~/Movies$
Re: IOError: [Errno 13] Permission denied [moving to NAS]
Posted: March 17th, 2013, 6:15 pm
by sander
Are you running sabnzbd from the commandline, or as a service / daemon. If as a service, under which account?
Furthermore, I only have one advice: check the NAS rights. It's not a SABnzbd thing. Proof: set the Complete folder to your local harddisk, and start downloading.
Re: IOError: [Errno 13] Permission denied [moving to NAS]
Posted: March 18th, 2013, 6:26 pm
by phillipston
OK, thanks. It is not a SABnzbd thing as you say. I have set the NAS rights - it is something else. I run it as a daemon and set the USER in etc/default/sabnzbdplus to rickhtpc, which has read/write privileges on the NAS (however, the NAS only seems to be seeing 'guest' which also has read/write access). I thought it might be a Python related thing. It's just so weird, nothing has changed on my NAS since I upgraded to XBMCbuntu.
I will figure this out!
Re: IOError: [Errno 13] Permission denied [moving to NAS]
Posted: March 19th, 2013, 2:02 am
by sander
phillipston wrote: I thought it might be a Python related thing.
Interesting hypothesis.
Did you look at sabnzbd/misc.py around line 816? The problems occurs in the line "shutil.copyfile(path, new_path)".
Have you set SABnzbd's logging to debug? With debug level, you should grep for "Moving" in sabnzbd.log, for example:
Code: Select all
2013-02-27 19:02:37,529::DEBUG::[misc:810] Moving. Old path:/home/sander/Downloads/incomplete/blablalbla/720p.hdtv.x264-knifesharp.nfo new path:/home/sander/Downloads/SABdownloads/_UNPACK_blablala01.720p.hdtv.x264-knifesharp.nfo overwrite?:0
Is there anything special in that line? Strange names / locations? Can you paste it here?
If the line looks OK, you can mimic the "shutil.copyfile(path, new_path)" in a python shell. Here is a two-liner that generates the same error message because I want to write to a location for which I haven't got the rights:
Code: Select all
sander@flappie:~$ python
Python 2.7.3 (default, Mar 15 2013, 21:35:30)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import shutil
>>> shutil.copyfile("hallo.txt", "/usr/bin/magniet")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/shutil.py", line 83, in copyfile
with open(dst, 'wb') as fdst:
IOError: [Errno 13] Permission denied: '/usr/bin/magniet'
>>>
sabnzbd/misc.py code:
Code: Select all
def move_to_path(path, new_path):
""" Move a file to a new path, optionally give unique filename
Return (ok, new_path)
"""
ok = True
overwrite = cfg.overwrite_files()
if overwrite and os.path.exists(new_path):
try:
os.remove(new_path)
except:
overwrite = False
if not overwrite:
new_path = get_unique_filename(new_path)
if new_path:
logging.debug("Moving. Old path:%s new path:%s overwrite?:%s",
path, new_path, overwrite)
try:
# First try cheap rename
renamer(path, new_path)
except:
# Cannot rename, try copying
try:
if not os.path.exists(os.path.dirname(new_path)):
create_dirs(os.path.dirname(new_path))
shutil.copyfile(path, new_path)
os.remove(path)
except:
if not (cfg.marker_file() and cfg.marker_file() in path):
logging.error(Ta('Failed moving %s to %s'), path, new_path)
logging.info("Traceback: ", exc_info = True)
ok = False
return ok, new_path
Re: IOError: [Errno 13] Permission denied [moving to NAS]
Posted: March 19th, 2013, 6:53 pm
by phillipston
So, in the SABnzbd log file we have:
2013-03-18 20:40:26,863::ERROR::[misc:822] Failed moving /home/rickhtpc/Downloads/incomplete/True_Grit.2010.BluRay.AC3-NoGroup/rsg-truegrit-xvid.r53 to /home/rickhtpc/Movies/_UNPACK_True_Grit 2010 BluRay AC3-NoGroup/rsg-truegrit-xvid.r53
There is nothing unusual there.
Then when I duplicate the code that you showed to duplicate hte IOError I get the following:
>>> shutil.copyfile("hallo.txt", "/user/bin/magiet")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/shutil.py", line 82, in copyfile
with open(src, 'rb') as fsrc:
IOError: [Errno 2] No such file or directory: 'hallo.txt'
>>>
It is interesting to note that my open call uses 'rb' whereas yours used 'wb'. Can that be the difference?
Re: IOError: [Errno 13] Permission denied [moving to NAS]
Posted: March 20th, 2013, 1:30 am
by sander
phillipston wrote:
It is interesting to note that my open call uses 'rb' whereas yours used 'wb'. Can that be the difference?
No, it's not:
Code: Select all
>>> shutil.copyfile("nothere.txt", "/user/bin/notallowed")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/shutil.py", line 82, in copyfile
with open(src, 'rb') as fsrc:
IOError: [Errno 2] No such file or directory: 'nothere.txt'
>>>
Re: IOError: [Errno 13] Permission denied [moving to NAS]
Posted: March 20th, 2013, 6:50 am
by phillipston
Code: Select all
rickhtpc@Rick-HTPC:~$ python
Python 2.7.3 (default, Sep 26 2012, 21:53:58)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import shutil
>>> shutil.copyfile(".asoundrc", "Movies/.asoundrc")
The above worked just fine, proving I can write to the mounted directory "Movies" from the local host. Just not with SABnzbd.