diff options
author | Christian Göttsche <cgzones@googlemail.com> | 2021-01-21 20:27:37 +0100 |
---|---|---|
committer | cgzones <cgzones@googlemail.com> | 2021-04-14 17:21:43 +0200 |
commit | 36880cd61c52f13c6fd284aa23d42d9493d3ab2e (patch) | |
tree | 54df8a9e8ef536db034af9a3f1d6496626ad802b /linux | |
parent | 812cfcb94df0fc0e6f9d33e39078454842d61609 (diff) |
Add read-only option
Add command line option to disable all system and process changing
features.
Diffstat (limited to 'linux')
-rw-r--r-- | linux/Platform.c | 5 | ||||
-rw-r--r-- | linux/Platform.h | 2 | ||||
-rw-r--r-- | linux/SystemdMeter.c | 3 |
3 files changed, 8 insertions, 2 deletions
diff --git a/linux/Platform.c b/linux/Platform.c index 831ea273..af3fa277 100644 --- a/linux/Platform.c +++ b/linux/Platform.c @@ -130,6 +130,9 @@ static enum CapMode Platform_capabilitiesMode = CAP_MODE_BASIC; #endif static Htop_Reaction Platform_actionSetIOPriority(State* st) { + if (Settings_isReadonly()) + return HTOP_OK; + const LinuxProcess* p = (const LinuxProcess*) Panel_getSelected((Panel*)st->mainPanel); if (!p) return HTOP_OK; @@ -873,7 +876,7 @@ bool Platform_getLongOption(int opt, int argc, char** argv) { switch (opt) { #ifdef HAVE_LIBCAP - case 128: { + case 160: { const char* mode = optarg; if (!mode && optind < argc && argv[optind] != NULL && (argv[optind][0] != '\0' && argv[optind][0] != '-')) { diff --git a/linux/Platform.h b/linux/Platform.h index 78a44275..2506fae5 100644 --- a/linux/Platform.h +++ b/linux/Platform.h @@ -85,7 +85,7 @@ static inline void Platform_getRelease(char** string) { #ifdef HAVE_LIBCAP #define PLATFORM_LONG_OPTIONS \ - {"drop-capabilities", optional_argument, 0, 128}, + {"drop-capabilities", optional_argument, 0, 160}, #else #define PLATFORM_LONG_OPTIONS #endif diff --git a/linux/SystemdMeter.c b/linux/SystemdMeter.c index 24a47f74..a891eb11 100644 --- a/linux/SystemdMeter.c +++ b/linux/SystemdMeter.c @@ -195,6 +195,9 @@ dlfailure: #endif /* !BUILD_STATIC || HAVE_LIBSYSTEMD */ static void updateViaExec(void) { + if (Settings_isReadonly()) + return; + int fdpair[2]; if (pipe(fdpair) < 0) return; |