From c34e3e7fbda9a2058cad7339d5f3f14c3f45213a Mon Sep 17 00:00:00 2001 From: Lab Rat <35325046+rootCircle@users.noreply.github.com> Date: Fri, 30 Jun 2023 06:37:19 +0000 Subject: [PATCH] Fix bug related to repeated sudo prompt due to set_override calls (#531) set_override method is now called only if force flag is invoked. Here are the specific code changes made: In auto_cpufreq/core.py: - Line 96: Removed the root_check call from the set_override function. This was intended to be done to comply with code template, i.e., to use root_check in the main file. In bin/auto-cpufreq: - Line 45: Added a root_check call before calling set_override in main program. Also, set_override is only called if force option is invoked, saving us from precious extra overheads. Fixes #530 --- auto_cpufreq/core.py | 1 - bin/auto-cpufreq | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/auto_cpufreq/core.py b/auto_cpufreq/core.py index d2a21e4..2dcdff1 100644 --- a/auto_cpufreq/core.py +++ b/auto_cpufreq/core.py @@ -96,7 +96,6 @@ def get_override(): return "default" def set_override(override): - root_check() # Calling root_check inside if and elif might be too verbose and is susceptible to bugs in future if override in ["powersave", "performance"]: with open(governor_override_state, "wb") as store: pickle.dump(override, store) diff --git a/bin/auto-cpufreq b/bin/auto-cpufreq index d3880da..98c3be7 100755 --- a/bin/auto-cpufreq +++ b/bin/auto-cpufreq @@ -45,7 +45,8 @@ def main(config, daemon, debug, install, remove, live, log, monitor, stats, vers # set governor override unless None or invalid if force is not None: not_running_daemon_check() - set_override(force) + root_check() # Calling root_check before set_override as it will require sudo access + set_override(force) # Calling set override, only if force has some values if len(sys.argv) == 1: