forked from ColinIanKing/stress-ng
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
core-capabilies: move *CAP* capability macros to new header
Move *CAP* capabilities macros from stress-ng.h to core-capabilities. as these macros are only required for just several stressors and it makes cppchecking faster. Signed-off-by: Colin Ian King <[email protected]>
- Loading branch information
1 parent
a21310b
commit 2bb0e81
Showing
43 changed files
with
338 additions
and
386 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,267 @@ | ||
/* | ||
* Copyright (C) 2022 Colin Ian King | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; either version 2 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
* | ||
*/ | ||
#ifndef CORE_CAPABILITIES_H | ||
#define CORE_CAPABILITIES_H | ||
|
||
#define SHIM_CAP_IS_ROOT (-1) | ||
|
||
/* POSIX-draft defined capabilities */ | ||
#if defined(CAP_CHOWN) | ||
#define SHIM_CAP_CHOWN CAP_CHOWN | ||
#else | ||
#define SHIM_CAP_CHOWN SHIM_CAP_IS_ROOT | ||
#endif | ||
|
||
#if defined(CAP_DAC_OVERRIDE) | ||
#define SHIM_CAP_DAC_OVERRIDE CAP_DAC_OVERRIDE | ||
#else | ||
#define SHIM_CAP_DAC_OVERRIDE SHIM_CAP_IS_ROOT | ||
#endif | ||
|
||
#if defined(CAP_DAC_READ_SEARCH) | ||
#define SHIM_CAP_DAC_READ_SEARCH CAP_DAC_READ_SEARCH | ||
#else | ||
#define SHIM_CAP_DAC_READ_SEARCH SHIM_CAP_IS_ROOT | ||
#endif | ||
|
||
#if defined(CAP_FOWNER) | ||
#define SHIM_CAP_FOWNER CAP_FOWNER | ||
#else | ||
#define SHIM_CAP_FOWNER SHIM_CAP_IS_ROOT | ||
#endif | ||
|
||
#if defined(CAP_FSETID) | ||
#define SHIM_CAP_FSETID CAP_FSETID | ||
#else | ||
#define SHIM_CAP_FSETID SHIM_CAP_IS_ROOT | ||
#endif | ||
|
||
#if defined(CAP_KILL) | ||
#define SHIM_CAP_KILL CAP_KILL | ||
#else | ||
#define SHIM_CAP_KILL SHIM_CAP_IS_ROOT | ||
#endif | ||
|
||
#if defined(CAP_SETGID) | ||
#define SHIM_CAP_SETGID CAP_SETGID | ||
#else | ||
#define SHIM_CAP_SETGID SHIM_CAP_IS_ROOT | ||
#endif | ||
|
||
#if defined(CAP_SETUID) | ||
#define SHIM_CAP_SETUID CAP_SETUID | ||
#else | ||
#define SHIM_CAP_SETUID SHIM_CAP_IS_ROOT | ||
#endif | ||
|
||
/* Linux specific capabilities */ | ||
#if defined(CAP_SETPCAP) | ||
#define SHIM_CAP_SETPCAP CAP_SETPCAP | ||
#else | ||
#define SHIM_CAP_SETPCAP SHIM_CAP_IS_ROOT | ||
#endif | ||
|
||
#if defined(CAP_LINUX_IMMUTABLE) | ||
#define SHIM_CAP_LINUX_IMMUTABLE CAP_LINUX_IMMUTABLE | ||
#else | ||
#define SHIM_CAP_LINUX_IMMUTABLE SHIM_CAP_IS_ROOT | ||
#endif | ||
|
||
#if defined(CAP_NET_BIND_SERVICE) | ||
#define SHIM_CAP_NET_BIND_SERVICE CAP_NET_BIND_SERVICE | ||
#else | ||
#define SHIM_CAP_NET_BIND_SERVICE SHIM_CAP_IS_ROOT | ||
#endif | ||
|
||
#if defined(CAP_NET_BROADCAST) | ||
#define SHIM_CAP_NET_BROADCAST CAP_NET_BROADCAST | ||
#else | ||
#define SHIM_CAP_NET_BROADCAST SHIM_CAP_IS_ROOT | ||
#endif | ||
|
||
#if defined(CAP_NET_ADMIN) | ||
#define SHIM_CAP_NET_ADMIN CAP_NET_ADMIN | ||
#else | ||
#define SHIM_CAP_NET_ADMIN SHIM_CAP_IS_ROOT | ||
#endif | ||
|
||
#if defined(CAP_NET_RAW) | ||
#define SHIM_CAP_NET_RAW CAP_NET_RAW | ||
#else | ||
#define SHIM_CAP_NET_RAW SHIM_CAP_IS_ROOT | ||
#endif | ||
|
||
#if defined(CAP_IPC_LOCK) | ||
#define SHIM_CAP_IPC_LOCK CAP_IPC_LOCK | ||
#else | ||
#define SHIM_CAP_IPC_LOCK SHIM_CAP_IS_ROOT | ||
#endif | ||
|
||
#if defined(CAP_IPC_OWNER) | ||
#define SHIM_CAP_IPC_OWNER CAP_IPC_OWNER | ||
#else | ||
#define SHIM_CAP_IPC_OWNER SHIM_CAP_IS_ROOT | ||
#endif | ||
|
||
#if defined(CAP_SYS_MODULE) | ||
#define SHIM_CAP_SYS_MODULE CAP_SYS_MODULE | ||
#else | ||
#define SHIM_CAP_SYS_MODULE SHIM_CAP_IS_ROOT | ||
#endif | ||
|
||
#if defined(CAP_SYS_RAWIO) | ||
#define SHIM_CAP_SYS_RAWIO CAP_SYS_RAWIO | ||
#else | ||
#define SHIM_CAP_SYS_RAWIO SHIM_CAP_IS_ROOT | ||
#endif | ||
|
||
#if defined(CAP_SYS_CHROOT) | ||
#define SHIM_CAP_SYS_CHROOT CAP_SYS_CHROOT | ||
#else | ||
#define SHIM_CAP_SYS_CHROOT SHIM_CAP_IS_ROOT | ||
#endif | ||
|
||
#if defined(CAP_SYS_PTRACE) | ||
#define SHIM_CAP_SYS_PTRACE CAP_SYS_PTRACE | ||
#else | ||
#define SHIM_CAP_SYS_PTRACE SHIM_CAP_IS_ROOT | ||
#endif | ||
|
||
#if defined(CAP_SYS_PACCT) | ||
#define SHIM_CAP_SYS_PACCT CAP_SYS_PACCT | ||
#else | ||
#define SHIM_CAP_SYS_PACCT SHIM_CAP_IS_ROOT | ||
#endif | ||
|
||
#if defined(CAP_SYS_ADMIN) | ||
#define SHIM_CAP_SYS_ADMIN CAP_SYS_ADMIN | ||
#else | ||
#define SHIM_CAP_SYS_ADMIN SHIM_CAP_IS_ROOT | ||
#endif | ||
|
||
#if defined(CAP_SYS_BOOT) | ||
#define SHIM_CAP_SYS_BOOT CAP_SYS_BOOT | ||
#else | ||
#define SHIM_CAP_SYS_BOOT SHIM_CAP_IS_ROOT | ||
#endif | ||
|
||
#if defined(CAP_SYS_NICE) | ||
#define SHIM_CAP_SYS_NICE CAP_SYS_NICE | ||
#else | ||
#define SHIM_CAP_SYS_NICE SHIM_CAP_IS_ROOT | ||
#endif | ||
|
||
#if defined(CAP_SYS_RESOURCE) | ||
#define SHIM_CAP_SYS_RESOURCE CAP_SYS_RESOURCE | ||
#else | ||
#define SHIM_CAP_SYS_RESOURCE SHIM_CAP_IS_ROOT | ||
#endif | ||
|
||
#if defined(CAP_SYS_TIME) | ||
#define SHIM_CAP_SYS_TIME CAP_SYS_TIME | ||
#else | ||
#define SHIM_CAP_SYS_TIME SHIM_CAP_IS_ROOT | ||
#endif | ||
|
||
#if defined(CAP_SYS_TTY_CONFIG) | ||
#define SHIM_CAP_SYS_TTY_CONFIG CAP_SYS_TTY_CONFIG | ||
#else | ||
#define SHIM_CAP_SYS_TTY_CONFIG SHIM_CAP_IS_ROOT | ||
#endif | ||
|
||
#if defined(CAP_MKNOD) | ||
#define SHIM_CAP_MKNOD CAP_MKNOD | ||
#else | ||
#define SHIM_CAP_MKNOD SHIM_CAP_IS_ROOT | ||
#endif | ||
|
||
#if defined(CAP_LEASE) | ||
#define SHIM_CAP_LEASE CAP_LEASE | ||
#else | ||
#define SHIM_CAP_LEASE SHIM_CAP_IS_ROOT | ||
#endif | ||
|
||
#if defined(CAP_AUDIT_WRITE) | ||
#define SHIM_CAP_AUDIT_WRITE CAP_AUDIT_WRITE | ||
#else | ||
#define SHIM_CAP_AUDIT_WRITE SHIM_CAP_IS_ROOT | ||
#endif | ||
|
||
#if defined(CAP_AUDIT_CONTROL) | ||
#define SHIM_CAP_AUDIT_CONTROL CAP_AUDIT_CONTROL | ||
#else | ||
#define SHIM_CAP_AUDIT_CONTROL SHIM_CAP_IS_ROOT | ||
#endif | ||
|
||
#if defined(CAP_SETFCAP) | ||
#define SHIM_CAP_SETFCAP CAP_SETFCAP | ||
#else | ||
#define SHIM_CAP_SETFCAP SHIM_CAP_IS_ROOT | ||
#endif | ||
|
||
#if defined(CAP_MAC_OVERRIDE) | ||
#define SHIM_CAP_MAC_OVERRIDE CAP_MAC_OVERRIDE | ||
#else | ||
#define SHIM_CAP_MAC_OVERRIDE SHIM_CAP_IS_ROOT | ||
#endif | ||
|
||
#if defined(CAP_MAC_ADMIN) | ||
#define SHIM_CAP_MAC_ADMIN CAP_MAC_ADMIN | ||
#else | ||
#define SHIM_CAP_MAC_ADMIN SHIM_CAP_IS_ROOT | ||
#endif | ||
|
||
#if defined(CAP_SYSLOG) | ||
#define SHIM_CAP_SYSLOG CAP_SYSLOG | ||
#else | ||
#define SHIM_CAP_SYSLOG SHIM_CAP_IS_ROOT | ||
#endif | ||
|
||
#if defined(CAP_WAKE_ALARM) | ||
#define SHIM_CAP_WAKE_ALARM CAP_WAKE_ALARM | ||
#else | ||
#define SHIM_CAP_WAKE_ALARM SHIM_CAP_IS_ROOT | ||
#endif | ||
|
||
#if defined(CAP_BLOCK_SUSPEND) | ||
#define SHIM_CAP_BLOCK_SUSPEND CAP_BLOCK_SUSPEND | ||
#else | ||
#define SHIM_CAP_BLOCK_SUSPEND SHIM_CAP_IS_ROOT | ||
#endif | ||
|
||
#if defined(CAP_AUDIT_READ) | ||
#define SHIM_CAP_AUDIT_READ CAP_AUDIT_READ | ||
#else | ||
#define SHIM_CAP_AUDIT_READ SHIM_CAP_IS_ROOT | ||
#endif | ||
|
||
#if defined(CAP_PERFMON) | ||
#define SHIM_CAP_PERFMON CAP_PERFMON | ||
#else | ||
#define SHIM_CAP_PERFMON SHIM_CAP_IS_ROOT | ||
#endif | ||
|
||
#if defined(CAP_BPF) | ||
#define SHIM_CAP_BPF CAP_BPF | ||
#else | ||
#define SHIM_CAP_BPF SHIM_CAP_IS_ROOT | ||
#endif | ||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
/* | ||
* Copyright (C) 2013-2021 Canonical, Ltd. | ||
* Copyright (C) 2022 Colin Ian King. | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
|
@@ -15,14 +16,9 @@ | |
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
* | ||
* This code is a complete clean re-write of the stress tool by | ||
* Colin Ian King <[email protected]> and attempts to be | ||
* backwardly compatible with the stress tool by Amos Waterland | ||
* <[email protected]> but has more stress tests and more | ||
* functionality. | ||
* | ||
*/ | ||
#include "stress-ng.h" | ||
#include "core-capabilities.h" | ||
|
||
#if defined(HAVE_LIB_BSD) && \ | ||
defined(__linux__) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
/* | ||
* Copyright (C) 2013-2021 Canonical, Ltd. | ||
* Copyright (C) 2022 Colin Ian King. | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
|
@@ -15,14 +16,9 @@ | |
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
* | ||
* This code is a complete clean re-write of the stress tool by | ||
* Colin Ian King <[email protected]> and attempts to be | ||
* backwardly compatible with the stress tool by Amos Waterland | ||
* <[email protected]> but has more stress tests and more | ||
* functionality. | ||
* | ||
*/ | ||
#include "stress-ng.h" | ||
#include "core-capabilities.h" | ||
|
||
static const stress_help_t help[] = { | ||
{ NULL, "binderfs N", "start N workers exercising binderfs" }, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.