leovoel / BeautifulDiscord

Adds custom CSS support to Discord.
MIT License
700 stars 72 forks source link

Linux - doesn't work at all if the discord install directory has no write permissions #24

Closed tjb0607 closed 6 years ago

tjb0607 commented 7 years ago

with discord-canary installed via the AUR package, and thus installed in a read-only directory, this happens:

$ beautifuldiscord --css /home/tyler/discord/style.css 
Found DiscordCanary under /opt/discord-canary
Traceback (most recent call last):
  File "/usr/bin/beautifuldiscord", line 11, in <module>
    load_entry_point('BeautifulDiscord==0.1.0', 'console_scripts', 'beautifuldiscord')()
  File "/usr/lib/python3.6/site-packages/beautifuldiscord/app.py", line 143, in main
    if extract_asar():
  File "/usr/lib/python3.6/site-packages/beautifuldiscord/app.py", line 98, in extract_asar
    a.extract('./app')
  File "/usr/lib/python3.6/site-packages/beautifuldiscord/asar.py", line 276, in extract
    self._extract_directory('.', self.header['files'], path)
  File "/usr/lib/python3.6/site-packages/beautifuldiscord/asar.py", line 254, in _extract_directory
    os.makedirs(dest)
  File "/usr/lib/python3.6/os.py", line 210, in makedirs
    makedirs(head, mode, exist_ok)
  File "/usr/lib/python3.6/os.py", line 220, in makedirs
    mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: './app'

Running beautifuldiscord as root sorta works, but then due to the permissions of the files it creates, it makes discord itself only able to run as root.

A quick, simple fix would be to tell people to run sudo chmod -R a+w /opt/discord-canary or whatever the install directory is. Another fix would be to make running beautifuldiscord as root work without breaking discord for everyone but the root user, possibly even calling sudo to automate this if the directory has no write permissions to the user running it.

daelvn commented 7 years ago

You can actually run Discord as non-root after replacing the files. beautifuldiscord will find an app, replace it then relaunch Discord, this instance is relaunched as root and so the socket (/tmp/Discord.sock) has also root permissions. When you close Discord then reopen as a normal user, it should work fine. I think the solution would be making it not relaunch Discord, just replacing the files.

Rapptz commented 6 years ago

This should be fixed now since it no longer writes anywhere except in the home directory.