mirror of https://github.com/ansible/ansible.git
Fix unicode handling in fixup_perms2 errorhandling (#18565)
The _fixup_perms2 method checks to see if the user that is being sudo'd is an unprivileged user or root. If it is an unprivileged user, some checks are done to see if becoming this user would lock the ssh user out of temp files, among other things. If this check fails, an error prints telling the user to check the documentation for becoming an unprivileged user. On some systems, the stderr prints out the unprivileged user the ssh user was trying to become contained in smartquotes. These quotes aren't in the ASCII range, and so when we're trying to call `str.format()` to combine the stderr message with the error text we get a UnicodeEncodeError as python can't coerce the smartquotes using the system default encoding. By calling `to_native()` on the error message we can ensure that the error message is a native string for the `Exception` handling, as `Exception` messages need to be native strings to avoid errors (byte strings in python2, and text strings in python3) Fixes: #18444pull/17822/head
parent
8d0418f7c1
commit
bb5d8fb476
Loading…
Reference in New Issue