+ raise CriticalException("please run this script with uid 0 (root).")
+
+
+def check_boot_flag(device):
+ boot_dev, x = get_device_from_partition(device)
+
+ with open(boot_dev, 'r') as image:
+ data = image.read(520)
+ bootcode = data[440:]
+ gpt_header = "\x55\xaa\x45\x46\x49\x20\x50\x41\x52\x54" # original GPT header
+ gpt_data = bootcode[70:80]
+
+ if gpt_data == gpt_header:
+ logging.info("GPT detected, skipping bootflag check")
+ elif bootcode[6] == '\x80':
+ logging.debug("bootflag is enabled")
+ else:
+ logging.debug("bootflag is NOT enabled")
+ raise VerifyException("Device %s does not have the bootflag set. "
+ "Please enable it to be able to boot." % boot_dev)