github.com/kubiko/snapd@v0.0.0-20201013125620-d4f3094d9ddf/interfaces/builtin/power_control.go (about)

     1  // -*- Mode: Go; indent-tabs-mode: t -*-
     2  
     3  /*
     4   * Copyright (C) 2020 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 powerControlSummary = `allows setting system power settings`
    23  
    24  const powerControlBaseDeclarationSlots = `
    25    power-control:
    26      allow-installation:
    27        slot-snap-type:
    28          - core
    29      deny-auto-connection: true
    30  `
    31  
    32  // https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-devices-power
    33  const powerControlConnectedPlugAppArmor = `
    34  # Description: This interface allows setting system power settings.
    35  # Allow read of all power setting
    36  /sys/devices/**/power/{,*} r,
    37  
    38  # Allow configuring wakeup events for supported devices
    39  /sys/devices/**/power/wakeup w,
    40  
    41  # Allow configuring power management of supported devices at runtime
    42  /sys/devices/**/power/control w,
    43  
    44  # For now, omit configuring asynchronous callbacks since they are often unsafe
    45  # Also omit autosuspend delay and PM QoS for now.
    46  #/sys/devices/**/power/async w,
    47  #/sys/devices/**/power/autosuspend_delay_ms w,
    48  #/sys/devices/**/power/pm_qos* w,
    49  `
    50  
    51  func init() {
    52  	registerIface(&commonInterface{
    53  		name:                  "power-control",
    54  		summary:               powerControlSummary,
    55  		implicitOnCore:        true,
    56  		implicitOnClassic:     true,
    57  		baseDeclarationSlots:  powerControlBaseDeclarationSlots,
    58  		connectedPlugAppArmor: powerControlConnectedPlugAppArmor,
    59  	})
    60  }