Add option to run sudo -v in a loop to prevent repeated password entries (MR 1997)

Many of pmbootstrap's actions require root rights. When after requesting
sudo access pmbootstrap takes longer than the sudo timeout interval to finish
execution, the password will have to be entered again on the next sudo
action.

This change adds an opt-in feature to run sudo -v in a background loop
in order to prevent having to enter the password more than once for a single
pmbootstrap run. The loop runs as a daemon timer which automatically gets
canceled when pmbootstrap exits.

Closes: #1677
This commit is contained in:
Johannes Marbach 2020-11-30 14:08:29 +01:00
parent 8842a7d5c0
commit 1eac61bcf7
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
5 changed files with 49 additions and 11 deletions

View file

@ -261,12 +261,13 @@ def test_questions_additional_options(args, monkeypatch):
assert cfg == {"pmbootstrap": {}}
# Answer everything
fake_answers(monkeypatch, ["y", "128", "64", "5", "2G", "n"])
fake_answers(monkeypatch, ["y", "128", "64", "5", "2G", "n", "n"])
func(args, cfg)
assert cfg == {"pmbootstrap": {"extra_space": "128",
"boot_size": "64",
"jobs": "5",
"ccache_size": "2G"}}
"ccache_size": "2G",
"sudo_timer": "False"}}
def test_questions_hostname(args, monkeypatch):