Skip to contentSkip to conversation

wic: improve generating disk system identifier

PATCH New Jonathan Liu 1 participant 1 message Jul 31, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 wic: improve generating disk system identifier

This should reduce the chance of generating 0xffffffff as the disk system identifier.

---
 scripts/lib/wic/plugins/imager/direct.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/lib/wic/plugins/imager/direct.py +2 -1
index 51bdd3a984..5765bbb527 100644
@@ -26,6 +26,7 @@
 
 import logging
 import os
+import random
 import shutil
 import tempfile
 import uuid
@@ -303,7 +304,7 @@ class PartitionedImage():
                           # all partitions (in bytes)
         self.ptable_format = ptable_format  # Partition table format
         # Disk system identifier
-        self.identifier = int.from_bytes(os.urandom(4), 'little') or 0xffffffff
+        self.identifier = random.SystemRandom().randint(1, 0xffffffff)
 
         self.partitions = partitions
         self.partimages = []
Signature · 1 line
2.13.2