Skip to content

Commit

Permalink
shim: pass seal data prepared by enclave-agent to runtime-boot
Browse files Browse the repository at this point in the history
Signed-off-by: Mikko Ylinen <[email protected]>
  • Loading branch information
mythi authored and piotrpalcz committed Nov 9, 2023
1 parent bed141f commit e28c886
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/shim/runtime/v2/rune/v2/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"os"
"path/filepath"
"strings"

"github.com/confidential-containers/enclave-cc/src/shim/runtime/v2/rune/config"
"github.com/confidential-containers/enclave-cc/src/shim/runtime/v2/rune/oci"
Expand Down Expand Up @@ -108,7 +109,14 @@ func handlePodContainer(ctx context.Context, s *service, r *taskAPI.CreateTaskRe
}
}
// sefsDir store the unionfs images (based on sefs)
sefsDir := filepath.Join(agentContainerRootDir, s.agentID, "merged/rootfs/images", cid)
lowerdirs := []string{
filepath.Join(agentContainerRootDir, s.agentID, "merged/rootfs/images", cid),
filepath.Join(bootContainerPath, "rootfs"),
}
sealDataDir := filepath.Join(agentContainerRootDir, s.agentID, "merged/rootfs/keys", cid)
if _, err := os.Stat(sealDataDir); !os.IsNotExist(err) {
lowerdirs = append(lowerdirs, sealDataDir)
}

var options []string
// Set index=off when mount overlayfs
Expand All @@ -117,7 +125,7 @@ func handlePodContainer(ctx context.Context, s *service, r *taskAPI.CreateTaskRe
fmt.Sprintf("workdir=%s", filepath.Join(workDir)),
fmt.Sprintf("upperdir=%s", filepath.Join(upperDir)),
)
options = append(options, fmt.Sprintf("lowerdir=%s:%s", sefsDir, filepath.Join(bootContainerPath, "rootfs")))
options = append(options, fmt.Sprintf("lowerdir=%s", strings.Join(lowerdirs, ":")))
r.Rootfs = append(r.Rootfs, &types.Mount{
Type: "overlay",
Source: "overlay",
Expand Down
3 changes: 2 additions & 1 deletion tools/packaging/build/agent-enclave-bundle/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ RUN export PATH="$PATH:/opt/occlum/build/bin" && \
# TODO: add new build stage and copy occlum_instance.tar.gz to it
WORKDIR /run/rune
RUN tar xzf /run/enclave-agent/occlum_instance/occlum_instance.tar.gz && \
rm -rf /run/enclave-agent
rm -rf /run/enclave-agent && \
mkdir /keys

RUN rm -rf $HOME/.cargo $HOME/.rustup /enclave-cc && sed -e '/cargo/d' -i /root/.profile && sed -e '/cargo/d' -i /root/.bashrc
RUN apt-get purge -y wget gnupg tzdata jq occlum occlum-pal occlum-toolchains-glibc make binutils libfuse2 libfuse3-3 ca-certificates rsync build-essential cmake git && apt-get autoremove -y
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
includes:
- base.yaml
targets:
- target: /
mkdirs:
- keys
- target: /bin
copy:
- files:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
includes:
- base.yaml
targets:
- target: /
mkdirs:
- keys
- target: /bin
copy:
- files:
Expand Down
4 changes: 4 additions & 0 deletions tools/packaging/build/agent-enclave-bundle/jq.filter
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,9 @@
"target": "/etc/",
"type": "hostfs",
"source": "/configs"
},{
"target": "/keys/",
"type": "hostfs",
"source": "/keys"
}] |
if $ENV.SGX_MODE == "SIM" then .metadata.debuggable = true else .metadata.debuggable = false end

0 comments on commit e28c886

Please sign in to comment.