Jump to content

InnerException: System.IO.IOException: Permission denied


Recommended Posts

Posted

Im trying to add an usb drive and an internal one with different media files. I have change the permissions on the files and folders and im still getting the same error. The only way i can have movies is to add them in the /root/snap/emby-server folder.

Here is the error report

*** Error Report ***
Version: 4.8.10.0
Command line: /snap/emby-server/37/system/EmbyServer.dll -programdata /root/snap/emby-server/common -ffdetect /snap/emby-server/37/bin/ffdetect -ffmpeg /snap/emby-server/37/bin/ffmpeg -ffprobe /snap/emby-server/37/bin/ffprobe -defaultdirectory /root/snap/emby-server/37 -updatepackage emby-server-snap_{version}_amd64.tar.xz
Operating system: Linux version 6.11.0-8-generic (buildd@lcy02-amd64-042) (x86_64-linux-gnu-gcc-14 (Ubuntu 14.2.0-4ubuntu2) 14.2.0, GNU ld (GNU Binutils for Ubuntu) 2.4
Framework: .NET 6.0.31
OS/Process: x64/x64
Runtime: snap/emby-server/37/system/System.Private.CoreLib.dll
Processor count: 4
Data path: /root/snap/emby-server/common
Application path: /snap/emby-server/37/system
System.UnauthorizedAccessException: System.UnauthorizedAccessException: Access to the path '/media/username/Baal' is denied.
---> System.IO.IOException: Permission denied
--- End of inner exception stack trace ---
at System.IO.Enumeration.FileSystemEnumerator`1.CreateDirectoryHandle(String path, Boolean ignoreNotFound)
at System.IO.Enumeration.FileSystemEnumerator`1.Init()
at System.IO.Enumeration.FileSystemEnumerable`1..ctor(String directory, FindTransform transform, EnumerationOptions options, Boolean isNormalized)
at System.IO.Enumeration.FileSystemEnumerableFactory.FileSystemInfos(String directory, String expression, EnumerationOptions options, Boolean isNormalized)
at System.IO.DirectoryInfo.InternalEnumerateInfos(String path, String searchPattern, SearchTarget searchTarget, EnumerationOptions options)
at System.IO.DirectoryInfo.EnumerateFileSystemInfos()
at Emby.Server.Implementations.IO.ManagedFileSystem.EnumerateFileSystemInfos(DirectoryInfo dir, Boolean recursive)
at Emby.Server.Implementations.IO.ManagedFileSystem.GetFileSystemEntries(String path, Boolean recursive, FileSystemCredentials credentials)
at Emby.Api.EnvironmentService.GetFileSystemEntries(GetDirectoryContents request)
at Emby.Api.EnvironmentService.Any(GetDirectoryContents request)
at Emby.Server.Implementations.Services.ServiceController.Execute(HttpListenerHost appHost, Object requestDto, IRequest req, Type serviceType)
at Emby.Server.Implementations.Services.ServiceHandler.ProcessRequestAsync(HttpListenerHost httpHost, IServerApplicationHost appHost, IRequest httpReq, IResponse httpRes, IStreamHelper streamHelper, RestPath restPath, String responseContentType, CancellationToken cancellationToken)
at Emby.Server.Implementations.HttpServer.HttpListenerHost.RequestHandler(IRequest httpReq, ReadOnlyMemory`1 urlString, ReadOnlyMemory`1 localPath, CancellationToken cancellationToken)
Source: System.Private.CoreLib
TargetSite: IntPtr CreateDirectoryHandle(System.String, Boolean)
InnerException: System.IO.IOException: Permission denied
Source:
TargetSite:
 
Any suggestions?
Posted

Hi @Luke. I have attached the log file. Any suggestions?

Posted (edited)

Did you mount ‘/media/username/Baal’ or did the desktop mount it automatically ? (if you don’t know it likely was the latter)

If so the OS will apply it’s default permissions (meaning the user logged into the will see the drive fine but others (ie. emby wont be able to see the drive)

You need to mount the drive differently, the most common way is in /etc/fstab.

Many of us here could walk you through this but I think A decent guide can explain this better:

https://pimylifeup.com/raspberry-pi-mount-usb-drive/

Ignore the RPi specific stuff @ the beginning and scroll down to the header:

    Mount a USB Drive to the Raspberry Pi Manually

 And get back if your still having problems

Edited by TMCsw
typo
  • Agree 1
Posted

Hi @TMCsw. I did the whole procedure, but as soon as the drive mounts, ownership of the mnt folder goes to root. The files get mounted on the specified folder in the fstab file, but im still unable to see the files from emby.

I even created another folder, assign the ownership and saw that when it mounts, ownership shift again to root

Posted
2 hours ago, luigiemby said:

ownership shift again to root

That is normal and fine.

 Your getting closer, now you need to make sure the permissions are correct.

 Try using the following command ‘namei -mo /full/path/to/movie/movie.ext'

And post the results here (for example this is working fine on my system):

tmc@50:/mnt namei -mo /mnt/m/emby/OTA_movies/Armageddon\ \(1998\)/Armageddon\ \(1998\).mkv
f: /mnt/m/emby/OTA_movies/Armageddon (1998)/Armageddon (1998).mkv
 drwxr-xr-x root root  /
 drwxr-xr-x root root  mnt
 drwxrwxr-x emby emby  m
 drwxrwxr-x emby emby  emby
 drwxrwxr-x emby emby  OTA_movies
 drwxrwxr-x emby emby  Armageddon (1998)
 -rw-rw-r-- emby emby  Armageddon (1998).mkv

Note that emby needs permissions thought the chain of directories (minimum rx for emby/others) and r for the actual file.

  • Agree 1
Posted

Here the results of the command. Thank you for your help @TMCsw

Are we getting closer?

namei -mo /mnt/media/Peliculas/50\ 50/50.50.2011.DVDScr.XviD-playXD.avi
f: /mnt/media/Peliculas/50 50/50.50.2011.DVDScr.XviD-playXD.avi
 drwxr-xr-x root root /
 drwxr-xr-x root root mnt
 drwxrwxrwx root root media
 drwxrwxrwx root root Peliculas
 drwxrwxrwx root root 50 50
 -rwxrwxrwx root root 50.50.2011.DVDScr.XviD-playXD.avi

Posted

Sorry was busy, but I think that should be working ? (although a little too open)

Lets’ try this command: (it lets emby own it)

sudo chown -Rv emby:emby /mnt/media/Peliculas

So the other things that could be wrong:

  •   Something is restricting access in /etc/fstab please post it here
  •   Your using the Snap version , perhaps they need the disk passed through (I don’t use snaps so I don’t know)
  •   Some times you need to type in (or cutNpaste) the folder (in emby) instead of using the picker.    
  •   Also you appear to be running an old version of Ubuntu with newer kernel

We probably need more info to help 

@Q-Droidam I missing something?

Posted

My guess is that snap sandboxing could be at play here and why it works when media is in the snap path. Chances are that it's not running as emby, might not even have an emby user on the host and I don't know what the runtime user actually is for emby snaps. Sorry, I don't have much to offer on this one.

 

  • Like 1
Posted

@Q-Droidyou are right about the user. There is no emby user on the passwd file. 

Posted
22 hours ago, Q-Droid said:

I don't know what the runtime user actually is for emby snaps.

 

I've asked our build developer to come in here and comment on this. Thanks guys.

Posted (edited)

This is indeed a result of snap's sandboxing. By default the snap runs as root, but can't access anything. We rely on the `removable-media` plug instead [0], but even this one does not auto-connect (forget the `home` and `system-files` plugs, our snap was rejected when we had them activated). To connect the `removable-media` plug, please run `sudo snap connect emby-server:removable-media :removable-media`. Then you should have access to anything under `/media`, `/run/media` and `/mnt`.

[0] https://snapcraft.io/docs/removable-media-interface

Edited by alucryd
Posted

That did it @alucryd. Thanks a lot and thank you to the team for all the help provided

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...