Calibre installation lacks the necessary group - no filesystem permissions

Problem Description
A user cannot read a calibre book using the web client.

Steps to Reproduce

  1. Log in to Freedombox (user has admin + calibre + all other permission)
  2. Click on Apps, Calibre, Launch Web Client
  3. Select a Library, select a Book
  4. Hit the Read button at the top of the page

Expected Results
I expect a web epub reader to be launched allowing the user to read the book.

Actual results
Failed to prepare book for reading
Could not open Starfish. There was an error processing the book, click “Show details” for more information
Traceback (most recent call last):
File “/usr/lib/calibre/calibre/utils/ipc/simple_worker.py”, line 289, in main
res = {‘result’:func(*args, **kwargs)}
File “/usr/lib/calibre/calibre/srv/render_book.py”, line 524, in render
Container(pathtoebook, output_dir, book_hash=book_hash)
File “/usr/lib/calibre/calibre/srv/render_book.py”, line 178, in init
ContainerBase.init(self, tdir, opfpath, log)
File “/usr/lib/calibre/calibre/ebooks/oeb/polish/container.py”, line 288, in init
raise InvalidBook(‘Could not locate opf file: %r’%opfpath)
InvalidBook: Could not locate opf file: u’/var/lib/private/calibre-server-freedombox/.cache/calibre/srvb/s/4DOAnr/content.opf’

Screenshot

Information

  • FreedomBox version: You are running Debian GNU/Linux 10 (buster) and FreedomBox version 21.4. FreedomBox is up to date.
  • Hardware: 4.19.0-16-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64 GNU/Linux
  • How did you install FreedomBox?: Debian Stable netinst + DEBIAN_FRONTEND=noninteractive apt-get -y install freedombox

Root Cause Analysis
A calibre group does not exist, and users with calibre permission are not assigned group 64238. Calibre installation creates directories under /var/lib/private/calibre-server-freedombox using group 64238. Filesystem operations are prevented for lack of permissions for the user.

  1. /var/lib/private/calibre-server-freedombox/.cache/calibre/srvb/s/4DOAnr/content.opf does not exit.
  2. user cannot enter the containing directory.
  3. user is not a member of folder’s group 64238
  4. group 64238 is not defined in the OS
  5. calibre group is not defined in OS

Workaround Attempts

Create a group 64238 with name calibre:

# groupadd -g 64238 calibre
groupadd: group ‘calibre’ already exists

Add user to 64238 group:

# usermod -a -G 64238 username
usermod: group ‘64238’ does not exist

Assign calibre as a supplementary group to user:

# usermod -a -G calibre username
This command is successful.

  1. Log out of Freedombox
  2. Log in to Freedombox as user with admin + calibre + everything else permission
  3. Open Calibre, Library, Book, and select Read.
    Actual Results:
    Failed to prepare book for reading
    Could not open Behemoth. There was an error processing the book, click “Show details” for more information
    Traceback (most recent call last):
    File “/usr/lib/calibre/calibre/utils/ipc/simple_worker.py”, line 289, in main
    res = {‘result’:func(*args, **kwargs)}
    File “/usr/lib/calibre/calibre/srv/render_book.py”, line 524, in render
    Container(pathtoebook, output_dir, book_hash=book_hash)
    File “/usr/lib/calibre/calibre/srv/render_book.py”, line 178, in init
    ContainerBase.init(self, tdir, opfpath, log)
    File “/usr/lib/calibre/calibre/ebooks/oeb/polish/container.py”, line 288, in init
    raise InvalidBook(‘Could not locate opf file: %r’%opfpath)
    InvalidBook: Could not locate opf file: u’/var/lib/private/calibre-server-freedombox/.cache/calibre/srvb/s/mJnnDx/content.opf’