github.com/meulengracht/snapd@v0.0.0-20210719210640-8bde69bcc84e/interfaces/builtin/media_control.go (about)

     1  // -*- Mode: Go; indent-tabs-mode: t -*-
     2  
     3  /*
     4   * Copyright (C) 2021 Canonical Ltd
     5   *
     6   * This program is free software: you can redistribute it and/or modify
     7   * it under the terms of the GNU General Public License version 3 as
     8   * published by the Free Software Foundation.
     9   *
    10   * This program is distributed in the hope that it will be useful,
    11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
    12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    13   * GNU General Public License for more details.
    14   *
    15   * You should have received a copy of the GNU General Public License
    16   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    17   *
    18   */
    19  
    20  package builtin
    21  
    22  // See https://www.kernel.org/doc/Documentation/userspace-api/media/mediactl/media-controller-intro.rst
    23  const mediaControlSummary = `allows access to media control devices`
    24  
    25  // The kernel media controller allows connecting and configuring
    26  // media hardware subsystems.
    27  // These operations should be considered privileged since the driver
    28  // assumes trusted input, therefore require manual connection.
    29  const mediaControlBaseDeclarationSlots = `
    30    media-control:
    31      allow-installation:
    32        slot-snap-type:
    33          - core
    34      deny-auto-connection: true
    35  `
    36  
    37  const mediaControlConnectedPlugAppArmor = `
    38  # Control of media devices
    39  /dev/media[0-9]* rw,
    40  
    41  # Access to V4L subnodes configuration
    42  # See https://www.kernel.org/doc/html/v4.12/media/uapi/v4l/dev-subdev.html
    43  /dev/v4l-subdev[0-9]* rw,
    44  `
    45  
    46  var mediaControlConnectedPlugUDev = []string{
    47  	`SUBSYSTEM=="media", KERNEL=="media[0-9]*"`,
    48  	`SUBSYSTEM=="video4linux", KERNEL=="v4l-subdev[0-9]*"`,
    49  }
    50  
    51  func init() {
    52  	registerIface(&commonInterface{
    53  		name:                  "media-control",
    54  		summary:               mediaControlSummary,
    55  		implicitOnCore:        true,
    56  		implicitOnClassic:     true,
    57  		baseDeclarationSlots:  mediaControlBaseDeclarationSlots,
    58  		connectedPlugAppArmor: mediaControlConnectedPlugAppArmor,
    59  		connectedPlugUDev:     mediaControlConnectedPlugUDev,
    60  	})
    61  }