github.com/bugraaydogar/snapd@v0.0.0-20210315170335-8c70bb858939/interfaces/builtin/shutdown.go (about)

     1  // -*- Mode: Go; indent-tabs-mode: t -*-
     2  
     3  /*
     4   * Copyright (C) 2016 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 shutdownSummary = `allows shutting down or rebooting the system`
    23  
    24  const shutdownBaseDeclarationSlots = `
    25    shutdown:
    26      allow-installation:
    27        slot-snap-type:
    28          - core
    29      deny-auto-connection: true
    30  `
    31  
    32  const shutdownConnectedPlugAppArmor = `
    33  # Description: Can reboot, power-off and halt the system.
    34  
    35  #include <abstractions/dbus-strict>
    36  
    37  dbus (send)
    38      bus=system
    39      path=/org/freedesktop/systemd1
    40      interface=org.freedesktop.systemd1.Manager
    41      member={Reboot,PowerOff,Halt}
    42      peer=(label=unconfined),
    43  
    44  dbus (send)
    45      bus=system
    46      path=/org/freedesktop/login1
    47      interface=org.freedesktop.login1.Manager
    48      member={PowerOff,Reboot,Suspend,Hibernate,HybridSleep,CanPowerOff,CanReboot,CanSuspend,CanHibernate,CanHybridSleep,ScheduleShutdown,CancelScheduledShutdown,SetWallMessage}
    49      peer=(label=unconfined),
    50  
    51  # Allow clients to introspect
    52  # do not use peer=(label=unconfined) here since this is DBus activated
    53  dbus (send)
    54      bus=system
    55      path=/org/freedesktop/systemd1
    56      interface=org.freedesktop.DBus.Introspectable
    57      member=Introspect,
    58  dbus (send)
    59      bus=system
    60      path=/org/freedesktop/login1
    61      interface=org.freedesktop.DBus.Introspectable
    62      member=Introspect,
    63  `
    64  
    65  func init() {
    66  	registerIface(&commonInterface{
    67  		name:                  "shutdown",
    68  		summary:               shutdownSummary,
    69  		implicitOnCore:        true,
    70  		implicitOnClassic:     true,
    71  		baseDeclarationSlots:  shutdownBaseDeclarationSlots,
    72  		connectedPlugAppArmor: shutdownConnectedPlugAppArmor,
    73  	})
    74  }