跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

test-selinux.sh

72 行 · 2.9 KB历史下载
1#!/usr/bin/env bash
2
3# SPDX-FileCopyrightText: Copyright The Lima Authors
4# SPDX-License-Identifier: Apache-2.0
5
6set -eu -o pipefail
7
8scriptdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
9# shellcheck source=common.inc.sh
10source "${scriptdir}/common.inc.sh"
11
12if [ "$#" -ne 1 ]; then
13 ERROR "Usage: $0 NAME"
14 exit 1
15fi
16
17NAME="$1"
18##########################################################################################
19## When using vz & virtiofs, initially container_file_t selinux label
20## was considered which works perfectly for container work loads
21## but it might break for other work loads if the process is running with
22## different label. Also these are the remote mounts from the host machine,
23## so keeping the label as nfs_t fits right. Package container-selinux by
24## default adds rules for nfs_t context which allows container workloads to work as well.
25## https://github.com/lima-vm/lima/pull/1965
26##
27## With integration[https://github.com/lima-vm/lima/pull/2474] with systemd-binfmt,
28## the existing "nfs_t" selinux label for Rosetta is causing issues while registering it.
29## This behaviour needs to be fixed by setting the label as "bin_t"
30## https://github.com/lima-vm/lima/pull/2630
31##########################################################################################
32INFO "Testing secontext is set for rosetta"
33expected="context=system_u:object_r:bin_t:s0"
34#Skip Rosetta checks for x86 GHA mac runners
35if [[ "$(uname)" == "Darwin" && "$(arch)" == "arm64" ]]; then
36 INFO "Testing secontext is set for rosetta mounts"
37 got=$(limactl shell "$NAME" mount | grep "rosetta" | awk '{print $6}')
38 INFO "secontext rosetta: expected=${expected}, got=${got}"
39 if [[ $got != *$expected* ]]; then
40 ERROR "secontext for rosetta mount is not set or Invalid"
41 exit 1
42 fi
43fi
44INFO "Testing secontext is set for bind mounts"
45expected="context=system_u:object_r:nfs_t:s0"
46INFO "Checking in mounts"
47got=$(limactl shell "$NAME" mount | grep "$HOME" | awk '{print $6}')
48INFO "secontext ${HOME}: expected=${expected}, got=${got}"
49if [[ $got != *$expected* ]]; then
50 ERROR "secontext for \"$HOME\" dir is not set or Invalid"
51 exit 1
52fi
53got=$(limactl shell "$NAME" mount | grep "/tmp/lima" | awk '{print $6}')
54INFO "secontext /tmp/lima: expected=${expected}, got=${got}"
55if [[ $got != *$expected* ]]; then
56 ERROR 'secontext for "/tmp/lima" dir is not set or Invalid'
57 exit 1
58fi
59INFO "Checking in fstab file"
60expected='context="system_u:object_r:nfs_t:s0"'
61got=$(limactl shell "$NAME" cat /etc/fstab | grep "$HOME" | awk '{print $4}')
62INFO "secontext ${HOME}: expected=${expected}, got=${got}"
63if [[ $got != *$expected* ]]; then
64 ERROR "secontext for \"$HOME\" dir is not set or Invalid"
65 exit 1
66fi
67got=$(limactl shell "$NAME" cat /etc/fstab | grep "/tmp/lima" | awk '{print $4}')
68INFO "secontext /tmp/lima: expected=${expected}, got=${got}"
69if [[ $got != *$expected* ]]; then
70 ERROR 'secontext for "/tmp/lima" dir is not set or Invalid'
71 exit 1
72fi