-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.h
45 lines (32 loc) · 1.2 KB
/
config.h
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
// Copyright 2017 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef LIBCONTAINER_CONFIG_H_
#define LIBCONTAINER_CONFIG_H_
#include <vector>
#include <base/callback_forward.h>
#include <base/macros.h>
#include <brillo/brillo_export.h>
#include <libminijail.h>
#include "libcontainer/libcontainer.h"
namespace libcontainer {
// A hook that can be run at different stages of the container startup. The PID
// parameter is the pid of the container's init process in the outer namespace.
// The hook should return true on success.
using HookCallback = base::Callback<bool(pid_t)>;
class BRILLO_EXPORT Config {
public:
Config();
Config(const Config&) = delete;
Config& operator=(const Config&) = delete;
~Config();
container_config* get() const { return config_; }
// Runs |callback| when |event| is reached. If |callback| fails,
// container_start() will fail and tear down the container.
void AddHook(minijail_hook_event_t event,
libcontainer::HookCallback callback);
private:
container_config* const config_;
};
} // namespace libcontainer
#endif // LIBCONTAINER_CONFIG_H_