Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp847776ybp; Fri, 11 Oct 2019 05:25:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqzjHHwAqyZvLAQ80C1PZJONoU+LHvJHVClcs6FY3GFRSduzj9/umOQkSDECgEMOmzjxbEQE X-Received: by 2002:a17:906:704:: with SMTP id y4mr13391186ejb.259.1570796711637; Fri, 11 Oct 2019 05:25:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570796711; cv=none; d=google.com; s=arc-20160816; b=THh2VX2ZSauW1/KIwKSGU0osrwl+LmNQcEYso9USFbah+L+tZuVo+Ht0dzc9ei2dgF G07LAI5Tck2lJ1oJ6XBu1saRq5tYPyuQkjWTe/srCllZiHMD9lx6A61A+1e51Dkba9M4 PaSUSEqZERB3QHi7swfeDNkAtj0xoQkIEdBLti6aNxcVaZA5uLuTH2qxCmS3Wv4t4pBn txjFZaG/QPv9b3T1tV1/W6R01/dxQ5xP4/hRXt5A80LMvlJL1PLlrnhlRpKq7prF/9Zv 3ZCyMB3Fl7AqBCrzOFwUO4I5HZu9kOMQl/MGe8z/wiy0+or3R3YH6nwaJS9C8ZTVhJEe CXBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=zPEIs0lUxFLfEYok2GIzQLdgem4WaYRvmHFm0GNaqN4=; b=ppq2/5kB4ClsErzvxb0FN1xmgslquAuyl4/pSeQdbWZGhbY8umaWVKQWlXG3A25HVe LmTRx6i3wYk24Pg3RUWC4WdbeEKF16lolLm86azB/Nw6wjG15dX+Tv0DvKUmJIw029O0 XEEK0MUwy1OKUq2qqo+/rS2sA+D/bQpRyYPRbvxjV/RRg9eOqZUg1Dj9i2ijFg0ntKGO +fLRpVCHKF9hfev6dS921SKBZGb/eDbHM2BPvghbel2t6p9g0vJMxqOWkrGMY7oXcVKW OoIB6gPv+qXuXgOr6xwmDmDv0SwoTjSv7W0enoWsX+tnj75T3woGWtshgF5sqn5E/6Dn 7Tnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bigon.be header.s=key1 header.b=fPuIG0uj; spf=pass (google.com: best guess record for domain of selinux-refpolicy-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=selinux-refpolicy-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j12si5130303ejx.282.2019.10.11.05.25.08; Fri, 11 Oct 2019 05:25:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of selinux-refpolicy-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@bigon.be header.s=key1 header.b=fPuIG0uj; spf=pass (google.com: best guess record for domain of selinux-refpolicy-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=selinux-refpolicy-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727907AbfJKMYW (ORCPT + 11 others); Fri, 11 Oct 2019 08:24:22 -0400 Received: from ithil.bigon.be ([163.172.57.153]:38286 "EHLO ithil.bigon.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728094AbfJKMYW (ORCPT ); Fri, 11 Oct 2019 08:24:22 -0400 Received: from localhost (localhost [IPv6:::1]) by ithil.bigon.be (Postfix) with ESMTP id 6A09120552 for ; Fri, 11 Oct 2019 14:24:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=bigon.be; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:from:from :received:received:received; s=key1; t=1570796658; x=1572611059; bh=VDBMM3T+nIZTLEf4vCmGy5L5xMwtcRhAcw++8Vtch9s=; b=fPuIG0ujndfl dvakFRjGl2VcWdZ/MQD44ct1OPKWr4G3OF16ABl9A/pHRM3q4wT3yzV+Ink/eVEJ CxJ4aokX5EqUhV1cdJIMvyXK5z3bCFszyPqjhJJ5I2XgLviQXxDiYxgCn3zVm013 pZVOMcHlj7BxsLFElOMUG5Pkv8rvG8I= Received: from ithil.bigon.be ([IPv6:::1]) by localhost (ithil.bigon.be [IPv6:::1]) (amavisd-new, port 10026) with ESMTP id 2j2eIqdn3BcL for ; Fri, 11 Oct 2019 14:24:18 +0200 (CEST) Received: from edoras.bigon.be (unknown [193.53.238.198]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bigon@bigon.be) by ithil.bigon.be (Postfix) with ESMTPSA for ; Fri, 11 Oct 2019 14:24:18 +0200 (CEST) Received: from bigon (uid 1000) (envelope-from bigon@bigon.be) id 220ec by edoras.bigon.be (DragonFly Mail Agent v0.12); Fri, 11 Oct 2019 14:24:16 +0200 From: Laurent Bigonville To: selinux-refpolicy@vger.kernel.org Subject: [PATCH 10/10] Allow vpnc to create and write its pid file in /run/NetworkManager Date: Fri, 11 Oct 2019 14:24:16 +0200 Message-Id: <20191011122416.14651-10-bigon@debian.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191011122416.14651-1-bigon@debian.org> References: <20191011122416.14651-1-bigon@debian.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: selinux-refpolicy-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: selinux-refpolicy@vger.kernel.org From: Laurent Bigonville The pid file is deleted by NetworkManager itself when the vpnc process exits NetworkManager call vpnc the following way: system_u:system_r:NetworkManager_t:s0 root 11692 0.0 0.0 166272 9472 ? Sl 12:58 0:00 /usr/lib/NetworkManager/nm-vpnc-service --bus-name org.freedesktop.NetworkManager.vpnc.Connection_21 system_u:system_r:vpnc_t:s0 root 11703 0.1 0.0 9900 4896 ? SL 12:58 0:00 /usr/sbin/vpnc --no-detach --pid-file /var/run/NetworkManager/nm-vpnc-fa482929-93ee-4c64-bfba-4ee31d70f35f.pid - ---- type=AVC msg=audit(07/10/19 10:38:35.131:931) : avc: denied { write } for pid=8653 comm=vpnc path=/run/NetworkManager/nm-vpnc-fa482929-93ee-4c64-bfba-4ee31d70f35f.pid dev="tmpfs" ino=112390 scontext=system_u:system_r:vpnc_t:s0 tcontext=system_u:object_r:NetworkManager_runtime_t:s0 tclass=file permissive=1 type=AVC msg=audit(07/10/19 10:38:35.131:931) : avc: denied { create } for pid=8653 comm=vpnc name=nm-vpnc-fa482929-93ee-4c64-bfba-4ee31d70f35f.pid scontext=system_u:system_r:vpnc_t:s0 tcontext=system_u:object_r:NetworkManager_runtime_t:s0 tclass=file permissive=1 type=AVC msg=audit(07/10/19 10:38:35.131:931) : avc: denied { add_name } for pid=8653 comm=vpnc name=nm-vpnc-fa482929-93ee-4c64-bfba-4ee31d70f35f.pid scontext=system_u:system_r:vpnc_t:s0 tcontext=system_u:object_r:NetworkManager_runtime_t:s0 tclass=dir permissive=1 type=AVC msg=audit(07/10/19 10:38:35.131:931) : avc: denied { write } for pid=8653 comm=vpnc name=NetworkManager dev="tmpfs" ino=30783 scontext=system_u:system_r:vpnc_t:s0 tcontext=system_u:object_r:NetworkManager_runtime_t:s0 tclass=dir permissive=1 This commit also adds the needed interfaces Signed-off-by: Laurent Bigonville --- policy/modules/admin/vpn.te | 2 ++ policy/modules/services/networkmanager.if | 38 +++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/policy/modules/admin/vpn.te b/policy/modules/admin/vpn.te index 01fd8340..6b2ad24c 100644 --- a/policy/modules/admin/vpn.te +++ b/policy/modules/admin/vpn.te @@ -124,6 +124,8 @@ optional_policy(` optional_policy(` networkmanager_attach_tun_iface(vpnc_t) + networkmanager_create_pid_files(vpnc_t) + networkmanager_rw_pid_files(vpnc_t) ') optional_policy(` diff --git a/policy/modules/services/networkmanager.if b/policy/modules/services/networkmanager.if index 4c6dd342..fb89f210 100644 --- a/policy/modules/services/networkmanager.if +++ b/policy/modules/services/networkmanager.if @@ -253,6 +253,25 @@ interface(`networkmanager_append_log_files',` append_files_pattern($1, NetworkManager_log_t, NetworkManager_log_t) ') +######################################## +## +## Create networkmanager pid files. +## +## +## +## Domain allowed access. +## +## +# +interface(`networkmanager_create_pid_files',` + gen_require(` + type NetworkManager_runtime_t; + ') + + files_search_pids($1) + create_files_pattern($1, NetworkManager_runtime_t, NetworkManager_runtime_t) +') + ######################################## ## ## Read networkmanager pid files. @@ -273,6 +292,25 @@ interface(`networkmanager_read_pid_files',` allow $1 NetworkManager_runtime_t:file read_file_perms; ') +######################################## +## +## Read/Write networkmanager pid files. +## +## +## +## Domain allowed access. +## +## +# +interface(`networkmanager_rw_pid_files',` + gen_require(` + type NetworkManager_runtime_t; + ') + + files_search_pids($1) + rw_files_pattern($1, NetworkManager_runtime_t, NetworkManager_runtime_t) +') + #################################### ## ## Connect to networkmanager over -- 2.23.0