Mount LUKS device for

Home Status
luks; if ($luksDevice === null) { Util\createBanner('✗', $service . ' has no LUKS device to mount', 'bad'); return; } $key = $_POST['key']; $mount = $_GET['mount']; $disk = exec('blkid /dev/' . $luksDevice->deviceName . ' | grep "UUID=\"' . $luksDevice->uuid . '\""'); $diskOk = !empty($disk); $cryptdevice = exec('lsblk -lno NAME,TYPE,MOUNTPOINT /dev/' . $luksDevice->deviceName . ' | grep "' . $luksDevice->mountPoint . '[[:space:]]*crypt"'); $cryptdeviceOk = !empty($cryptdevice); $cryptdeviceMapping = exec('lsblk -lno NAME,TYPE,MOUNTPOINT /dev/' . $luksDevice->deviceName . ' | grep "crypt" | awk \'{print $1}\''); $mountpoint = exec('cat /proc/mounts | grep "/dev/mapper/' . $luksDevice->mountPoint . ' /mnt/' . $luksDevice->mountPoint . '"'); $mountpointOk = !empty($mountpoint); if (!empty($key) && $diskOk && !$cryptdeviceOk) { $safeKey = escapeshellarg($key); Util\doShellExec('echo ' . $safeKey . ' | sudo cryptsetup --verbose luksOpen /dev/' . $luksDevice->deviceName . ' ' . $luksDevice->mountPoint . ' 2>&1', '/mount.php?service=' . $service, 'cryptsetup'); } if (!empty($mount) && $diskOk && $cryptdeviceOk && !$mountpointOk) { Util\doShellExec('sudo mount -v /dev/mapper/' . $luksDevice->mountPoint . ' /mnt/' . $luksDevice->mountPoint, '/mount.php?service=' . $service, 'mount'); } if (!$diskOk) { Util\createBanner('✗', '/dev/' . $luksDevice->deviceName . ' is not attached or has incorrect UUID', 'bad'); echo '

Attach /dev/' . $luksDevice->deviceName . ' with UUID="' . $luksDevice->uuid . '" to continue.

'; return; } else { Util\createBanner('✓', '/dev/' . $luksDevice->deviceName . ' is attached', 'good'); } if (!$cryptdeviceOk) { if (!empty($cryptdeviceMapping)) { Util\createBanner('✗', "/dev/" . $luksDevice->deviceName . " has incorrect mapping '" . $cryptdeviceMapping. "'", 'bad'); echo '

Cannot continue. Close luks device /dev/' . $luksDevice->deviceName . ' first.

'; return; } Util\createBanner('✗', '/dev/' . $luksDevice->deviceName . ' is locked', 'bad'); echo "

"; echo "Provide the encryption key for /dev/" . $luksDevice->deviceName . " (" . $luksDevice->uuid . ")"; echo "

"; echo "
"; echo "
"; echo "Unlock /dev/" . $luksDevice->deviceName . ""; echo ""; echo "

"; echo ""; echo "
"; echo "
"; return; } else { Util\createBanner('✓', "/dev/" . $luksDevice->deviceName . " is open and has mapping '" . $luksDevice->mountPoint . "'", 'good'); } if (!$mountpointOk) { Util\createBanner('✗', '/dev/mapper/' . $luksDevice->mountPoint . ' is not mounted at /mnt/' . $luksDevice->mountPoint, 'bad'); echo "

Mount /dev/mapper/" . $luksDevice->mountPoint . " at /mnt/" . $luksDevice->mountPoint . ".

"; echo "

[Mount device]

"; return; } else { Util\createBanner('✓', '/dev/mapper/' . $luksDevice->mountPoint . ' is mounted at /mnt/' . $luksDevice->mountPoint, 'good'); } ?>

There is nothing to do.