python/samba: open files in binary mode as appropriate
authorNoel Power <noel.power@suse.com>
Wed, 8 Aug 2018 15:56:33 +0000 (16:56 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 3 Sep 2018 01:22:20 +0000 (03:22 +0200)
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/provision/__init__.py
python/samba/schema.py

index 5b0a71f0241185463b5244e51e4efa37a1242ba1..81272095c48d7382c62235da54272b9d0784cc7d 100644 (file)
@@ -1082,7 +1082,7 @@ def setup_encrypted_secrets_key(path):
     finally:
         os.umask(umask_original)
 
-    with os.fdopen(fd, 'w') as f:
+    with os.fdopen(fd, 'wb') as f:
         key = samba.generate_random_bytes(16)
         f.write(key)
 
index 59b53faf5cdefda51b334c38c25872892d94b220..918f3f7ecc0585cdf482c18b23c356c04d82085c 100644 (file)
@@ -112,7 +112,7 @@ class Schema(object):
 
         if files is not None:
             for file in files:
-                self.schema_data += open(file, 'r').read()
+                self.schema_data += open(file, 'rb').read()
 
         self.schema_data = substitute_var(self.schema_data,
                                           {"SCHEMADN": schemadn})
@@ -131,7 +131,7 @@ class Schema(object):
         if override_prefixmap is not None:
             self.prefixmap_data = override_prefixmap
         else:
-            self.prefixmap_data = open(setup_path("prefixMap.txt"), 'r').read()
+            self.prefixmap_data = open(setup_path("prefixMap.txt"), 'rb').read()
 
         if additional_prefixmap is not None:
             for map in additional_prefixmap: