This repository has been archived by the owner on Apr 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
/
main.go
103 lines (81 loc) · 2.65 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// +build !enclave
/* Copyright (c) Edgeless Systems GmbH
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
package main
import (
"errors"
"flag"
"fmt"
"io/ioutil"
"os"
"path"
"path/filepath"
"github.com/edgelesssys/edgelessdb/edb/core"
"github.com/edgelesssys/marblerun/marble/premain"
)
var internalPath string
func main() {
runAsMarble := flag.Bool("marble", false, "Run edb with Marblerun")
flag.Parse()
if *runAsMarble {
// Contact Marblerun to provision edb
if err := premain.PreMainMock(); err != nil {
panic(err)
}
}
config := core.Config{
DataPath: "data",
DatabaseAddress: "127.0.0.1",
APIAddress: "127.0.0.1:8080",
CertificateDNSName: "localhost",
Debug: false,
LogDir: "",
}
// Load config parameters from environment variables
config = core.FillConfigFromEnvironment(config)
var err error
internalPath, err = ioutil.TempDir("", "")
if err != nil {
panic(err)
}
defer os.RemoveAll(internalPath)
config.DataPath = hostPath(config.DataPath)
// Warn user this is not a trustful setup at all!
fmt.Println("edb is running in non-enclave mode without Marblerun.")
fmt.Println("This means edb will save the encryption key used IN PLAINTEXT on the disk.")
fmt.Println("THIS IS OBVIOUSLY NOT SECURE AT ALL FOR PRODUCTION!")
fmt.Println("Only ever use non-enclave mode for testing, please...")
if err := os.MkdirAll(path.Join(hostPath(config.DataPath), core.PersistenceDir), 0o700); err != nil && !os.IsExist(err) {
panic(err)
}
run(config, *runAsMarble, internalPath, "127.0.0.1")
}
func hostPath(path string) string {
result, err := filepath.Abs(path)
if err != nil {
panic(err)
}
return result
}
type executionEnv struct{}
func (executionEnv) GetRemoteReport(reportData []byte) ([]byte, error) {
return nil, errors.New("GetRemoteReport: not running in an enclave")
}
func (executionEnv) GetProductSealKey() ([]byte, error) {
return make([]byte, 16), nil
}
func (executionEnv) IsEnclave() bool {
return false
}
func (executionEnv) GetNumTCS() int {
return 64
}