Skip to content

Commit 2f7c3b9

Browse files
authored
Merge pull request #5 from solidc0re/testing
v0.2.1-alpha
2 parents 6eb740c + 3bcd323 commit 2f7c3b9

File tree

3 files changed

+96
-16
lines changed

3 files changed

+96
-16
lines changed

solidcore-firstboot.sh

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,6 +1065,74 @@ space_1
10651065
conf_msg "Automatic update timers initiated"
10661066
space_2
10671067

1068+
1069+
# === FINAL CHECKS ===
1070+
1071+
clear
1072+
long_msg ">
1073+
>
1074+
> Running some final checks..."
1075+
sleep 2
1076+
space_2
1077+
1078+
# Check the current SELinux status and enable enforcing if required
1079+
short_msg "[1 of 3] Checking SELinux..."
1080+
space_1
1081+
sleep 1
1082+
current_status=$(sestatus | awk '/Current mode:/ {print $3}')
1083+
desired_status="enforcing"
1084+
1085+
if [ "$current_status" = "$desired_status" ]; then
1086+
conf_msg "SELinux already set to enforcing"
1087+
else
1088+
setenforce 1
1089+
conf_msg "SELinux now set to enforcing"
1090+
fi
1091+
space_2
1092+
1093+
# HTTP check for the repos
1094+
short_msg "[2 of 3] Checking insecure URLs in the repo directory..."
1095+
space_1
1096+
sleep 1
1097+
patterns=("^baseurl=http:" "^metalink=http:")
1098+
for pattern in "${patterns[@]}"; do
1099+
output=$(grep -r "$pattern" /etc/yum.repos.d/)
1100+
if [ -n "$output" ]; then
1101+
short_msg "${bold}[WARNING]${normal} HTTP link found in the repository directory (/etc/yum.repos.d/)."
1102+
short_msg "Output:"
1103+
short_msg "$output"
1104+
short_msg "Please investigate. You may be able to manually edit the repo to use HTTPS. Failing that, contact the repo maintainer to report the security issue."
1105+
sleep 2
1106+
else
1107+
conf_msg "No insecure repos found in the repository directory"
1108+
fi
1109+
done
1110+
space_2
1111+
1112+
# CPU vulnerability check
1113+
short_msg "[3 of 3] Checking CPU Vulnerabilities..."
1114+
space_1
1115+
sleep 1
1116+
1117+
short_msg "Vulnerability | Status"
1118+
short_msg "------------------ | --------------"
1119+
1120+
vulnerabilities=$(grep . /sys/devices/system/cpu/vulnerabilities/*)
1121+
1122+
while read -r line; do
1123+
# Extract vulnerability and status using awk
1124+
vulnerability=$(short_msg "$line" | awk -F ':' '{print $1}')
1125+
status=$(short_msg "$line" | awk -F ':' '{print $2}')
1126+
1127+
# Print the vulnerability and its status in a table format
1128+
printf "%-18s | %s\n" "$vulnerability" "$status"
1129+
done <<< "$vulnerabilities"
1130+
sleep 1
1131+
space_1
1132+
short_msg "Please take a note of the vulnerability if there is no mitigation in place and your device is listed as affected."
1133+
sleep 3
1134+
space_2
1135+
10681136
# === TiDY UP & FINISH ===
10691137

10701138
# Reboot if USB Guard installed, otherwise farewell

solidcore-install.sh

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ chmod +x /etc/solidcore/defaults.sh
283283

284284
# Define an array of files to be backed up
285285
files_to_backup=(
286+
"/etc/chrony.conf"
286287
"/etc/default/grub"
287288
"/etc/fstab"
288289
"/etc/machine-id"
@@ -293,6 +294,7 @@ files_to_backup=(
293294
"/etc/security/limits.conf"
294295
"/etc/security/pwquality.conf"
295296
"/etc/ssh/sshd_config"
297+
"/etc/sysconfig/chronyd"
296298
"/etc/systemd/coredump.conf"
297299
"/etc/systemd/system/rpm-ostreed-automatic.timer.d/override.conf"
298300
"/var/lib/dbus/machine-id"
@@ -625,23 +627,31 @@ EOF
625627
systemctl restart NetworkManager
626628

627629

628-
# === HTTPS REPO CHECK ===
630+
# === CHRONY CONF ===
629631

630-
# Define an array of patterns to search for
631-
patterns=("^baseurl=http:" "^metalink=http:")
632+
# Borrowed from GrapheneOS, keeping license intact
633+
license_url="https://raw.githubusercontent.com/GrapheneOS/infrastructure/main/LICENSE"
634+
chrony_url="https://raw.githubusercontent.com/GrapheneOS/infrastructure/main/chrony.conf"
632635

633-
# Loop through the patterns and perform checks
634-
for pattern in "${patterns[@]}"; do
635-
output=$(grep -r "$pattern" /etc/yum.repos.d/)
636-
if [ -n "$output" ]; then
637-
echo "Warning: HTTP link found in yum repository configuration."
638-
echo "Output:"
639-
echo "$output"
640-
echo "Please investigate whether you can manually edit the repo to use HTTPS instead."
641-
fi
642-
done
636+
mkdir -p ./tmp
637+
wget -q -O ./tmp/LICENSE "$license_url"
638+
sed 's/^/# /' ./tmp/LICENSE > ./tmp/LICENSE_temp
639+
wget -q -O ./tmp/chrony.conf "$chrony_url"
640+
641+
systemctl stop chronyd.service
642+
rm -rf /etc/chrony.conf
643+
644+
# Build new chrony.conf
645+
cat ./tmp/LICENSE_temp >> /etc/chrony.conf
646+
cat ./tmp/chrony.conf >> /etc/chrony.conf
647+
648+
# Update chronyd
649+
sed -i 's/^OPTIONS=.*$/OPTIONS='"-F 1"'/' /etc/sysconfig/chronyd
643650

644-
conf_msg "No insecure repos found in yum repository directory"
651+
# Clean up
652+
systemctl start chronyd.service
653+
rm -rf ./tmp
654+
conf_msg "Chrony configuration updated (thanks GrapheneOS!)"
645655

646656

647657
# === AUTOMATIC UPDATES ===

solidcore-uninstall.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ if [[ "$uninstall_response" =~ ^[Yy]$ ]]; then
132132

133133
# Define an array of files to be restored
134134
files_to_restore=(
135-
"/etc/default/grub"
135+
"/etc/chrony.conf"
136+
"/etc/default/grub"
136137
"/etc/fstab"
137138
"/etc/machine-id"
138139
"/etc/resolv.conf"
@@ -142,6 +143,7 @@ if [[ "$uninstall_response" =~ ^[Yy]$ ]]; then
142143
"/etc/security/limits.conf"
143144
"/etc/security/pwquality.conf"
144145
"/etc/ssh/sshd_config"
146+
"/etc/sysconfig/chronyd"
145147
"/etc/systemd/coredump.conf"
146148
"/etc/systemd/system/rpm-ostreed-automatic.timer.d/override.conf"
147149
"/var/lib/dbus/machine-id"
@@ -154,7 +156,7 @@ if [[ "$uninstall_response" =~ ^[Yy]$ ]]; then
154156
if [ -e "$backup_file" ]; then
155157
if [ "$backup_file" == "/var/lib/dbus/machine-id" ]; then
156158
# Restore the backup file
157-
cp "$backup_file" "$source_file"
159+
cp -f "$backup_file" "$source_file"
158160
conf_msg "Backup restored for: $source_file"
159161
# Remove the backup file
160162
rm "$backup_file"

0 commit comments

Comments
 (0)