From 752659fd081ec89470cc25d99de9cb06f8025855 Mon Sep 17 00:00:00 2001 From: Explorer09 Date: Wed, 17 Apr 2024 06:00:44 +0800 Subject: Avoid writing configuration to non-regular files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Check whether the configuration file (after symlink resolution) is writable and is a regular file on htop startup, and only then, write the configuration on exit. Also permit reading when the legacy configuration file ("~/.htoprc") is a symlink. Write the new configuration only when both the legacy file and the new location are writable. Thanks to Christian Göttsche (@cgzones) for providing the initial version of the patch. Fixes: #1426 Signed-off-by: Kang-Che Sung --- Settings.h | 1 + 1 file changed, 1 insertion(+) (limited to 'Settings.h') diff --git a/Settings.h b/Settings.h index de4e0096..b5bc8efd 100644 --- a/Settings.h +++ b/Settings.h @@ -55,6 +55,7 @@ typedef struct ScreenSettings_ { typedef struct Settings_ { char* filename; char* initialFilename; + bool writeConfig; /* whether to write the current settings on exit */ int config_version; HeaderLayout hLayout; MeterColumnSetting* hColumns; -- cgit v1.2.3