From 57f4f0678aa5ca637fedc0a6c0e3e2c7ce7328b4 Mon Sep 17 00:00:00 2001 From: Evgeny Sinelnikov Date: Fri, 6 Aug 2021 09:21:38 +0400 Subject: [PATCH] Fix startup user and computer gpoa initialization --- gpoa/gpoa | 37 ++++++++++++++++++++++++++++--------- gpoa/messages/__init__.py | 4 ++++ 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/gpoa/gpoa b/gpoa/gpoa index 279e8cd..653f58e 100755 --- a/gpoa/gpoa +++ b/gpoa/gpoa @@ -73,25 +73,44 @@ class gpoa_controller: def __init__(self): self.__args = parse_arguments() self.is_machine = False - if not self.__args.user: - user = get_machine_name() - self.is_machine = True + self.noupdate = self.__args.noupdate set_loglevel(self.__args.loglevel) + locale.bindtextdomain('gpoa', '/usr/lib/python3/site-packages/gpoa/locale') gettext.bindtextdomain('gpoa', '/usr/lib/python3/site-packages/gpoa/locale') gettext.textdomain('gpoa') + if not self.__args.user: + self.username = get_machine_name() + self.is_machine = True + else: + self.username = self.__args.user + uname = get_process_user() uid = os.getuid() logdata = dict() - logdata['username'] = uname - logdata['uid'] = uid - log('D1', logdata) + logdata['username'] = self.username + logdata['is_machine'] = self.is_machine + logdata['process_username'] = uname + logdata['process_uid'] = uid + + if self.is_machine: + log('D61', logdata) + else: + log('D1', logdata) + self.username = determine_username(self.username) if not is_root(): - self.username = uname + self.noupdate = True + + if self.is_machine: + msgtext = message_with_code('E34') + log('E34', {'username': self.username}) + raise Exception(msgtext) + + log('D59', {'username': self.username}) else: - self.username = determine_username(self.__args.user) + log('D60', {'username': self.username}) def run(self): ''' @@ -113,7 +132,7 @@ class gpoa_controller: if self.__args.nodomain: nodomain = True - if not self.__args.noupdate: + if not self.noupdate: if is_root(): back = None try: diff --git a/gpoa/messages/__init__.py b/gpoa/messages/__init__.py index 377c921..d0fe638 100644 --- a/gpoa/messages/__init__.py +++ b/gpoa/messages/__init__.py @@ -61,6 +61,7 @@ def error_code(code): error_ids[31] = 'Error connecting to DBus Session daemon' error_ids[32] = 'No reply from DBus Session' error_ids[33] = 'Error occured while running forked process with dropped privileges' + error_ids[34] = 'Error running GPOA directly for computer' return error_ids.get(code, 'Unknown error code') @@ -124,6 +125,9 @@ def debug_code(code): debug_ids[56] = 'Kill dbus-daemon and dconf-service in user context' debug_ids[57] = 'Found connection by org.freedesktop.DBus.GetConnectionUnixProcessID' debug_ids[58] = 'Connection search return org.freedesktop.DBus.Error.NameHasNoOwner' + debug_ids[59] = 'Running GPOA without GPT update directly for user' + debug_ids[60] = 'Running GPOA by root for user' + debug_ids[61] = 'The GPOA process was started for computer' return debug_ids.get(code, 'Unknown debug code')