diddlesnaps / tvheadend

MIT License
10 stars 0 forks source link

[Bug]: oscam cannot open card reader on /dev/ttyUSB0: permission denied #19

Open AdrieVanDijk opened 2 years ago

AdrieVanDijk commented 2 years ago

What happened?

I have used this snap for several years on a raspberry pi 4 with ubuntu 20.04, but now I have a problem with oscam. I followed your comment here to enable ipv6. That works, but now oscam gets 'permission denied' when it tries to open my card reader on /dev/ttyUSB0. The problem looks similar to the one you gave this comment on, but that solution does not seem to work for tvheadend because it does not have a 'serial-port' plug. How do other people do this? I have tried to install it with the --classic flag, but that is ignored, because it is a strictly confined snap.

What should have happened?

oscam shoud be able to access my card reader

Output of snap info $snap_name

name:      tvheadend
summary:   TV streaming server supporting DVB, ATSC, IPTV, and SAT>IP
publisher: Daniel Llewellyn (diddledani)
store-url: https://snapcraft.io/tvheadend
contact:   https://github.com/diddlesnaps/tvheadend/issues
license:   unset
description: |
  Tvheadend is a TV streaming server and digital video recorder supporting DVB-S, DVB-S2, DVB-C,
  DVB-C2, DVB-T, DVB-T2, ATSC, IPTV, SAT>IP and other formats. It can also stream and record from
  HDHomeRun devices.
  Once installed use your web browser to navigate to `http://[IP-Address]:9981/` (You can use
  `127.0.0.1` for the IP Address if your browser and tvheadend are on the same computer.)

  Once installed use your web browser to navigate to `http://[IP-Address]:9981/ `to set up the
  server. You can use `127.0.0.1` for the IP Address if your browser and tvheadend are on the same
  computer, or you can find the TVHeadend icon in your desktop menu.

  You can change the listening port and IP with `snapctl set tvheadend tvh-http-port=9981` and
  `snapctl set tvheadend tvh-ip=0.0.0.0`. You can also change the port for HTSP streaming
  connections with `snapctl set tvheadend tvh-htsp-port=9982`

  OSCam's web interface is listening on port `8888` by default. You can change this by editing the
  file returned by `tvheadend.oscam-config`. e.g. `sudo $EDITOR $(tvheadend.oscam-config)`. This is
  an ini-style file where the web interface IP Address and Port are configured as below:

      [global]
      serverip =

      [webif]
      httpport =

   See [the OSCam configuration
   reference](http://www.streamboard.tv/wiki/OSCam/en/Config/oscam.conf)  for details on the
   accepted options for the configuration file.

  - Upstream Project: https://tvheadend.org/
  - snapcraft.yaml Build Definition:
  https://github.com/diddlesnaps/tvheadend/blob/master/snap/snapcraft.yaml

  This Snap package is not maintained by the TVHeadend project. Please report issues here:
  https://github.com/diddlesnaps/tvheadend/issues
commands:
  - tvheadend.oscam-config
  - tvheadend.oscam-webui
  - tvheadend.reset-permissions
  - tvheadend.tvheadend-webui
services:
  tvheadend.oscam: simple, enabled, inactive
  tvheadend:       simple, enabled, active
snap-id:      BLigMwxrfwBKQpnk0iQHu8hZts8Fgf2d
tracking:     latest/stable
refresh-date: today at 14:56 CEST
channels:
  latest/stable:    4.2.8 2022-01-09 (202) 142MB -
  latest/candidate: ↑                            
  latest/beta:      ↑                            
  latest/edge:      4.2.8 2022-03-25 (211) 142MB -
installed:          4.2.8            (202) 142MB -

Output of snap connections $snap_name

Interface        Plug                       Slot              Notes
avahi-control    tvheadend:avahi-control    -                 -
desktop          tvheadend:desktop          :desktop          -
dvb              tvheadend:dvb              :dvb              -
network          tvheadend:network          :network          -
network-bind     tvheadend:network-bind     :network-bind     -
opengl           tvheadend:opengl           :opengl           -
removable-media  tvheadend:removable-media  :removable-media  manual

Output of snap version

snap    2.54.4
snapd   2.54.4
series  16
ubuntu  20.04
kernel  5.4.0-1058-raspi

Relevant log output

[21669.412321] audit: type=1326 audit(1650392991.034:63146): auid=4294967295 uid=0 gid=0 ses=4294967295 pid=78933 comm="oscam" exe="/snap/tvheadend/202/usr/local/bin/oscam" sig=0 arch=c00000b7 syscall=140 compat=0 ip=0xffffa8245528 code=0x50000
[21669.418757] audit: type=1400 audit(1650392991.042:63147): apparmor="DENIED" operation="open" profile="snap.tvheadend.oscam" name="/dev/ttyUSB0" pid=78933 comm="wr08-ziggo" requested_mask="wr" denied_mask="wr" fsuid=0 ouid=0
[21671.419739] audit: type=1400 audit(1650392993.042:63148): apparmor="DENIED" operation="open" profile="snap.tvheadend.oscam" name="/dev/ttyUSB0" pid=78933 comm="wr08-ziggo" requested_mask="wr" denied_mask="wr" fsuid=0 ouid=0
[21673.420737] audit: type=1400 audit(1650392995.046:63149): apparmor="DENIED" operation="open" profile="snap.tvheadend.oscam" name="/dev/ttyUSB0" pid=78933 comm="wr08-ziggo" requested_mask="wr" denied_mask="wr" fsuid=0 ouid=0
[21675.421146] audit: type=1400 audit(1650392997.045:63150): apparmor="DENIED" operation="open" profile="snap.tvheadend.oscam" name="/dev/ttyUSB0" pid=78933 comm="wr08-ziggo" requested_mask="wr" denied_mask="wr" fsuid=0 ouid=0
[21677.421383] audit: type=1400 audit(1650392999.045:63151): apparmor="DENIED" operation="open" profile="snap.tvheadend.oscam" name="/dev/ttyUSB0" pid=78933 comm="wr08-ziggo" requested_mask="wr" denied_mask="wr" fsuid=0 ouid=0
[21679.421627] audit: type=1400 audit(1650393001.045:63152): apparmor="DENIED" operation="open" profile="snap.tvheadend.oscam" name="/dev/ttyUSB0" pid=78933 comm="wr08-ziggo" requested_mask="wr" denied_mask="wr" fsuid=0 ouid=0
[21681.421863] audit: type=1400 audit(1650393003.045:63153): apparmor="DENIED" operation="open" profile="snap.tvheadend.oscam" name="/dev/ttyUSB0" pid=78933 comm="wr08-ziggo" requested_mask="wr" denied_mask="wr" fsuid=0 ouid=0
[21683.422108] audit: type=1400 audit(1650393005.045:63154): apparmor="DENIED" operation="open" profile="snap.tvheadend.oscam" name="/dev/ttyUSB0" pid=78933 comm="wr08-ziggo" requested_mask="wr" denied_mask="wr" fsuid=0 ouid=0
[21685.422380] audit: type=1400 audit(1650393007.045:63155): apparmor="DENIED" operation="open" profile="snap.tvheadend.oscam" name="/dev/ttyUSB0" pid=78933 comm="wr08-ziggo" requested_mask="wr" denied_mask="wr" fsuid=0 ouid=0
[21687.423117] audit: type=1400 audit(1650393009.045:63156): apparmor="DENIED" operation="open" profile="snap.tvheadend.oscam" name="/dev/ttyUSB0" pid=78933 comm="wr08-ziggo" requested_mask="wr" denied_mask="wr" fsuid=0 ouid=0
[21689.423366] audit: type=1400 audit(1650393011.045:63157): apparmor="DENIED" operation="open" profile="snap.tvheadend.oscam" name="/dev/ttyUSB0" pid=78933 comm="wr08-ziggo" requested_mask="wr" denied_mask="wr" fsuid=0 ouid=0

Teminal output of app

2022/04/19 20:29:51 00000000 s     (main) System name    = Linux
    2022/04/19 20:29:51 00000000 s     (main) Host name      = pi4
    2022/04/19 20:29:51 00000000 s     (main) Release        = 5.4.0-1058-raspi
    2022/04/19 20:29:51 00000000 s     (main) Version        = #65-Ubuntu SMP PREEMPT Fri Mar 25 12:29:46 UTC 2022
    2022/04/19 20:29:51 00000000 s     (main) Machine        = aarch64
    2022/04/19 20:29:51 00000000 s     (main) creating pidfile /tmp/oscam.pid with pid 78933
    2022/04/19 20:29:51 00000000 s   (config) userdb reloaded: 1 accounts loaded, 0 expired, 0 disabled
    2022/04/19 20:29:51 00000000 s     (main) signal handling initialized
    2022/04/19 20:29:51 00000000 s      (net) monitor: initialized (fd=6, port=1988)
    2022/04/19 20:29:51 00000000 s      (net) newcamd: initialized (fd=7, port=10000)
    2022/04/19 20:29:51 00000000 s      (net) -> CAID: 0604 PROVID: 075D27
    2022/04/19 20:29:51 00000000 s   (reader) ziggo [smargo] creating thread for device /dev/ttyUSB0
    2022/04/19 20:29:51 00000000 s     (main) waiting for local card init
    2022/04/19 20:29:51 6480112C r   (reader) ziggo [smargo] ERROR: Opening device /dev/ttyUSB0 (errno=13 Permission denied)
    2022/04/19 20:29:51 6480112C r   (reader) ziggo [smargo] Cannot open device: /dev/ttyUSB0
    2022/04/19 20:29:51 1BCCB81E h    (webif) webif: decompressed 184845 bytes back into 488736 bytes
    2022/04/19 20:29:51 1BCCB81E h    (webif) HTTP Server running. ip=:: port=8888
    2022/04/19 20:29:53 6480112C r   (reader) ziggo [smargo] ERROR: Opening device /dev/ttyUSB0 (errno=13 Permission denied)
    2022/04/19 20:29:53 6480112C r   (reader) ziggo [smargo] Cannot open device: /dev/ttyUSB0
    2022/04/19 20:29:55 6480112C r   (reader) ziggo [smargo] ERROR: Opening device /dev/ttyUSB0 (errno=13 Permission denied)
    2022/04/19 20:29:55 6480112C r   (reader) ziggo [smargo] Cannot open device: /dev/ttyUSB0
    2022/04/19 20:29:57 6480112C r   (reader) ziggo [smargo] ERROR: Opening device /dev/ttyUSB0 (errno=13 Permission denied)
    2022/04/19 20:29:57 6480112C r   (reader) ziggo [smargo] Cannot open device: /dev/ttyUSB0
    2022/04/19 20:29:59 6480112C r   (reader) ziggo [smargo] ERROR: Opening device /dev/ttyUSB0 (errno=13 Permission denied)
    2022/04/19 20:29:59 6480112C r   (reader) ziggo [smargo] Cannot open device: /dev/ttyUSB0
    2022/04/19 20:30:01 6480112C r   (reader) ziggo [smargo] ERROR: Opening device /dev/ttyUSB0 (errno=13 Permission denied)
    2022/04/19 20:30:01 6480112C r   (reader) ziggo [smargo] Cannot open device: /dev/ttyUSB0
    2022/04/19 20:30:03 6480112C r   (reader) ziggo [smargo] ERROR: Opening device /dev/ttyUSB0 (errno=13 Permission denied)
    2022/04/19 20:30:03 6480112C r   (reader) ziggo [smargo] Cannot open device: /dev/ttyUSB0
    2022/04/19 20:30:05 6480112C r   (reader) ziggo [smargo] ERROR: Opening device /dev/ttyUSB0 (errno=13 Permission denied)
    2022/04/19 20:30:05 6480112C r   (reader) ziggo [smargo] Cannot open device: /dev/ttyUSB0
    2022/04/19 20:30:07 6480112C r   (reader) ziggo [smargo] ERROR: Opening device /dev/ttyUSB0 (errno=13 Permission denied)
    2022/04/19 20:30:07 6480112C r   (reader) ziggo [smargo] Cannot open device: /dev/ttyUSB0
    2022/04/19 20:30:09 6480112C r   (reader) ziggo [smargo] ERROR: Opening device /dev/ttyUSB0 (errno=13 Permission denied)
    2022/04/19 20:30:09 6480112C r   (reader) ziggo [smargo] Cannot open device: /dev/ttyUSB0
    2022/04/19 20:30:11 6480112C r   (reader) ziggo [smargo] ERROR: Opening device /dev/ttyUSB0 (errno=13 Permission denied)
    2022/04/19 20:30:11 6480112C r   (reader) ziggo [smargo] Cannot open device: /dev/ttyUSB0
    2022/04/19 20:30:11 00000000 s     (main) init for all local cards done
    2022/04/19 20:30:11 00000000 s (emmcache) loaded 0 emmcache records from /tmp/oscam.emmcache in 0 ms
    2022/04/19 20:30:11 00000000 s (emmcache) loaded 0 emmstat records from /tmp/oscam.emmstat in 0 ms
    2022/04/19 20:30:11 00000000 s (anticasc) anti cascading disabled
    2022/04/19 20:30:11 00000000 s     (gbox) local gbox failed init
    2022/04/19 20:30:11 4DC72EC6 c  (newcamd) client connected to 10000 port
    2022/04/19 20:30:11 4DC72EC6 c   (client) anonymous disconnected from ::1
    2022/04/19 20:30:11 0E5B78BC c  (newcamd) client connected to 10000 port
    2022/04/19 20:30:11 0E5B78BC c        (-) -- Skipped 1 duplicated log lines --
    2022/04/19 20:30:11 0E5B78BC c   (client) anonymous disconnected from ::1
    2022/04/19 20:30:11 0635B055 c   (client) encrypted newcamd:10000-client ::1 granted (tvheadend, au=on (1 reader))
    2022/04/19 20:30:11 0635B055 c  (newcamd) user tvheadend authenticated successfully (Tvheadend)
    2022/04/19 20:30:11 0635B055 c  (newcamd) AU disabled for user tvheadend