diff options
author | Papoteur <papoteur@mageia.org> | 2023-06-30 17:14:02 +0200 |
---|---|---|
committer | Papoteur <papoteur@mageia.org> | 2023-06-30 18:20:06 +0200 |
commit | c3306066bc58b1dfef5252c1a5908c8ce368646b (patch) | |
tree | ecda2c9d4177d1646964066bb910f7faaf589965 | |
parent | 2a774405fbcf1f3b5b7ba2d62db5745c060347f9 (diff) | |
download | isodumper-c3306066bc58b1dfef5252c1a5908c8ce368646b.tar isodumper-c3306066bc58b1dfef5252c1a5908c8ce368646b.tar.gz isodumper-c3306066bc58b1dfef5252c1a5908c8ce368646b.tar.bz2 isodumper-c3306066bc58b1dfef5252c1a5908c8ce368646b.tar.xz isodumper-c3306066bc58b1dfef5252c1a5908c8ce368646b.zip |
keep authorization during 10 min (magiback)
-rwxr-xr-x | backend/magiback | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/backend/magiback b/backend/magiback index 526e98a..f3babc8 100755 --- a/backend/magiback +++ b/backend/magiback @@ -6,10 +6,16 @@ import isodumper.raw_write as raw_write import threading import gettext import logging +import time DEAMON_ORG = 'org.mageia.Magiback' DEAMON_INTERFACE = DEAMON_ORG ISODUMPER_INTERFACE = DEAMON_ORG + ".Isodumper" +# Keep the authorization during KEEPER (in seconds) +KEEPER = 600 +auth = False +last_auth = 0 + logging.basicConfig(filename="/var/log/magiback.log", format='%(asctime)s %(levelname)-8s %(message)s', level=logging.DEBUG) @@ -78,6 +84,7 @@ class Isodumper(raw_write.Dumper): self.backup_mode = False self.uid = 0 self.gid = 0 + self.last_auth = time.perf_counter() def do_write(self, source, target, size, dbus_context): self.finished.clear() @@ -150,7 +157,16 @@ class Isodumper(raw_write.Dumper): def check_permission(action, dbus_context): """ Check permission """ - return dbus_context.is_authorized(action, {'polkit.icon_name': 'isodumper.png', }, interactive=True) + global auth + global last_auth + cur = time.perf_counter() + if cur - last_auth > KEEPER or not auth: + auth = dbus_context.is_authorized(action, {'polkit.icon_name': 'isodumper.png', }, interactive=True) + if auth: + last_auth = cur + return auth + else: + return True class ConfFile(object): |