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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
diff --git a/src/libcalamares/utils/Runner.cpp b/src/libcalamares/utils/Runner.cpp
index c7146c2d7..e165d9a8f 100644
--- a/src/libcalamares/utils/Runner.cpp
+++ b/src/libcalamares/utils/Runner.cpp
@@ -140,13 +140,13 @@ Calamares::Utils::Runner::run()
}
if ( m_location == RunLocation::RunInTarget )
{
- process.setProgram( "chroot" );
- process.setArguments( QStringList { workingDirectory.absolutePath() } << m_command );
+ process.setProgram( "pkexec" );
+ process.setArguments( QStringList { "chroot" } + QStringList { workingDirectory.absolutePath() } << m_command );
}
else
{
- process.setProgram( "env" );
- process.setArguments( m_command );
+ process.setProgram( "pkexec" );
+ process.setArguments( QStringList { "env" } + m_command );
}
if ( m_output )
diff --git a/src/modules/mount/main.py b/src/modules/mount/main.py
index a3318d1a0..5fbe202fd 100644
--- a/src/modules/mount/main.py
+++ b/src/modules/mount/main.py
@@ -152,7 +152,8 @@ def mount_partition(root_mount_point, partition, partitions):
# Ensure that the created directory has the correct SELinux context on
# SELinux-enabled systems.
- os.makedirs(mount_point, exist_ok=True)
+ subprocess.check_call(["pkexec", "mkdir", "-p", mount_point])
+
try:
subprocess.call(['chcon', '--reference=' + raw_mount_point, mount_point])
except FileNotFoundError as e:
@@ -193,13 +194,13 @@ def mount_partition(root_mount_point, partition, partitions):
for s in btrfs_subvolumes:
if not s["subvolume"]:
continue
- os.makedirs(root_mount_point + os.path.dirname(s["subvolume"]), exist_ok=True)
- subprocess.check_call(["btrfs", "subvolume", "create",
+ subprocess.check_call(["pkexec", "mkdir", "-p", root_mount_point + os.path.dirname(s["subvolume"])])
+ subprocess.check_call(["pkexec", "btrfs", "subvolume", "create",
root_mount_point + s["subvolume"]])
if s["mountPoint"] == "/":
# insert the root subvolume into global storage
libcalamares.globalstorage.insert("btrfsRootSubvolume", s["subvolume"])
- subprocess.check_call(["umount", "-v", root_mount_point])
+ subprocess.check_call(["pkexec", "umount", "-v", root_mount_point])
device = partition["device"]
diff --git a/src/modules/welcome/checker/GeneralRequirements.cpp b/src/modules/welcome/checker/GeneralRequirements.cpp
index ca7219ca4..6ac682ba4 100644
--- a/src/modules/welcome/checker/GeneralRequirements.cpp
+++ b/src/modules/welcome/checker/GeneralRequirements.cpp
@@ -371,10 +371,34 @@ GeneralRequirements::checkEnoughStorage( qint64 requiredSpace )
cWarning() << "GeneralRequirements is configured without libparted.";
return false;
#else
- return check_big_enough( requiredSpace );
+ return big_enough( requiredSpace );
#endif
}
+bool
+GeneralRequirements::big_enough( qint64 requiredSpace )
+{
+ FILE *fpipe;
+ char command[128];
+ snprintf(command, sizeof(command), "lsblk --bytes -no SIZE,TYPE | grep disk | awk '$1 > %llu {print $1}'", requiredSpace);
+ char c = 0;
+
+ if (0 == (fpipe = (FILE*)popen(command, "r")))
+ {
+ cWarning() << "Failed to check storage size.";
+ return false;
+ }
+
+ while (fread(&c, sizeof c, 1, fpipe))
+ {
+ pclose(fpipe);
+ return true;
+ }
+
+ pclose(fpipe);
+
+ return false;
+}
bool
GeneralRequirements::checkEnoughRam( qint64 requiredRam )
diff --git a/src/modules/welcome/checker/GeneralRequirements.h b/src/modules/welcome/checker/GeneralRequirements.h
index b6646da11..ea27324fa 100644
--- a/src/modules/welcome/checker/GeneralRequirements.h
+++ b/src/modules/welcome/checker/GeneralRequirements.h
@@ -36,6 +36,7 @@ private:
bool checkHasPower();
bool checkHasInternet();
bool checkIsRoot();
+ bool big_enough( qint64 requiredSpace );
qreal m_requiredStorageGiB;
qreal m_requiredRamGiB;
|