summaryrefslogtreecommitdiff
path: root/app-admin/calamares/files/calamares-3.1.8-openrc-dmcrypt-cfg.patch
blob: d39e3fabc2db5bee9418171737fd46971306e678 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
diff -Nur a/src/modules/openrcdmcryptcfg/main.py b/src/modules/openrcdmcryptcfg/main.py
--- a/src/modules/openrcdmcryptcfg/main.py	1970-01-01 01:00:00.000000000 +0100
+++ b/src/modules/openrcdmcryptcfg/main.py	2017-08-22 19:23:32.660085460 +0100
@@ -0,0 +1,61 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+#
+# === This file is part of Calamares - <http://github.com/calamares> ===
+#
+#   Copyright 2017, Ghiunhan Mamut <venerix@redcorelinux.org>
+#
+#   Calamares is free software: you can redistribute it and/or modify
+#   it under the terms of the GNU General Public License as published by
+#   the Free Software Foundation, either version 3 of the License, or
+#   (at your option) any later version.
+#
+#   Calamares is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+#   GNU General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with Calamares. If not, see <http://www.gnu.org/licenses/>.
+
+import libcalamares
+import os.path
+
+
+def write_dmcrypt_conf(partitions, root_mount_point, dmcrypt_conf_path):
+    crypto_target = ""
+    crypto_source = ""
+
+    for partition in partitions:
+        if partition["mountPoint"] == "/home" and not "luksMapperName" in partition:
+            pass
+
+        elif partition["mountPoint"] == "/home" and "luksMapperName" in partition:
+            crypto_target = partition["luksMapperName"]
+            crypto_source = "/dev/disk/by-uuid/{!s}".format(partition["uuid"])
+            with open(os.path.join(root_mount_point, dmcrypt_conf_path), 'a+') as dmcrypt_file:
+                dmcrypt_file.write("\ntarget=" + crypto_target)
+                dmcrypt_file.write("\nsource=" + crypto_source)
+                dmcrypt_file.write("\nkey=/crypto_keyfile.bin")
+                dmcrypt_file.write("\n")
+                dmcrypt_file.close()
+
+        elif not partition["mountPoint"] == "/home" in partition:
+            pass
+
+    return None
+
+
+def run():
+    """
+    This module configures the OpenRC dmcrypt service for an encrypted /home partition.
+    :return:
+    """
+
+    root_mount_point = libcalamares.globalstorage.value("rootMountPoint")
+    dmcrypt_conf_path = libcalamares.job.configuration["configFilePath"]
+    partitions = libcalamares.globalstorage.value("partitions")
+
+    dmcrypt_conf_path = dmcrypt_conf_path.lstrip('/')
+
+    return write_dmcrypt_conf(partitions, root_mount_point, dmcrypt_conf_path)
diff -Nur a/src/modules/openrcdmcryptcfg/module.desc b/src/modules/openrcdmcryptcfg/module.desc
--- a/src/modules/openrcdmcryptcfg/module.desc	1970-01-01 01:00:00.000000000 +0100
+++ b/src/modules/openrcdmcryptcfg/module.desc	2017-08-22 13:11:15.198714035 +0100
@@ -0,0 +1,5 @@
+---
+type:       "job"
+name:       "openrcdmcryptcfg"
+interface:  "python"
+script:     "main.py"
diff -Nur a/src/modules/openrcdmcryptcfg/openrcdmcryptcfg.conf b/src/modules/openrcdmcryptcfg/openrcdmcryptcfg.conf
--- a/src/modules/openrcdmcryptcfg/openrcdmcryptcfg.conf	1970-01-01 01:00:00.000000000 +0100
+++ b/src/modules/openrcdmcryptcfg/openrcdmcryptcfg.conf	2017-08-22 13:11:15.198714035 +0100
@@ -0,0 +1,2 @@
+---
+configFilePath: /etc/conf.d/dmcrypt