mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
rootless: set sticky bit if using XDG_RUNTIME_DIR
According to the XDG specification[1], in order to avoid the possibility of our container states being auto-pruned every 6 hours we need to set the sticky bit. Rather than handling all of the users of --root, we just create the directory and set the sticky bit during detection, as it's not expensive. [1]: https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html Signed-off-by: Aleksa Sarai <asarai@suse.de>
This commit is contained in:
@@ -67,6 +67,15 @@ func main() {
|
|||||||
runtimeDir := os.Getenv("XDG_RUNTIME_DIR")
|
runtimeDir := os.Getenv("XDG_RUNTIME_DIR")
|
||||||
if runtimeDir != "" {
|
if runtimeDir != "" {
|
||||||
root = runtimeDir + "/runc"
|
root = runtimeDir + "/runc"
|
||||||
|
// According to the XDG specification, we need to set anything in
|
||||||
|
// XDG_RUNTIME_DIR to have a sticky bit if we don't want it to get
|
||||||
|
// auto-pruned.
|
||||||
|
if err := os.MkdirAll(root, 0700); err != nil {
|
||||||
|
fatal(err)
|
||||||
|
}
|
||||||
|
if err := os.Chmod(root, 0700|os.ModeSticky); err != nil {
|
||||||
|
fatal(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user