From ae78dbbff81196f1d7bc8fabf84d05e6b9f3ca03 Mon Sep 17 00:00:00 2001 From: TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> Date: Tue, 28 Apr 2026 15:42:50 +0900 Subject: updates --- fedora/.local/bin/htop-vim/linux/SELinuxMeter.c | 93 ------------------------- 1 file changed, 93 deletions(-) delete mode 100644 fedora/.local/bin/htop-vim/linux/SELinuxMeter.c (limited to 'fedora/.local/bin/htop-vim/linux/SELinuxMeter.c') diff --git a/fedora/.local/bin/htop-vim/linux/SELinuxMeter.c b/fedora/.local/bin/htop-vim/linux/SELinuxMeter.c deleted file mode 100644 index c35cb68..0000000 --- a/fedora/.local/bin/htop-vim/linux/SELinuxMeter.c +++ /dev/null @@ -1,93 +0,0 @@ -/* -htop - SELinuxMeter.c -(C) 2020 htop dev team -Released under the GNU GPLv2+, see the COPYING file -in the source distribution for its full text. -*/ - -#include "linux/SELinuxMeter.h" - -#include "CRT.h" - -#include -#include -#include -#include -#include -#include - -#include "Object.h" -#include "XUtils.h" - - -static const int SELinuxMeter_attributes[] = { - METER_TEXT, -}; - -static bool enabled = false; -static bool enforcing = false; - -static bool hasSELinuxMount(void) { - struct statfs sfbuf; - int r = statfs("/sys/fs/selinux", &sfbuf); - if (r != 0) { - return false; - } - - if ((uint32_t)sfbuf.f_type != /* SELINUX_MAGIC */ 0xf97cff8cU) { - return false; - } - - struct statvfs vfsbuf; - r = statvfs("/sys/fs/selinux", &vfsbuf); - if (r != 0 || (vfsbuf.f_flag & ST_RDONLY)) { - return false; - } - - return true; -} - -static bool isSelinuxEnabled(void) { - return hasSELinuxMount() && (0 == access("/etc/selinux/config", F_OK)); -} - -static bool isSelinuxEnforcing(void) { - if (!enabled) { - return false; - } - - char buf[20]; - ssize_t r = xReadfile("/sys/fs/selinux/enforce", buf, sizeof(buf)); - if (r < 0) - return false; - - int enforce = 0; - if (sscanf(buf, "%d", &enforce) != 1) { - return false; - } - - return !!enforce; -} - -static void SELinuxMeter_updateValues(Meter* this) { - enabled = isSelinuxEnabled(); - enforcing = isSelinuxEnforcing(); - - xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "%s%s", enabled ? "enabled" : "disabled", enabled ? (enforcing ? "; mode: enforcing" : "; mode: permissive") : ""); -} - -const MeterClass SELinuxMeter_class = { - .super = { - .extends = Class(Meter), - .delete = Meter_delete, - }, - .updateValues = SELinuxMeter_updateValues, - .defaultMode = TEXT_METERMODE, - .maxItems = 0, - .total = 100.0, - .attributes = SELinuxMeter_attributes, - .name = "SELinux", - .uiName = "SELinux", - .description = "SELinux state overview", - .caption = "SELinux: " -}; -- cgit v1.2.3