UbuntuではなくLinuxカーネル4.18でスナップ実行を修正する方法は?

UbuntuではなくLinuxカーネル4.18でスナップ実行を修正する方法は?

Ubuntu以外のシステムでスナップアプリケーションを実行しています。

$ snap version                                                                                                                                   
snap    2.30-5+b1
snapd   2.30-5+b1
series  16
pureos  
kernel  4.18.0-1-amd64

snap run私のアプリのいくつかは動作しますが、他のアプリでは次のエラーが返されます。

cannot perform readlinkat() on the mount namespace file descriptor of the init process: Permission denied

次のようなsnapcraft.ioの提案、私は以下を試しました。

  • ベータコアに切り替えてください。同じエラーです。

  • AppArmor 構成ファイルを次のように変更します。

    1. 実行して、snap list使用しているコアのバージョンを正確に識別します(Core 16-2.35.2 r 5548)。

    2. /etc/apparmor.d/snap.core.5548.usr.lib.snapd.snap-confine説明したように、ファイルを末尾()に追加して修正します。ptrace read peer=unconfined,

    3. アップデートAppArmorsudo apparmor_parser -r /etc/apparmor.d/snap.core.5548.usr.lib.snapd.snap-confine

しかし、それには違いはありません。失敗したアプリケーションは引き続き失敗します。また何ができますか?


ノート

ステップ2を確認してください。

$ tail /etc/apparmor.d/snap.core.5548.usr.lib.snapd.snap-confine                                                                                 
    # from the core snap but we are already inside the constructed mount
    # namespace. Here the apparmor kernel module re-constructs the path to
    # snap-update-ns using the "hostfs" mount entry rather than the more
    # "natural" /snap mount entry but we have no control over that.  This is
    # reported as (LP: #1716339). The variants here represent different
    # locations of snap mount directory across distributions.
    /var/lib/snapd/hostfs/{,var/lib/snapd/}snap/core/*/usr/lib/snapd/snap-update-ns r,

    ptrace read peer=unconfined,
}

ベストアンサー1

次の追加の変更で問題が修正されました。このステップsnapcraftスレッドの他のユーザーには機能しません。しかし、彼らは私のために働きます。以前の変更のうち、実際に不要な変更があるかどうかはわかりません。

  1. 次のように/etc/apparmor.d/usr.lib.snapd.snap-confine.real最後に追加するように変更します。ptrace read peer=unconfined,

    $ tail /etc/apparmor.d/usr.lib.snapd.snap-confine.real                                                                                       
            # But we don't want anyone to touch /snap/bin
            audit deny mount /snap/bin/** -> /**,
            audit deny mount /** -> /snap/bin/**,
    
            # Allow the content interface to bind fonts from the host filesystem
            mount options=(ro bind) /var/lib/snapd/hostfs/usr/share/fonts/ -> /snap/*/*/**,
        }
    
        ptrace read peer=unconfined,
    }
    
  2. sudo apparmor_parser -r /etc/apparmor.d/*snap-confine*

おすすめ記事