Bubblewrap integration broke user thumbnailers

Bug #1808702 reported by Romano Giannetti
34
This bug affects 6 people
Affects Status Importance Assigned to Milestone
gnome-desktop3 (Ubuntu)
Fix Released
Low
Unassigned

Bug Description

This bug is related to https://bugs.launchpad.net/ubuntu/+source/gnome-desktop3/+bug/1795668 and to the question in Ubuntu Stackexchange https://askubuntu.com/questions/1088539/custom-thumbnailers-don-t-work-on-ubuntu-18-10-and-18-04

The recent hardening on thumbnailers by using bubblewrap is causing a problem with user-installed thumbnailers. Consider this (for example) thumbnailer to add a small Dilbert icon to the GIMP .xcf files:

#!/bin/bash

tmpfile1=$(tempfile --directory /tmp --prefix xcft --suffix .png)
trap 'rm -rf $tmpfile1' INT EXIT TERM

die() {
  echo >&2 "$@"
  rm -rf $tmpfile1
  exit 1
}

# The script will be called with parameters : -s %s %u %o
# -s %s: vertical size, %u: input url, %o: output file

if [ $1 = "-s" ]; then
   size=$2
   uin=$3
   fout=$4
else
   size=32 #default size
   uin=$1
   fout=$2
fi

# uin es una url, eliminar "file://"
fin="${uin#file://*}"

/usr/bin/gnome-xcf-thumbnailer -s $size "$fin" $tmpfile1 || die "gnome-xcf-thumbnailer failed"
/usr/bin/composite-im6.q16 -gravity southeast \
   \( -resize $((size/2))x$((size/2)) /usr/share/gimp/2.0/images/wilber.png \) \
   \( -resize $sizex$size $tmpfile1 \) "$fout" || die "convert failed"

rm -rf $tmpfile1
exit 0

It used to work before the last update to use bubblewrap, and now doesn't work anymore. I tried to dig into https://github.com/GNOME/gnome-desktop/blob/master/libgnome-desktop/gnome-desktop-thumbnail-script.c to see what happens, and I concluded that the "reinforced" thumbnail generator do this:

mkdir /tmp/temporary

bwrap --ro-bind /usr /usr \
    --ro-bind /etc/ld.so.cache /etc/ld.so.cache \
    --ro-bind /bin /bin \
    --ro-bind /lib64 /lib64 \
    --ro-bind /lib /lib \
    --ro-bind /sbin /sbin \
    --proc /proc \
    --dev /dev \
    --chdir / \
    --setenv GIO_USE_VFS local \
    --unshare-all \
    --die-with-parent \
    --bind /tmp/temporary /tmp \
    --ro-bind /home/romano/software/thumbnailers/test/rgttiwm.xcf /tmp/gnome-desktop-file-to-thumbnail.xcf \
    /usr/bin/xcf-thumb -s 128 file:///tmp/gnome-desktop-file-to-thumbnail.xcf /tmp/gnome-desktop-thumbnailer.png
    #
cp /tmp/temporary/gnome-desktop-thumbnailer.png test.png

...and this way, my thumbnailer did succeed in creating the PNG with the correct preview. But when called internally by gnome, it fails, and creates a strange "~/.cache/thumbnailer/fail" file containing the following:

�PNG

IHDRĉd�EtEXtThumb::URIfile:///home/romano/software/thumbnailers/test/rgttiwm.xcf����tEXtThumb::MTime1380735765�y�O tEXtSoftwareGNOME::ThumbnailFactoryo
[...]

Revision history for this message
Romano Giannetti (romano-giannetti) wrote :

Notice anyway that one of the problems was that originally the thumbnailer called

     /usr/bin/composite

which, do to the alternative setup in .deb packages, was a link to /etc/alternatives/composite that pointed back to the real binary; probably the "/etc/alternatives/" directory should be added to the bind-ed directories...

Revision history for this message
Romano Giannetti (romano-giannetti) wrote :

Ok, the problem is that the commit from:

https://gitlab.gnome.org/GNOME/gnome-desktop/commit/259e7e4edb0d9b84fb7cf0847149ff8d42ab9a56

should be added, since Ubuntu/Debian has unmerged /usr.

Also, the problem with alternatives still stands, see https://gitlab.gnome.org/GNOME/gnome-desktop/issues/92

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in gnome-desktop3 (Ubuntu):
status: New → Confirmed
Revision history for this message
Sebastien Bacher (seb128) wrote :

the commit you mentioned is already in Ubuntu since https://bugs.launchpad.net/ubuntu/+source/gnome-desktop3/3.28.2-0ubuntu1.2

Revision history for this message
Romano Giannetti (romano-giannetti) wrote :

Indeed. So it must be something different; the problem with alternative is real, but nevertheless the aforementioned thumbnailer does not work even with the absolute path to composite...

Will dig a bit more. The puzzling thing is that using the wrapper script from http://bernaerts.dyndns.org/linux/74-ubuntu/360-ubuntu-nautilus-external-thumbnailer-failure *does* fix things...

Revision history for this message
Romano Giannetti (romano-giannetti) wrote :

As an aside, can you hint where I can find the messages printed by the `g_warning()` in the code? I was utterly unable to find them...

Revision history for this message
c4pp4 (c4pp4) wrote :
Revision history for this message
Romano Giannetti (romano-giannetti) wrote :

@c4pp4, could be, but I think this is already in...

Revision history for this message
c4pp4 (c4pp4) wrote :

@Romano Giannetti

The commit is from Dec 13, 2018. It's in 3.31.4.

Revision history for this message
Romano Giannetti (romano-giannetti) wrote :

@c4pp4 --- you're right. So probably the only thing we need is the bind of /etc/alternatives; upstream seems to agree it's the only way to go: https://gitlab.gnome.org/GNOME/gnome-desktop/issues/92

Revision history for this message
Thomas Debesse (illwieckz) wrote :

Hi, I'm getting the exact same problem with my thumbnailer:
https://github.com/illwieckz/crunch-thumbnailer

After investigations using "G_MESSAGES_DEBUG=all" I discovered the thumbnailer is called by nautilus this way:

bwrap --ro-bind /usr /usr --ro-bind /etc/ld.so.cache /etc/ld.so.cache --ro-bind /bin /bin --ro-bind /lib64 /lib64 --ro-bind /lib /lib --ro-bind /sbin /sbin --ro-bind-try /var/cache/fontconfig /var/cache/fontconfig --proc /proc --dev /dev --chdir / --setenv GIO_USE_VFS local --unshare-all --die-with-parent --setenv G_MESSAGES_DEBUG all --bind /tmp/gnome-desktop-thumbnailer-M7A75Z /tmp --ro-bind /home/illwieckz/Mapping/Unvanquished/InterstellarOasis/build/test/map-metro_test.dpkdir/textures/metro/alumb_t.crn /tmp/gnome-desktop-file-to-thumbnail.crn crunch-thumbnailer -s 256 /tmp/gnome-desktop-file-to-thumbnail.crn /tmp/gnome-desktop-thumbnailer.png

My thumbnailer is calling the "convert" tool from ImageMagick, but convert is an "alternative":

$ readlink /usr/bin/convert
/etc/alternatives/convert
$ readlink /etc/alternatives/convert
/usr/bin/convert-im6.q16

Since "/etc/alternatives" is not bound by bwrap, the thumnailer fails. Any ETA for the fix?

Revision history for this message
Haowei Wen (yushijinhun) wrote :

The "/etc/alternatives" problem breaks totem-video-thumbnailer, causing thumbnails of some MP4 files can't be shown. (see https://gitlab.gnome.org/GNOME/gnome-desktop/-/issues/92#note_888505)

Revision history for this message
Sebastien Bacher (seb128) wrote :

The issue has been fixed upstream with that commit now
https://gitlab.gnome.org/GNOME/gnome-desktop/-/commit/df477a3d
the change will land in the next update (and is probably a candidate for a SRU)

Changed in gnome-desktop3 (Ubuntu):
importance: Undecided → Low
status: Confirmed → Fix Committed
Revision history for this message
Sebastien Bacher (seb128) wrote :

The issue is fixed in G now

Changed in gnome-desktop3 (Ubuntu):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.