summaryrefslogtreecommitdiffstats
path: root/linux
diff options
context:
space:
mode:
authorNathan Scott <nathans@redhat.com>2021-03-22 14:49:07 +1100
committerNathan Scott <nathans@redhat.com>2021-03-22 17:16:40 +1100
commit253ff23f9e3a26c9575758fd1849b457c5d4d635 (patch)
treeb756365fd3c197fc568b9ff68653bda0d2b0e0f3 /linux
parentd56d23d91adf3fad512e5311fcdd0ca129e820c7 (diff)
Use a platform-specific routine for long option usage
Related to https://github.com/htop-dev/htop/pull/564
Diffstat (limited to 'linux')
-rw-r--r--linux/Platform.c14
-rw-r--r--linux/Platform.h22
2 files changed, 23 insertions, 13 deletions
diff --git a/linux/Platform.c b/linux/Platform.c
index a6885254..13c0ddb2 100644
--- a/linux/Platform.c
+++ b/linux/Platform.c
@@ -846,6 +846,20 @@ void Platform_getBattery(double* percent, ACPresence* isOnAC) {
Platform_Battery_cacheTime = now;
}
+void Platform_longOptionsUsage(const char* name)
+{
+#ifdef HAVE_LIBCAP
+ printf(
+" --drop-capabilities[=none|basic|strict] Drop Linux capabilities when running as root\n"
+" none - do not drop any capabilities\n"
+" basic (default) - drop all capabilities not needed by %s\n"
+" strict - drop all capabilities except those needed for\n"
+" core functionality\n", name);
+#else
+ (void) name;
+#endif
+}
+
bool Platform_getLongOption(int opt, int argc, char** argv) {
#ifndef HAVE_LIBCAP
(void) argc;
diff --git a/linux/Platform.h b/linux/Platform.h
index 30544997..18d303d1 100644
--- a/linux/Platform.h
+++ b/linux/Platform.h
@@ -27,19 +27,6 @@ in the source distribution for its full text.
#define PATH_MAX 4096
#endif
-#ifdef HAVE_LIBCAP
- #define PLATFORM_LONG_OPTIONS \
- {"drop-capabilities", optional_argument, 0, 128},
- #define PLATFORM_LONG_OPTIONS_USAGE \
- " --drop-capabilities[=none|basic|strict] Drop Linux capabilities when running as root\n" \
- " none - do not drop any capabilities\n" \
- " basic (default) - drop all capabilities not needed by htop\n" \
- " strict - drop all capabilities except those needed for core functionality\n"
-#else
- #define PLATFORM_LONG_OPTIONS
- #define PLATFORM_LONG_OPTIONS_USAGE
-#endif
-
extern const ProcessField Platform_defaultFields[];
@@ -95,6 +82,15 @@ static inline void Platform_getRelease(char** string) {
*string = Generic_uname();
}
+#ifdef HAVE_LIBCAP
+ #define PLATFORM_LONG_OPTIONS \
+ {"drop-capabilities", optional_argument, 0, 128},
+#else
+ #define PLATFORM_LONG_OPTIONS
+#endif
+
+void Platform_longOptionsUsage(const char* name);
+
bool Platform_getLongOption(int opt, int argc, char** argv);
#endif

© 2014-2024 Faster IT GmbH | imprint | privacy policy