Skip to content

Commit 26ac9d9

Browse files
committed
fixup! Adding runc jailing
Signed-off-by: xibz <[email protected]>
1 parent cd7e683 commit 26ac9d9

11 files changed

+414
-297
lines changed

proto/firecracker.pb.go

Lines changed: 35 additions & 54 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/firecracker.proto

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,5 @@ message SetVMMetadataRequest {
5858
}
5959

6060
message JailerConfig {
61-
// Determines whether or not the jailer should be disabled.
62-
//
63-
// Valid values are "ON", "OFF"
64-
string State = 1;
65-
uint32 UID = 2;
66-
uint32 GID = 3;
61+
bool DisableJailing = 1;
6762
}

runtime/config.go

Lines changed: 22 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ package main
1515

1616
import (
1717
"encoding/json"
18-
"fmt"
1918
"io/ioutil"
2019
"os"
2120

@@ -38,24 +37,28 @@ const (
3837

3938
// Config represents runtime configuration parameters
4039
type Config struct {
41-
FirecrackerBinaryPath string `json:"firecracker_binary_path"`
42-
KernelImagePath string `json:"kernel_image_path"`
43-
KernelArgs string `json:"kernel_args"`
44-
RootDrive string `json:"root_drive"`
45-
CPUCount int `json:"cpu_count"`
46-
CPUTemplate string `json:"cpu_template"`
47-
LogLevel string `json:"log_level"`
48-
HtEnabled bool `json:"ht_enabled"`
49-
Debug bool `json:"debug"`
50-
51-
JailerConfig JailerConfig `json:"jailer"`
40+
FirecrackerBinaryPath string `json:"firecracker_binary_path"`
41+
KernelImagePath string `json:"kernel_image_path"`
42+
KernelArgs string `json:"kernel_args"`
43+
RootDrive string `json:"root_drive"`
44+
CPUCount int `json:"cpu_count"`
45+
CPUTemplate string `json:"cpu_template"`
46+
LogLevel string `json:"log_level"`
47+
HtEnabled bool `json:"ht_enabled"`
48+
Debug bool `json:"debug"`
49+
JailerConfig JailerConfig `json:"jailer"`
5250
}
5351

5452
// JailerConfig houses a set of configurable values for jailing
5553
type JailerConfig struct {
5654
DisableJailing bool `json:"disable_jailing"`
57-
UID *int `json:"uid"`
58-
GID *int `json:"gid"`
55+
// MinID represents the minimum value for the UID and GID when finding those
56+
// values.
57+
MinID uint32 `json:"min_id"`
58+
// MaxID represents the maximum value for the UID and GID when finding those
59+
// values
60+
MaxID uint32 `json:"max_id"`
61+
RuncBinaryPath string `json:"runc_binary_path"`
5962
}
6063

6164
// LoadConfig loads configuration from JSON file at 'path'
@@ -79,34 +82,15 @@ func LoadConfig(path string) (*Config, error) {
7982
RootDrive: defaultRootfsPath,
8083
CPUCount: defaultCPUCount,
8184
CPUTemplate: string(defaultCPUTemplate),
85+
JailerConfig: JailerConfig{
86+
MinID: defaultMinIDCount,
87+
MaxID: defaultMaxIDCount,
88+
},
8289
}
90+
8391
if err := json.Unmarshal(data, cfg); err != nil {
8492
return nil, errors.Wrapf(err, "failed to unmarshal config from %q", path)
8593
}
8694

8795
return cfg, nil
8896
}
89-
90-
var (
91-
// ErrNoUIDProvided returns when no UID was specified in the configuration
92-
// file
93-
ErrNoUIDProvided = fmt.Errorf("no uid provided in configuration")
94-
// ErrNoGIDProvided returns when no GID was specified in the configuration
95-
// filme
96-
ErrNoGIDProvided = fmt.Errorf("no gid provided in configuration")
97-
)
98-
99-
// Validate ensures that the configuration file has valid values
100-
func (c *Config) Validate() error {
101-
if !c.JailerConfig.DisableJailing {
102-
if c.JailerConfig.UID == nil {
103-
return ErrNoUIDProvided
104-
}
105-
106-
if c.JailerConfig.GID == nil {
107-
return ErrNoGIDProvided
108-
}
109-
}
110-
111-
return nil
112-
}

runtime/drive_handler.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,6 @@ func (h *stubDriveHandler) createStubDrive(driveID, path string) error {
111111
h.logger.WithError(err).Errorf("unexpected error during %v close", f.Name())
112112
}
113113
}()
114-
if err := f.Chmod(0600); err != nil {
115-
return err
116-
}
117114

118115
stubContent, err := internal.GenerateStubContent(driveID)
119116
if err != nil {

0 commit comments

Comments
 (0)