Skip to content

Commit 4e10cdb

Browse files
committed
Fix bug related to repeated sudo prompt due to set_override calls
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 AdnanHodzic#530
1 parent 486a9a6 commit 4e10cdb

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

auto_cpufreq/core.py

-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ def get_override():
9696
return "default"
9797

9898
def set_override(override):
99-
root_check() # Calling root_check inside if and elif might be too verbose and is susceptible to bugs in future
10099
if override in ["powersave", "performance"]:
101100
with open(governor_override_state, "wb") as store:
102101
pickle.dump(override, store)

bin/auto-cpufreq

+2-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ def main(config, daemon, debug, install, remove, live, log, monitor, stats, vers
4545
# set governor override unless None or invalid
4646
if force is not None:
4747
not_running_daemon_check()
48-
set_override(force)
48+
root_check() # Calling root_check before set_override as it will require sudo access
49+
set_override(force) # Calling set override, only if force has some values
4950

5051
if len(sys.argv) == 1:
5152

0 commit comments

Comments
 (0)