From cc70274079a0de78497011e2c665838522b6e1f5 Mon Sep 17 00:00:00 2001 From: Alejandro Sirgo Rica Date: Wed, 2 Oct 2024 12:13:25 +0200 Subject: src: check if the system is hibernated before /image/create Mount the system partition in readonly mode and check for the hiberfil.sys file if the target system is a Windows. Fail the image creation process if the target system is hibernated. --- src/live/ogOperations.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/live') diff --git a/src/live/ogOperations.py b/src/live/ogOperations.py index 74e4c09..83242d2 100644 --- a/src/live/ogOperations.py +++ b/src/live/ogOperations.py @@ -648,6 +648,16 @@ class OgLiveOperations: if not fstype: raise OgError(f'No filesystem detected in {padev}. Aborting image creation') + ro_mountpoint = padev.replace('dev', 'mnt') + if not mount_mkdir(padev, ro_mountpoint, readonly=True): + raise OgError(f'Cannot mount {ro_mountpoint} as readonly') + + try: + if is_hibernation_enabled(ro_mountpoint): + raise OgError(f'Target system in {padev} has hibernation enabled') + finally: + umount(ro_mountpoint) + if change_access(user=self._smb_user, pwd=self._smb_pass) == -1: raise OgError('remount of /opt/opengnsys/images has failed') -- cgit v1.2.3-18-g5258