DiscordChatExporter: System.UnauthorizedAccessException in version 2.42.4 and later
Version
2.42.4
Flavor
CLI (Command-Line Interface)
Platform
Docker / Debian
Export format
HTML
Steps to reproduce
- Install Debian in a VM
- Install Docker: https://docs.docker.com/engine/install/debian/#install-using-the-repository
- Run this test script with version 2.42.4:
token=$(<token.txt) id=$(<channel.txt) version="tyrrrz/discordchatexporter:$1" rm -rf tmp mkdir -p tmp sudo docker pull "$version" sudo docker run -t -v "$(realpath tmp)":/out "$version" export -t "$token" -c "$id" --fuck-russia
Tested and replicated in a fresh Debian VM. I bisected the issue and found that it was introduced in 2.42.4; 2.42.3 was the last working version. The issue is still present in latest as of today.
Details
Expected behavior: Exports the channel.
Actual behavior:
2.42.4: Pulling from tyrrrz/discordchatexporter
Digest: sha256:2a4865027ce2f3aed8e8956ade3cee3f6a2ad556b3f9db20f710f871a074fa35
Status: Image is up to date for tyrrrz/discordchatexporter:2.42.4
docker.io/tyrrrz/discordchatexporter:2.42.4
Resolving channel(s)...
Exporting 1 channel(s)...
Server Meta / server-general ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0%
ERROR
System.UnauthorizedAccessException: Access to the path '/out/Nonclassical Theory and Systems - Server Meta - server-general [994207163880833107].html' is denied.
System.IO.IOException: Permission denied
at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirError)
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode, Boolean failForSymlink, Boolean& wasSymlink, Func`4 createOpenException)
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, UnixFileMode openPermissions, Int64& fileLength, UnixFileMode& filePermissions, Boolean failForSymlink, Boolean& wasSymlink, Func`4 createOpenException)
at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
at System.IO.File.Create(String path)
at DiscordChatExporter.Core.Exporting.MessageExporter.CreateMessageWriter(String filePath, ExportFormat format, ExportContext context) in /tmp/app/DiscordChatExporter.Core/Exporting/MessageExporter.cs:104
at DiscordChatExporter.Core.Exporting.MessageExporter.GetWriterAsync(CancellationToken cancellationToken) in /tmp/app/DiscordChatExporter.Core/Exporting/MessageExporter.cs:59
at DiscordChatExporter.Core.Exporting.MessageExporter.ExportMessageAsync(Message message, CancellationToken cancellationToken) in /tmp/app/DiscordChatExporter.Core/Exporting/MessageExporter.cs:70
at DiscordChatExporter.Core.Exporting.ChannelExporter.ExportChannelAsync(ExportRequest request, IProgress`1 progress, CancellationToken cancellationToken) in /tmp/app/DiscordChatExporter.Core/Exporting/ChannelExporter.cs:77
at DiscordChatExporter.Core.Exporting.ChannelExporter.ExportChannelAsync(ExportRequest request, IProgress`1 progress, CancellationToken cancellationToken) in /tmp/app/DiscordChatExporter.Core/Exporting/ChannelExporter.cs:62
at DiscordChatExporter.Core.Exporting.ChannelExporter.ExportChannelAsync(ExportRequest request, IProgress`1 progress, CancellationToken cancellationToken) in /tmp/app/DiscordChatExporter.Core/Exporting/ChannelExporter.cs:83
at DiscordChatExporter.Cli.Commands.Base.ExportCommandBase.<>c__DisplayClass63_2.<<ExportAsync>b__2>d.MoveNext() in /tmp/app/DiscordChatExporter.Cli/Commands/Base/ExportCommandBase.cs:227
at DiscordChatExporter.Cli.Utils.Extensions.ConsoleExtensions.StartTaskAsync(ProgressContext context, String description, Func`2 performOperationAsync) in /tmp/app/DiscordChatExporter.Cli/Utils/Extensions/ConsoleExtensions.cs:53
at DiscordChatExporter.Cli.Commands.Base.ExportCommandBase.<>c__DisplayClass63_1.<<ExportAsync>b__1>d.MoveNext() in /tmp/app/DiscordChatExporter.Cli/Commands/Base/ExportCommandBase.cs:201
at System.Threading.Tasks.Parallel.<>c__53`1.<<ForEachAsync>b__53_0>d.MoveNext()
at DiscordChatExporter.Cli.Commands.Base.ExportCommandBase.<>c__DisplayClass63_0.<<ExportAsync>b__0>d.MoveNext() in /tmp/app/DiscordChatExporter.Cli/Commands/Base/ExportCommandBase.cs:190
at Spectre.Console.Progress.<>c__DisplayClass27_0.<<StartAsync>b__0>d.MoveNext() in /_/src/Spectre.Console/Live/Progress/Progress.cs:98
at Spectre.Console.Progress.<>c__DisplayClass28_0`1.<<StartAsync>b__0>d.MoveNext() in /_/src/Spectre.Console/Live/Progress/Progress.cs:133
at Spectre.Console.Internal.DefaultExclusivityMode.RunAsync[T](Func`1 func) in /_/src/Spectre.Console/Internal/DefaultExclusivityMode.cs:40
at Spectre.Console.Progress.StartAsync[T](Func`2 action) in /_/src/Spectre.Console/Live/Progress/Progress.cs:116
at Spectre.Console.Progress.StartAsync(Func`2 action) in /_/src/Spectre.Console/Live/Progress/Progress.cs:96
at DiscordChatExporter.Cli.Commands.Base.ExportCommandBase.ExportAsync(IConsole console, IReadOnlyList`1 channels) in /tmp/app/DiscordChatExporter.Cli/Commands/Base/ExportCommandBase.cs:180
at DiscordChatExporter.Cli.Commands.Base.ExportCommandBase.ExportAsync(IConsole console, IReadOnlyList`1 channelIds) in /tmp/app/DiscordChatExporter.Cli/Commands/Base/ExportCommandBase.cs:318
at DiscordChatExporter.Cli.Commands.ExportChannelsCommand.ExecuteAsync(IConsole console) in /tmp/app/DiscordChatExporter.Cli/Commands/ExportChannelsCommand.cs:25
at CliFx.CliApplication.RunAsync(ApplicationSchema applicationSchema, CommandInput commandInput) in /_/CliFx/CliApplication.cs:153
at CliFx.CliApplication.RunAsync(IReadOnlyList`1 commandLineArguments, IReadOnlyDictionary`2 environmentVariables) in /_/CliFx/CliApplication.cs:193
Based on the version in which this bug was introduced, it is most likely unrelated to #978.
Checklist
- I have looked through existing issues to make sure that this bug has not been reported before
- I have provided a descriptive title for this issue
- I have made sure that that this bug is reproducible on the latest version of the application
- I have provided all the information needed to reproduce this bug as efficiently as possible
- I have sponsored this project
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 24 (12 by maintainers)
I changed the folder and still got the error.
I solved the issue thanks @Tyrrrz . I importantly identified why it’s happening. The volume mount that the docker compose generated to the container was generated via docker compose, I didn’t use
mkdirTherefore usingllI realized it had root owners. Which caused the permission errors therefore use the guidelines stated in https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Docker.md#unix-permissions-issues to solve the permission error for the directory.My bad, try now @eelegiap (when this build finishes: https://github.com/Tyrrrz/DiscordChatExporter/actions/runs/7731406381)
@Silex thanks a lot, that was very insightful. Would you be able to PR one of your described solutions?
If I may give my two cents, because it’s a classic recurring problem for many images, the pattern other images use is:
You don’t have to follow this, but it has the advantage so running your container for the first time sets the permissions the correct way.
With your image the way it’s designed atm, what you have to do at the moment is:
On hosts where the current user is already 1000, the chown is not necessary, and because it’s what happens with most people you never notice the problem. But then one user has a UID of 1001 and boom, you can this bug and you need the chown.
I suggest you either switch to the pattern above or document that you need to chown to 1000:1000.