github.com/chipaca/snappy@v0.0.0-20210104084008-1f06296fe8ad/interfaces/builtin/network_setup_control.go (about)

     1  // -*- Mode: Go; indent-tabs-mode: t -*-
     2  
     3  /*
     4   * Copyright (C) 2017 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  const networkSetupControlSummary = `allows access to netplan configuration`
    23  
    24  const networkSetupControlBaseDeclarationSlots = `
    25    network-setup-control:
    26      allow-installation:
    27        slot-snap-type:
    28          - core
    29      deny-auto-connection: true
    30  `
    31  
    32  const networkSetupControlConnectedPlugAppArmor = `
    33  # Description: Can read/write netplan configuration files
    34  
    35  /etc/netplan/{,**} rw,
    36  /etc/network/{,**} rw,
    37  /etc/systemd/network/{,**} rw,
    38  
    39  # netplan generate
    40  /run/ r,
    41  /run/systemd/network/{,**} r,
    42  /run/systemd/network/*-netplan-* w,
    43  /run/NetworkManager/conf.d/{,**} r,
    44  /run/NetworkManager/conf.d/*netplan*.conf* w,
    45  
    46  /run/udev/rules.d/ rw,                 # needed for cloud-init
    47  /run/udev/rules.d/[0-9]*-netplan-* rw,
    48  
    49  #include <abstractions/dbus-strict>
    50  
    51  # Allow use of Netplan Apply API, used to apply network configuration
    52  dbus (send)
    53      bus=system
    54      interface=io.netplan.Netplan
    55      path=/io/netplan/Netplan
    56  	member=Apply
    57  	peer=(label=unconfined),
    58  
    59  # Allow use of Netplan Info API, used to get information on available netplan
    60  # features and version
    61  dbus (send)
    62  	bus=system
    63  	interface=io.netplan.Netplan
    64  	path=/io/netplan/Netplan
    65  	member=Info
    66  	peer=(label=unconfined),
    67  `
    68  
    69  func init() {
    70  	registerIface(&commonInterface{
    71  		name:                  "network-setup-control",
    72  		summary:               networkSetupControlSummary,
    73  		implicitOnCore:        true,
    74  		implicitOnClassic:     true,
    75  		baseDeclarationSlots:  networkSetupControlBaseDeclarationSlots,
    76  		connectedPlugAppArmor: networkSetupControlConnectedPlugAppArmor,
    77  	})
    78  }