github.com/bugraaydogar/snapd@v0.0.0-20210315170335-8c70bb858939/interfaces/builtin/netlink_audit.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 netlinkAuditSummary = `allows access to kernel audit system through netlink`
    23  
    24  const netlinkAuditBaseDeclarationSlots = `
    25    netlink-audit:
    26      allow-installation:
    27        slot-snap-type:
    28          - core
    29      deny-auto-connection: true
    30  `
    31  
    32  const netlinkAuditConnectedPlugSecComp = `
    33  # Description: Can use netlink to read/write to kernel audit system.
    34  bind
    35  socket AF_NETLINK - NETLINK_AUDIT
    36  `
    37  
    38  const netlinkAuditConnectedPlugAppArmor = `
    39  # Description: Can use netlink to read/write to kernel audit system.
    40  network netlink,
    41  
    42  # CAP_NET_ADMIN required for multicast netlink sockets per 'man 7 netlink'
    43  capability net_admin,
    44  
    45  # CAP_AUDIT_READ required to read the audit log via the netlink multicast socket
    46  # per 'man 7 capabilities'
    47  capability audit_read,
    48  
    49  # CAP_AUDIT_WRITE required to write to the audit log via the netlink multicast
    50  # socket per 'man 7 capabilities'
    51  capability audit_write,
    52  `
    53  
    54  func init() {
    55  	registerIface(&commonInterface{
    56  		name:                  "netlink-audit",
    57  		summary:               netlinkAuditSummary,
    58  		implicitOnCore:        true,
    59  		implicitOnClassic:     true,
    60  		baseDeclarationSlots:  netlinkAuditBaseDeclarationSlots,
    61  		connectedPlugSecComp:  netlinkAuditConnectedPlugSecComp,
    62  		connectedPlugAppArmor: netlinkAuditConnectedPlugAppArmor,
    63  	})
    64  }