mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix pam_limits writing text to a file opened in binary mode
Fixes #24392
This commit is contained in:
parent
a47fbba8ae
commit
16325f6f15
1 changed files with 7 additions and 7 deletions
|
@ -133,9 +133,12 @@ EXAMPLES = '''
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
import shutil
|
import tempfile
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
from ansible.module_utils._text import to_native
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
|
@ -192,15 +195,15 @@ def main():
|
||||||
space_pattern = re.compile(r'\s+')
|
space_pattern = re.compile(r'\s+')
|
||||||
|
|
||||||
message = ''
|
message = ''
|
||||||
f = open (limits_conf, 'r')
|
f = open (limits_conf, 'rb')
|
||||||
# Tempfile
|
# Tempfile
|
||||||
nf = tempfile.NamedTemporaryFile()
|
nf = tempfile.NamedTemporaryFile(mode='w+')
|
||||||
|
|
||||||
found = False
|
found = False
|
||||||
new_value = value
|
new_value = value
|
||||||
|
|
||||||
for line in f:
|
for line in f:
|
||||||
|
line = to_native(line, errors='surrogate_or_strict')
|
||||||
if line.startswith('#'):
|
if line.startswith('#'):
|
||||||
nf.write(line)
|
nf.write(line)
|
||||||
continue
|
continue
|
||||||
|
@ -305,8 +308,5 @@ def main():
|
||||||
module.exit_json(**res_args)
|
module.exit_json(**res_args)
|
||||||
|
|
||||||
|
|
||||||
# import module snippets
|
|
||||||
from ansible.module_utils.basic import *
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in a new issue