From c7a323e4668c3ce1a64887077d31a30572d9ab52 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 19 Jun 2017 18:20:24 -0400 Subject: [PATCH] Displaymanager: simplify gdm configuration. Replace calling out to shell to run echo redirected to a file by opening the file and writing to it. --- src/modules/displaymanager/main.py | 34 +++++++++--------------------- 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/src/modules/displaymanager/main.py b/src/modules/displaymanager/main.py index e6c057f71..0aba7baea 100644 --- a/src/modules/displaymanager/main.py +++ b/src/modules/displaymanager/main.py @@ -177,34 +177,20 @@ def set_autologin(username, else: gdm_conf.write('AutomaticLoginEnable=False\n') - if (do_autologin - and os.path.exists("{!s}/var/lib/AccountsService/users".format( + if (do_autologin): + accountservice_dir = "{!s}/var/lib/AccountsService/users".format( root_mount_point ) - )): - os.system( - "echo \"[User]\" > " - "{!s}/var/lib/AccountsService/users/{!s}".format( - root_mount_point, - username - ) - ) + userfile_path = "{!s}/{!s}".format(accountservice_dir, username) + if os.path.exists(accountservice_dir): + with open(userfile_path, "w") as userfile: + userfile.write("[User]\n") - if default_desktop_environment is not None: - os.system( - "echo \"XSession={!s}\" >> " - "{!s}/var/lib/AccountsService/users/{!s}".format( - default_desktop_environment.desktop_file, - root_mount_point, username - ) - ) + if default_desktop_environment is not None: + userfile.write("XSession={!s}\n".format( + default_desktop_environment.desktop_file)) - os.system( - "echo \"Icon=\" >> " - "{!s}/var/lib/AccountsService/users/{!s}".format( - root_mount_point, username - ) - ) + userfile.write("Icon=\n") if "kdm" == displaymanager: # Systems with KDM as Desktop Manager