gitee.com/mysnapcore/mysnapd@v0.1.0/interfaces/builtin/scsi_generic.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  const scsiGenericSummary = `allows access to SCSI generic driver devices`
    23  
    24  const scsiGenericBaseDeclarationSlots = `
    25    scsi-generic:
    26      allow-installation:
    27        slot-snap-type:
    28          - core
    29      deny-auto-connection: true
    30  `
    31  const scsiGenericBaseDeclarationPlugs = `
    32    block-devices:
    33      allow-installation: false
    34      deny-auto-connection: true
    35  `
    36  
    37  const scsiGenericConnectedPlugAppArmor = `
    38  # allow read,write access to generic scsi devices
    39  # ref: https://www.kernel.org/doc/Documentation/scsi/scsi-generic.txt
    40  /dev/sg[0-9]* rw,
    41  `
    42  
    43  var scsiGenericConnectedPlugUDev = []string{
    44  	// ref: https://www.kernel.org/doc/Documentation/scsi/scsi-generic.txt
    45  	`KERNEL=="sg[0-9]*"`,
    46  }
    47  
    48  func init() {
    49  	registerIface(&commonInterface{
    50  		name:                  "scsi-generic",
    51  		summary:               scsiGenericSummary,
    52  		implicitOnCore:        true,
    53  		implicitOnClassic:     true,
    54  		baseDeclarationSlots:  scsiGenericBaseDeclarationSlots,
    55  		connectedPlugAppArmor: scsiGenericConnectedPlugAppArmor,
    56  		connectedPlugUDev:     scsiGenericConnectedPlugUDev,
    57  	})
    58  }