Skip to content

Commit

Permalink
Fix bug related to repeated sudo prompt due to set_override calls
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rootCircle committed Jun 28, 2023
1 parent 486a9a6 commit 4e10cdb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
1 change: 0 additions & 1 deletion auto_cpufreq/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion bin/auto-cpufreq
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down

0 comments on commit 4e10cdb

Please sign in to comment.