V8.00.000.2025.06.17
All checks were successful
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 53s
All checks were successful
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 53s
Signed-off-by: Marc S. Weidner <msw@coresecret.dev>
This commit is contained in:
@@ -306,7 +306,7 @@ mount_partition() {
|
||||
do_log "debug" "file_only" "3280() [HMP_FSTAB_MOUNT_OPTS] : '${var_mount_path}' -> '${HMP_FSTAB_MOUNT_OPTS["${var_mount_path}"]}'."
|
||||
|
||||
mount_with_dir "${var_mount_path}" "${var_fs_uuid}" "${var_btrfs_options}" "btrfs" || return "${ERR_MOUNTING_DEV}"
|
||||
do_log "info" "file_only" "3280() Mounted: '${var_fs_uuid}' on: '${TARGET}${var_mount_path}' (Options='${var_btrfs_options}')."
|
||||
do_log "info" "file_only" "3280() Mounted: '${var_fs_uuid}' on: '${TARGET}${var_mount_path}' Options='${var_btrfs_options}'."
|
||||
|
||||
if [[ "${var_fs_btrfs_snapshot}" == "true" ]]; then
|
||||
|
||||
@@ -325,7 +325,7 @@ mount_partition() {
|
||||
do_log "debug" "file_only" "3280() [HMP_FSTAB_MOUNT_OPTS] : '${var_mount_path}/.snapshots' -> '${HMP_FSTAB_MOUNT_OPTS["${var_mount_path}/.snapshots"]}'."
|
||||
|
||||
mount_with_dir "${var_mount_path}/.snapshots" "${var_fs_uuid}" "${var_mount_optsnap}" "btrfs"
|
||||
do_log "info" "file_only" "3280() Mounted: '${var_fs_uuid}' on: '${TARGET}${var_mount_path}/.snapshots' (Options='${var_mount_optsnap}')."
|
||||
do_log "info" "file_only" "3280() Mounted: '${var_fs_uuid}' on: '${TARGET}${var_mount_path}/.snapshots' Options='${var_mount_optsnap}'."
|
||||
|
||||
fi
|
||||
;;
|
||||
@@ -337,7 +337,7 @@ mount_partition() {
|
||||
do_log "debug" "file_only" "3280() [HMP_FSTAB_MOUNT_OPTS] : '${var_mount_path}' -> '${HMP_FSTAB_MOUNT_OPTS["${var_mount_path}"]}'."
|
||||
|
||||
mount_with_dir "${var_mount_path}" "${var_fs_uuid}" "${var_mount_options}" "ext4" || return "${ERR_MOUNTING_DEV}"
|
||||
do_log "info" "file_only" "3280() Mounted: '${var_fs_uuid}' on: '${TARGET}${var_mount_path}' (Options='${var_mount_options}')."
|
||||
do_log "info" "file_only" "3280() Mounted: '${var_fs_uuid}' on: '${TARGET}${var_mount_path}' Options='${var_mount_options}'."
|
||||
;;
|
||||
|
||||
fat32)
|
||||
@@ -347,7 +347,7 @@ mount_partition() {
|
||||
do_log "debug" "file_only" "3280() [HMP_FSTAB_MOUNT_OPTS] : '${var_mount_path}' -> '${HMP_FSTAB_MOUNT_OPTS["${var_mount_path}"]}'."
|
||||
|
||||
mount_with_dir "${var_mount_path}" "${var_fs_uuid}" "${var_mount_options}" "vfat" || return "${ERR_MOUNTING_DEV}"
|
||||
do_log "info" "file_only" "3280() Mounted: '${var_fs_uuid}' on: '${TARGET}${var_mount_path}' (Options='${var_mount_options}')."
|
||||
do_log "info" "file_only" "3280() Mounted: '${var_fs_uuid}' on: '${TARGET}${var_mount_path}' Options='${var_mount_options}'."
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
@@ -67,7 +67,7 @@ generate_fstab() {
|
||||
: >| "${TARGET}/etc/fstab"
|
||||
chmod 0600 "${TARGET}/etc/fstab"
|
||||
|
||||
cat << "EOF" >> "${TARGET}/etc/fstab"
|
||||
cat << EOF >> "${TARGET}/etc/fstab"
|
||||
# SPDX-Version: 3.0
|
||||
# SPDX-CreationInfo: 2025-06-17; WEIDNER, Marc S.; <msw@coresecret.dev>
|
||||
# SPDX-ExternalRef: GIT https://git.coresecret.dev/msw/CISS.debian.installer.git
|
||||
@@ -190,22 +190,6 @@ tmpfs /run tmpfs m
|
||||
# vim: number et ts=2 sw=2 sts=2 ai tw=192 ft=sh
|
||||
EOF
|
||||
|
||||
: >| "${DIR_LOG}/fstab.verify.log"
|
||||
chmod 0600 "${DIR_LOG}/fstab.verify.log"
|
||||
|
||||
do_in_target_script "${TARGET}" "systemd-analyze verify /etc/fstab >> ${DIR_LOG}/fstab.verify.log" 2>&1
|
||||
rc="$?"
|
||||
|
||||
if (( rc == 0 )); then
|
||||
|
||||
do_log "info" "file_only" "4040() '/etc/fstab' verified successfully with systemd-analyze."
|
||||
|
||||
else
|
||||
|
||||
do_log "warning" "file_only" "4040() '/etc/fstab' verification returned errors — see '${DIR_LOG}/fstab.verify.log'."
|
||||
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
|
||||
|
||||
@@ -22,9 +22,7 @@ guard_sourcing
|
||||
# 0: on success
|
||||
#######################################
|
||||
minimal_toolset() {
|
||||
declare var_bin
|
||||
|
||||
### Define HashMap: command -> package
|
||||
### Declare Arrays, HashMaps, and Variables.
|
||||
# shellcheck disable=SC2154
|
||||
declare -A hmp_tool_pkg=(
|
||||
[awk]="gawk"
|
||||
@@ -48,12 +46,42 @@ minimal_toolset() {
|
||||
[zsh]="zsh"
|
||||
)
|
||||
|
||||
declare var_bin=""
|
||||
|
||||
for var_bin in "${!hmp_tool_pkg[@]}"; do
|
||||
|
||||
if ! do_in_target_script "${TARGET}" "command -v ${var_bin} >/dev/null"; then
|
||||
|
||||
do_in_target "${TARGET}" apt-get install -y "${hmp_tool_pkg[${var_bin}]}"
|
||||
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
### Ensure systemd and machine-id are in place
|
||||
if ! do_in_target_script "${TARGET}" "command -v systemctl >/dev/null"; then
|
||||
|
||||
do_log "info" "file_only" "4090() 'systemctl' not found — installing 'systemd' and dependencies."
|
||||
do_in_target "${TARGET}" apt-get install -y systemd systemd-sysv dbus
|
||||
|
||||
else
|
||||
|
||||
do_log "info" "file_only" "4090() 'systemctl' found — skipping installation of systemd."
|
||||
|
||||
fi
|
||||
|
||||
### Generate machine-id if missing
|
||||
if ! do_in_target_script "${TARGET}" "[[ -s /etc/machine-id ]]"; then
|
||||
|
||||
do_log "info" "file_only" "4090() Generating /etc/machine-id via systemd-machine-id-setup."
|
||||
do_in_target "${TARGET}" systemd-machine-id-setup
|
||||
|
||||
else
|
||||
|
||||
do_log "info" "file_only" "4090() Existing machine-id found — no action needed."
|
||||
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
|
||||
|
||||
45
func/system/4092_minimal_checks.sh
Normal file
45
func/system/4092_minimal_checks.sh
Normal file
@@ -0,0 +1,45 @@
|
||||
#!/bin/bash
|
||||
# SPDX-Version: 3.0
|
||||
# SPDX-CreationInfo: 2025-06-17; WEIDNER, Marc S.; <msw@coresecret.dev>
|
||||
# SPDX-ExternalRef: GIT https://git.coresecret.dev/msw/CISS.debian.installer.git
|
||||
# SPDX-FileContributor: WEIDNER, Marc S.; Centurion Intelligence Consulting Agency
|
||||
# SPDX-FileCopyrightText: 2024-2025; WEIDNER, Marc S.; <msw@coresecret.dev>
|
||||
# SPDX-FileType: SOURCE
|
||||
# SPDX-License-Identifier: EUPL-1.2 OR LicenseRef-CCLA-1.0
|
||||
# SPDX-LicenseComment: This file is part of the CISS.debian.installer.secure framework.
|
||||
# SPDX-PackageName: CISS.debian.installer
|
||||
# SPDX-Security-Contact: security@coresecret.eu
|
||||
|
||||
guard_sourcing
|
||||
|
||||
#######################################
|
||||
# TODO: Implement this function
|
||||
# Globals:
|
||||
# TARGET
|
||||
# Arguments:
|
||||
# None
|
||||
# Returns:
|
||||
# 0: on success
|
||||
#######################################
|
||||
minimal_checks() {
|
||||
declare var_bin
|
||||
|
||||
: >| "${DIR_LOG}/fstab.verify.log"
|
||||
chmod 0600 "${DIR_LOG}/fstab.verify.log"
|
||||
|
||||
do_in_target_script "${TARGET}" "systemd-analyze verify /etc/fstab >> ${DIR_LOG}/fstab.verify.log 2>&1"
|
||||
rc="$?"
|
||||
|
||||
if (( rc == 0 )); then
|
||||
|
||||
do_log "info" "file_only" "4040() '/etc/fstab' verified successfully with systemd-analyze."
|
||||
|
||||
else
|
||||
|
||||
do_log "warning" "file_only" "4040() '/etc/fstab' verification returned errors — see '${DIR_LOG}/fstab.verify.log'."
|
||||
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
|
||||
91
func/system/4900_verify_system.sh
Normal file
91
func/system/4900_verify_system.sh
Normal file
@@ -0,0 +1,91 @@
|
||||
#!/bin/bash
|
||||
# SPDX-Version: 3.0
|
||||
# SPDX-CreationInfo: 2025-06-17; WEIDNER, Marc S.; <msw@coresecret.dev>
|
||||
# SPDX-ExternalRef: GIT https://git.coresecret.dev/msw/CISS.debian.installer.git
|
||||
# SPDX-FileContributor: WEIDNER, Marc S.; Centurion Intelligence Consulting Agency
|
||||
# SPDX-FileCopyrightText: 2024-2025; WEIDNER, Marc S.; <msw@coresecret.dev>
|
||||
# SPDX-FileType: SOURCE
|
||||
# SPDX-License-Identifier: EUPL-1.2 OR LicenseRef-CCLA-1.0
|
||||
# SPDX-LicenseComment: This file is part of the CISS.debian.installer.secure framework.
|
||||
# SPDX-PackageName: CISS.debian.installer
|
||||
# SPDX-Security-Contact: security@coresecret.eu
|
||||
|
||||
guard_sourcing
|
||||
|
||||
#######################################
|
||||
# TODO: Implement this function.
|
||||
verify_system() {
|
||||
### Declare Arrays, HashMaps, and Variables.
|
||||
do_log "info" "file_only" "4100() Starting system integrity verification..."
|
||||
|
||||
###########################################
|
||||
## Systemd & Identity Checks
|
||||
###########################################
|
||||
do_log "info" "file_only" "4100() Checking systemd installation and machine-id."
|
||||
|
||||
do_in_target_script "${TARGET}" 'command -v systemctl && systemctl --version' >> "${LOG_FILE}" 2>&1 || \
|
||||
do_log "warning" "file_only" "4100() systemd or systemctl not properly installed."
|
||||
|
||||
do_in_target_script "${TARGET}" '[ -s /etc/machine-id ]' || \
|
||||
do_log "warning" "file_only" "4100() Missing or empty /etc/machine-id."
|
||||
|
||||
###########################################
|
||||
## crypttab & fstab Validation
|
||||
###########################################
|
||||
do_log "info" "file_only" "4100() Validating fstab and crypttab."
|
||||
|
||||
do_in_target_script "${TARGET}" 'systemd-analyze verify /etc/fstab /etc/crypttab' >> "${LOG_FILE}" 2>&1 || \
|
||||
do_log "warning" "file_only" "4100() systemd-analyze verification failed. See ${LOG_FILE}."
|
||||
|
||||
do_in_target_script "${TARGET}" 'findmnt --verify' >> "${LOG_FILE}" 2>&1 || \
|
||||
do_log "warning" "file_only" "4100() findmnt reports potential inconsistencies."
|
||||
|
||||
###########################################
|
||||
## Essential Services
|
||||
###########################################
|
||||
do_log "info" "file_only" "4100() Validating essential services."
|
||||
do_in_target_script "${TARGET}" 'systemctl list-unit-files --state=enabled,disabled' >> "${LOG_FILE}" 2>&1
|
||||
|
||||
###########################################
|
||||
## Init & Bootloader
|
||||
###########################################
|
||||
do_log "info" "file_only" "4100() Checking init and GRUB presence."
|
||||
|
||||
do_in_target_script "${TARGET}" 'readlink -f /sbin/init' >> "${LOG_FILE}" 2>&1 || \
|
||||
do_log "warning" "file_only" "4100() /sbin/init is missing or invalid."
|
||||
|
||||
do_in_target_script "${TARGET}" 'test -e /boot/grub/grub.cfg || test -e /boot/efi/EFI/debian/grubx64.efi' || \
|
||||
do_log "warning" "file_only" "4100() GRUB config or EFI binary not found."
|
||||
|
||||
###########################################
|
||||
## /etc Configuration Checks
|
||||
###########################################
|
||||
do_log "info" "file_only" "4100() Validating core /etc configurations."
|
||||
|
||||
do_in_target_script "${TARGET}" 'grep -E "^127\.0\.1\.1" /etc/hosts' >> "${LOG_FILE}" 2>&1 || \
|
||||
do_log "warning" "file_only" "4100() Missing 127.0.1.1 entry in /etc/hosts."
|
||||
|
||||
do_in_target_script "${TARGET}" '[ -s /etc/hostname ]' || \
|
||||
do_log "warning" "file_only" "4100() /etc/hostname is missing or empty."
|
||||
|
||||
###########################################
|
||||
## Permissions & Security
|
||||
###########################################
|
||||
do_log "info" "file_only" "4100() Auditing /root permissions and login shell."
|
||||
|
||||
do_in_target_script "${TARGET}" 'stat -c "%A %U:%G" /root' >> "${LOG_FILE}" 2>&1
|
||||
do_in_target_script "${TARGET}" 'grep ^root: /etc/passwd' >> "${LOG_FILE}" 2>&1
|
||||
|
||||
###########################################
|
||||
## dpkg & apt status
|
||||
###########################################
|
||||
do_log "info" "file_only" "4100() Verifying package integrity."
|
||||
|
||||
do_in_target_script "${TARGET}" 'dpkg --audit' >> "${LOG_FILE}" 2>&1 || true
|
||||
do_in_target_script "${TARGET}" 'apt-get check' >> "${LOG_FILE}" 2>&1 || \
|
||||
do_log "warning" "file_only" "4100() apt-get check reported errors."
|
||||
|
||||
do_log "info" "file_only" "4100() Verification completed. Output stored in: ${LOG_FILE}."
|
||||
return 0
|
||||
}
|
||||
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
|
||||
@@ -139,6 +139,8 @@ trap_exit_non_zero() {
|
||||
declare -r var_func="$4"
|
||||
declare -r var_cmmd="$5"
|
||||
|
||||
clean_up "${var_code}"
|
||||
|
||||
if [[ "${ERRTRAP}" == "false" ]]; then
|
||||
|
||||
if [[ "${VAR_DEBUG_TRACE}" == "true" || "${VAR_DEBUG_TRAP}" == "true" ]]; then dump_vars_exiting; fi
|
||||
@@ -148,8 +150,6 @@ trap_exit_non_zero() {
|
||||
gauge ) dialog_gauge_cleaner ;;
|
||||
esac
|
||||
|
||||
clean_up "${var_code}"
|
||||
|
||||
printf "%b❌ Trap on 'EXIT' : CISS.debian.installer Script failed. %b%b" "${RED}" "${RES}" "${NL}" | tee -a "${LOG_EXT}"
|
||||
printf "%b❌ : This was most probably caused by an unbound variable. %b%b" "${RED}" "${RES}" "${NL}" | tee -a "${LOG_EXT}"
|
||||
printf "%b❌ GIT Commit : %s %b%b" "${RED}" "${VAR_GIT_REL}" "${RES}" "${NL}" | tee -a "${LOG_EXT}"
|
||||
|
||||
Reference in New Issue
Block a user