aboutsummaryrefslogtreecommitdiff
path: root/lib/std/os/bits/linux/securebits.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2020-09-12 10:48:38 -0700
committerAndrew Kelley <andrew@ziglang.org>2020-09-12 10:48:38 -0700
commitaf4cc20ce275aeb0e59eee3d893b2f310c1f0239 (patch)
treecc3ff8fa792c20ff0fc0f1e19e98998cc76c07c2 /lib/std/os/bits/linux/securebits.zig
parent03a23418ff13e6ff64cdeed3ef4b54f99c533d88 (diff)
parent9fe4c89230df2d78c8bf37b4b1d7a9bedb92677b (diff)
downloadzig-af4cc20ce275aeb0e59eee3d893b2f310c1f0239.tar.gz
zig-af4cc20ce275aeb0e59eee3d893b2f310c1f0239.zip
Merge remote-tracking branch 'origin/master' into stage2-zig-cc
Master branch added in the concept of library versioning being optional to main.cpp. It will need to be re-added into this branch before merging back into master.
Diffstat (limited to 'lib/std/os/bits/linux/securebits.zig')
-rw-r--r--lib/std/os/bits/linux/securebits.zig41
1 files changed, 41 insertions, 0 deletions
diff --git a/lib/std/os/bits/linux/securebits.zig b/lib/std/os/bits/linux/securebits.zig
new file mode 100644
index 0000000000..0086a694d9
--- /dev/null
+++ b/lib/std/os/bits/linux/securebits.zig
@@ -0,0 +1,41 @@
+// SPDX-License-Identifier: MIT
+// Copyright (c) 2015-2020 Zig Contributors
+// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
+// The MIT license requires this copyright notice to be included in all copies
+// and substantial portions of the software.
+
+fn issecure_mask(comptime x: comptime_int) comptime_int {
+ return 1 << x;
+}
+
+pub const SECUREBITS_DEFAULT = 0x00000000;
+
+pub const SECURE_NOROOT = 0;
+pub const SECURE_NOROOT_LOCKED = 1;
+
+pub const SECBIT_NOROOT = issecure_mask(SECURE_NOROOT);
+pub const SECBIT_NOROOT_LOCKED = issecure_mask(SECURE_NOROOT_LOCKED);
+
+pub const SECURE_NO_SETUID_FIXUP = 2;
+pub const SECURE_NO_SETUID_FIXUP_LOCKED = 3;
+
+pub const SECBIT_NO_SETUID_FIXUP = issecure_mask(SECURE_NO_SETUID_FIXUP);
+pub const SECBIT_NO_SETUID_FIXUP_LOCKED = issecure_mask(SECURE_NO_SETUID_FIXUP_LOCKED);
+
+pub const SECURE_KEEP_CAPS = 4;
+pub const SECURE_KEEP_CAPS_LOCKED = 5;
+
+pub const SECBIT_KEEP_CAPS = issecure_mask(SECURE_KEEP_CAPS);
+pub const SECBIT_KEEP_CAPS_LOCKED = issecure_mask(SECURE_KEEP_CAPS_LOCKED);
+
+pub const SECURE_NO_CAP_AMBIENT_RAISE = 6;
+pub const SECURE_NO_CAP_AMBIENT_RAISE_LOCKED = 7;
+
+pub const SECBIT_NO_CAP_AMBIENT_RAISE = issecure_mask(SECURE_NO_CAP_AMBIENT_RAISE);
+pub const SECBIT_NO_CAP_AMBIENT_RAISE_LOCKED = issecure_mask(SECURE_NO_CAP_AMBIENT_RAISE_LOCKED);
+
+pub const SECURE_ALL_BITS = issecure_mask(SECURE_NOROOT) |
+ issecure_mask(SECURE_NO_SETUID_FIXUP) |
+ issecure_mask(SECURE_KEEP_CAPS) |
+ issecure_mask(SECURE_NO_CAP_AMBIENT_RAISE);
+pub const SECURE_ALL_LOCKS = SECURE_ALL_BITS << 1;