mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-05-03 14:54:53 -04:00
local: fix mac issues in bazel (#1893)
This commit is contained in:
parent
7c345f4503
commit
e0fe8e6ca0
13 changed files with 84 additions and 16 deletions
|
@ -231,6 +231,9 @@ cc_library(
|
||||||
":ms_tpm_20_ref_google_samples",
|
":ms_tpm_20_ref_google_samples",
|
||||||
"@org_openssl//:openssl",
|
"@org_openssl//:openssl",
|
||||||
],
|
],
|
||||||
|
target_compatible_with = [
|
||||||
|
"@platforms//os:linux",
|
||||||
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
cc_library(
|
cc_library(
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
--- simulator/ms-tpm-20-ref/BUILD.bazel
|
--- simulator/ms-tpm-20-ref/BUILD.bazel
|
||||||
+++ simulator/ms-tpm-20-ref/BUILD.bazel
|
+++ simulator/ms-tpm-20-ref/BUILD.bazel
|
||||||
@@ -0,0 +1,509 @@
|
@@ -0,0 +1,512 @@
|
||||||
+cc_library(
|
+cc_library(
|
||||||
+ name = "ms_tpm_20_ref",
|
+ name = "ms_tpm_20_ref",
|
||||||
+ visibility = ["//visibility:public"],
|
+ visibility = ["//visibility:public"],
|
||||||
|
@ -231,6 +231,9 @@
|
||||||
+ ":ms_tpm_20_ref_google_samples",
|
+ ":ms_tpm_20_ref_google_samples",
|
||||||
+ "@org_openssl//:openssl",
|
+ "@org_openssl//:openssl",
|
||||||
+ ],
|
+ ],
|
||||||
|
+ target_compatible_with = [
|
||||||
|
+ "@platforms//os:linux",
|
||||||
|
+ ],
|
||||||
+)
|
+)
|
||||||
+
|
+
|
||||||
+cc_library(
|
+cc_library(
|
||||||
|
|
8
3rdparty/bazel/org_openssl/BUILD.bazel
vendored
8
3rdparty/bazel/org_openssl/BUILD.bazel
vendored
|
@ -18,11 +18,19 @@ cc_test(
|
||||||
],
|
],
|
||||||
"//conditions:default": [],
|
"//conditions:default": [],
|
||||||
}),
|
}),
|
||||||
|
# TODO support OpenSSL on Mac
|
||||||
|
target_compatible_with = [
|
||||||
|
"@platforms//os:linux",
|
||||||
|
],
|
||||||
deps = ["@org_openssl//:openssl"],
|
deps = ["@org_openssl//:openssl"],
|
||||||
)
|
)
|
||||||
|
|
||||||
build_test(
|
build_test(
|
||||||
name = "build_test",
|
name = "build_test",
|
||||||
|
# TODO support OpenSSL on Mac
|
||||||
|
target_compatible_with = [
|
||||||
|
"@platforms//os:linux",
|
||||||
|
],
|
||||||
targets = [
|
targets = [
|
||||||
"@org_openssl//:openssl",
|
"@org_openssl//:openssl",
|
||||||
],
|
],
|
||||||
|
|
|
@ -9,7 +9,7 @@ def go_test(ld = None, count = 3, **kwargs):
|
||||||
|
|
||||||
It adds the following:
|
It adds the following:
|
||||||
- Sets test count to 3.
|
- Sets test count to 3.
|
||||||
- Sets race detector to on by default.
|
- Sets race detector to on by default (except Mac OS)
|
||||||
- Optionally sets the interpreter path to ld.
|
- Optionally sets the interpreter path to ld.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -23,7 +23,16 @@ def go_test(ld = None, count = 3, **kwargs):
|
||||||
kwargs["args"].append("--test.count={}".format(count))
|
kwargs["args"].append("--test.count={}".format(count))
|
||||||
|
|
||||||
# enable race detector by default
|
# enable race detector by default
|
||||||
kwargs.setdefault("race", "on")
|
race_value = select({
|
||||||
|
"@platforms//os:macos": "off",
|
||||||
|
"//conditions:default": "on",
|
||||||
|
})
|
||||||
|
pure_value = select({
|
||||||
|
"@platforms//os:macos": "on",
|
||||||
|
"//conditions:default": "off",
|
||||||
|
})
|
||||||
|
kwargs.setdefault("race", race_value)
|
||||||
|
kwargs.setdefault("pure", pure_value)
|
||||||
|
|
||||||
# set gc_linkopts to set the interpreter path to ld.
|
# set gc_linkopts to set the interpreter path to ld.
|
||||||
kwargs.setdefault("gc_linkopts", [])
|
kwargs.setdefault("gc_linkopts", [])
|
||||||
|
|
|
@ -9,6 +9,9 @@ go_library(
|
||||||
"diskencryption_cross.go",
|
"diskencryption_cross.go",
|
||||||
],
|
],
|
||||||
importpath = "github.com/edgelesssys/constellation/v2/bootstrapper/internal/diskencryption",
|
importpath = "github.com/edgelesssys/constellation/v2/bootstrapper/internal/diskencryption",
|
||||||
|
target_compatible_with = [
|
||||||
|
"@platforms//os:linux",
|
||||||
|
],
|
||||||
visibility = ["//bootstrapper:__subpackages__"],
|
visibility = ["//bootstrapper:__subpackages__"],
|
||||||
deps = select({
|
deps = select({
|
||||||
"@io_bazel_rules_go//go/platform:android": [
|
"@io_bazel_rules_go//go/platform:android": [
|
||||||
|
|
|
@ -9,6 +9,9 @@ go_library(
|
||||||
"cryptmapper_cross.go",
|
"cryptmapper_cross.go",
|
||||||
],
|
],
|
||||||
importpath = "github.com/edgelesssys/constellation/v2/csi/cryptmapper",
|
importpath = "github.com/edgelesssys/constellation/v2/csi/cryptmapper",
|
||||||
|
target_compatible_with = [
|
||||||
|
"@platforms//os:linux",
|
||||||
|
],
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
deps = select({
|
deps = select({
|
||||||
"@io_bazel_rules_go//go/platform:android": [
|
"@io_bazel_rules_go//go/platform:android": [
|
||||||
|
|
|
@ -5,6 +5,8 @@ go_library(
|
||||||
name = "setup",
|
name = "setup",
|
||||||
srcs = [
|
srcs = [
|
||||||
"interface.go",
|
"interface.go",
|
||||||
|
"mount_cross.go",
|
||||||
|
"mount_linux.go",
|
||||||
"setup.go",
|
"setup.go",
|
||||||
],
|
],
|
||||||
importpath = "github.com/edgelesssys/constellation/v2/disk-mapper/internal/setup",
|
importpath = "github.com/edgelesssys/constellation/v2/disk-mapper/internal/setup",
|
||||||
|
|
|
@ -9,7 +9,6 @@ package setup
|
||||||
import (
|
import (
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"os"
|
"os"
|
||||||
"syscall"
|
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/cloud/metadata"
|
"github.com/edgelesssys/constellation/v2/internal/cloud/metadata"
|
||||||
)
|
)
|
||||||
|
@ -49,16 +48,6 @@ type RecoveryDoer interface {
|
||||||
// DiskMounter uses the syscall package to mount disks.
|
// DiskMounter uses the syscall package to mount disks.
|
||||||
type DiskMounter struct{}
|
type DiskMounter struct{}
|
||||||
|
|
||||||
// Mount performs a mount syscall.
|
|
||||||
func (m DiskMounter) Mount(source string, target string, fstype string, flags uintptr, data string) error {
|
|
||||||
return syscall.Mount(source, target, fstype, flags, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unmount performs an unmount syscall.
|
|
||||||
func (m DiskMounter) Unmount(target string, flags int) error {
|
|
||||||
return syscall.Unmount(target, flags)
|
|
||||||
}
|
|
||||||
|
|
||||||
// MkdirAll uses os.MkdirAll to create the directory.
|
// MkdirAll uses os.MkdirAll to create the directory.
|
||||||
func (m DiskMounter) MkdirAll(path string, perm fs.FileMode) error {
|
func (m DiskMounter) MkdirAll(path string, perm fs.FileMode) error {
|
||||||
return os.MkdirAll(path, perm)
|
return os.MkdirAll(path, perm)
|
||||||
|
|
22
disk-mapper/internal/setup/mount_cross.go
Normal file
22
disk-mapper/internal/setup/mount_cross.go
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
//go:build !linux
|
||||||
|
|
||||||
|
/*
|
||||||
|
Copyright (c) Edgeless Systems GmbH
|
||||||
|
|
||||||
|
SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
*/
|
||||||
|
package setup
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Mount performs a mount syscall.
|
||||||
|
func (m DiskMounter) Mount(_ string, _ string, _ string, _ uintptr, _ string) error {
|
||||||
|
return errors.New("mount not implemented on this platform")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unmount performs an unmount syscall.
|
||||||
|
func (m DiskMounter) Unmount(_ string, _ int) error {
|
||||||
|
return errors.New("mount not implemented on this platform")
|
||||||
|
}
|
22
disk-mapper/internal/setup/mount_linux.go
Normal file
22
disk-mapper/internal/setup/mount_linux.go
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
//go:build linux
|
||||||
|
|
||||||
|
/*
|
||||||
|
Copyright (c) Edgeless Systems GmbH
|
||||||
|
|
||||||
|
SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
*/
|
||||||
|
package setup
|
||||||
|
|
||||||
|
import (
|
||||||
|
"syscall"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Mount performs a mount syscall.
|
||||||
|
func (m DiskMounter) Mount(source string, target string, fstype string, flags uintptr, data string) error {
|
||||||
|
return syscall.Mount(source, target, fstype, flags, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unmount performs an unmount syscall.
|
||||||
|
func (m DiskMounter) Unmount(target string, flags int) error {
|
||||||
|
return syscall.Unmount(target, flags)
|
||||||
|
}
|
|
@ -44,6 +44,7 @@ const (
|
||||||
stateDiskMountPath = "/var/run/state"
|
stateDiskMountPath = "/var/run/state"
|
||||||
cryptsetupOptions = "cipher=aes-xts-plain64,integrity=hmac-sha256"
|
cryptsetupOptions = "cipher=aes-xts-plain64,integrity=hmac-sha256"
|
||||||
stateInfoPath = stateDiskMountPath + "/constellation/node_state.json"
|
stateInfoPath = stateDiskMountPath + "/constellation/node_state.json"
|
||||||
|
msrdonly = 0x1 // same as syscall.MS_RDONLY
|
||||||
)
|
)
|
||||||
|
|
||||||
// Manager handles formatting, mapping, mounting and unmounting of state disks.
|
// Manager handles formatting, mapping, mounting and unmounting of state disks.
|
||||||
|
@ -95,7 +96,7 @@ func (s *Manager) PrepareExistingDisk(recover RecoveryDoer) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// we do not care about cleaning up the mount point on error, since any errors returned here should cause a boot failure
|
// we do not care about cleaning up the mount point on error, since any errors returned here should cause a boot failure
|
||||||
if err := s.mounter.Mount(filepath.Join("/dev/mapper/", stateDiskMappedName), stateDiskMountPath, "ext4", syscall.MS_RDONLY, ""); err != nil {
|
if err := s.mounter.Mount(filepath.Join("/dev/mapper/", stateDiskMappedName), stateDiskMountPath, "ext4", msrdonly, ""); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
//go:build integration && cgo
|
//go:build integration && cgo && linux
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright (c) Edgeless Systems GmbH
|
Copyright (c) Edgeless Systems GmbH
|
||||||
|
|
|
@ -5,6 +5,9 @@ go_library(
|
||||||
name = "server",
|
name = "server",
|
||||||
srcs = ["server.go"],
|
srcs = ["server.go"],
|
||||||
importpath = "github.com/edgelesssys/constellation/v2/hack/qemu-metadata-api/server",
|
importpath = "github.com/edgelesssys/constellation/v2/hack/qemu-metadata-api/server",
|
||||||
|
target_compatible_with = [
|
||||||
|
"@platforms//os:linux",
|
||||||
|
],
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
deps = [
|
deps = [
|
||||||
"//hack/qemu-metadata-api/virtwrapper",
|
"//hack/qemu-metadata-api/virtwrapper",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue