From 644b46d3f301ac1b237818b8dc59f178c8fe14fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20B=C5=99ezina?= Date: Sat, 24 Nov 2018 13:01:28 +0100 Subject: [PATCH 12/15] compat: write to sysconfig after all changes are done Before this patch we were writing to sysconfig before we check that authconfig is run as root. This produce following traceback: Truncated backtrace: authcompat_EnvironmentFile.py:77:write:PermissionError: [Errno 13] Permission denied: '/etc/sysconfig/authconfig' Traceback (most recent call last): File "/usr/sbin/authconfig", line 650, in main() File "/usr/sbin/authconfig", line 629, in main authcompat = AuthCompat() File "/usr/sbin/authconfig", line 463, in __init__ self.sysconfig.write() File "/usr/lib/python3.7/site-packages/authselect/authcompat_EnvironmentFile.py", line 77, in write with open(self.filename, "w") as f: PermissionError: [Errno 13] Permission denied: '/etc/sysconfig/authconfig' Now we write to sysconfig after writing all changes. Resolves: https://github.com/pbrezina/authselect/issues/119 --- src/compat/authcompat.py.in.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compat/authcompat.py.in.in b/src/compat/authcompat.py.in.in index 666dcd0df57962a789a8882c26535d95d3e75cf2..e4b8c05c6a11a215529ba66f8b36b72a6ac18448 100755 --- a/src/compat/authcompat.py.in.in +++ b/src/compat/authcompat.py.in.in @@ -460,7 +460,6 @@ class AuthCompat: self.options.parse() self.options.applysysconfig(self.sysconfig) self.options.updatesysconfig(self.sysconfig) - self.sysconfig.write() def printWarning(self): print(_("Running authconfig compatibility tool.")) @@ -646,6 +645,7 @@ def main(): try: authcompat.runAuthselect() authcompat.writeConfiguration() + authcompat.sysconfig.write() except subprocess.CalledProcessError as result: eprint(_("Command [%s] failed with %d, stderr:") % (' '.join(result.cmd), result.returncode)) -- 2.17.2