mirror of
https://github.com/apple/container.git
synced 2026-10-24 23:58:42 +00:00
Add capabilities support (#444)
Closes https://github.com/apple/containerization/issues/442 This adds capabilities support to LinuxContainer via a new surface in ContainerizationOS + some C wrappers.
This commit is contained in:
1 parent
96d37e2e21
commit
7962dae643
13 files changed
+1207
-10
No files matched your search
@@ -157,6 +157,7 @@ public struct Process: Codable, Sendable {
|
||||
}()
|
||||
self.init(args: args, cwd: cwd, env: env, user: user)
|
||||
}
|
||||
|
||||
public init(from decoder: Decoder) throws {
|
||||
self.init()
|
||||
|
||||
@@ -194,18 +195,26 @@ public struct Process: Codable, Sendable {
|
||||
}
|
||||
|
||||
public struct LinuxCapabilities: Codable, Sendable {
|
||||
public var bounding: [String]
|
||||
public var effective: [String]
|
||||
public var inheritable: [String]
|
||||
public var permitted: [String]
|
||||
public var ambient: [String]
|
||||
public var bounding: [String]?
|
||||
public var effective: [String]?
|
||||
public var inheritable: [String]?
|
||||
public var permitted: [String]?
|
||||
public var ambient: [String]?
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case bounding
|
||||
case effective
|
||||
case inheritable
|
||||
case permitted
|
||||
case ambient
|
||||
}
|
||||
|
||||
public init(
|
||||
bounding: [String],
|
||||
effective: [String],
|
||||
inheritable: [String],
|
||||
permitted: [String],
|
||||
ambient: [String]
|
||||
bounding: [String]? = nil,
|
||||
effective: [String]? = nil,
|
||||
inheritable: [String]? = nil,
|
||||
permitted: [String]? = nil,
|
||||
ambient: [String]? = nil
|
||||
) {
|
||||
self.bounding = bounding
|
||||
self.effective = effective
|
||||
@@ -213,6 +222,24 @@ public struct LinuxCapabilities: Codable, Sendable {
|
||||
self.permitted = permitted
|
||||
self.ambient = ambient
|
||||
}
|
||||
|
||||
public init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||
self.bounding = try container.decodeIfPresent([String].self, forKey: .bounding)
|
||||
self.effective = try container.decodeIfPresent([String].self, forKey: .effective)
|
||||
self.inheritable = try container.decodeIfPresent([String].self, forKey: .inheritable)
|
||||
self.permitted = try container.decodeIfPresent([String].self, forKey: .permitted)
|
||||
self.ambient = try container.decodeIfPresent([String].self, forKey: .ambient)
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(bounding, forKey: .bounding)
|
||||
try container.encodeIfPresent(effective, forKey: .effective)
|
||||
try container.encodeIfPresent(inheritable, forKey: .inheritable)
|
||||
try container.encodeIfPresent(permitted, forKey: .permitted)
|
||||
try container.encodeIfPresent(ambient, forKey: .ambient)
|
||||
}
|
||||
}
|
||||
|
||||
public struct Box: Codable, Sendable {
|
||||
|
||||
Reference in new issue
Block a user