Files
snapd/cmd/snap-exec
Michael Vogt 0275484761 snap-exec: fix detection if cups interface is connected
* snap-exec: fix detection if `cups` interface is connected

The cups interface needs a way to set the environment variable
`CUPS_SERVER` if the `cups` interface is connected. However we
have no mechanism for setting environment vars based on interface
connections currently. To workaround this, the cups work added
a workaround in `snap-exec` that tried to detect if `cups` is
connected and when it is set the environment. Unfortunately the
code in there was too simplistic because it just checked if
the directory `/var/cups` exists. However ths dir now always
exists because it's needed as the mount point.

This commit fixes the detection by checking if `/var/cups` is
a bind mount. This is checked by looking at the `stat()` data
and the `dev_t` field in there. If they differ it means the
bind mount exists and the only thing that creates this bind
mount is the `cups` `MountConnectedPlug()` code.

This is not great but it fixes the spread failure we see
in the `cups-control` test (which is a real bug) and should
be good enough until we have a proper interface backend that
can set environment variables.

* tests: re-enable interfaces-cups-control test

For unclear reasons the error message on unplug changes when I
run this on my 20.04 system so I updated the tests - it most likely
because the test-snapd-cups-control-consumer snap moved from
core16 to core20 a week ago but that is not 100% confirmed.

* snap-exec: fix unit test for CUPS_SERVER workaround
2022-04-04 13:17:50 +02:00
..