aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--functions64
-rwxr-xr-xrc.multi2
-rwxr-xr-xrc.sysinit31
3 files changed, 83 insertions, 14 deletions
diff --git a/functions b/functions
index 545ad75..a0cea12 100644
--- a/functions
+++ b/functions
@@ -381,12 +381,13 @@ activate_vgs() {
(( $? == 0 )) && stat_done || stat_fail
}
-do_unlock() {
+do_unlock_legacy() {
# $1 = requested name
# $2 = source device
# $3 = password
# $4 = options
stat_append "${1}.."
+ printf "${C_FAIL}Using legacy crypttab format. This will stop working in the future. See crypttab(5).${C_OTHER}\n"
local open=create a=$1 b=$2 failed=0
# Ordering of options is different if you are using LUKS vs. not.
# Use ugly swizzling to deal with it.
@@ -448,7 +449,6 @@ do_unlock() {
/*)
cryptsetup -d "$3" $4 $open "$a" "$b" >/dev/null;;
*)
- printf "${C_FAIL}crypttab contains a literal encryption key. This will stop working in the future.${C_OTHER}\n"
echo "$3" | cryptsetup $4 $open "$a" "$b" >/dev/null;;
esac
if (( $? )); then
@@ -460,10 +460,64 @@ do_unlock() {
return $failed
}
+do_unlock_systemd() {
+ stat_append "${1}.."
+ local failed=0
+ if ! /usr/lib/systemd/systemd-cryptsetup attach "$1" "$2" "$3" $4; then
+ failed=1
+ else
+ IFS=,
+ if in_array swap ${options[@]}; then
+ if ! mkswap /dev/mapper/$name >/dev/null; then
+ failed=1
+ fi
+ elif in_array tmp ${options[@]}; then
+ if ! mke2fs /dev/mapper/$name >/dev/null; then
+ failed=1
+ fi
+ fi
+ fi
+ if (( $failed )); then
+ stat_append "failed "
+ else
+ stat_append "ok "
+ fi
+ return $failed
+}
+
+do_unlock() {
+ local name=$1 device=$2 password=$3 options=$4
+
+ if [[ ${options:0:2} =~ -. ]]; then
+ do_unlock_legacy "$name" "$device" "$password" "$options"
+ return $?
+ fi
+
+ case $password in
+ ASK|SWAP)
+ do_unlock_legacy "$name" "$device" "$password" "$options"
+ ;;
+ /dev/*)
+ if [[ ${password##*:} == $password ]]; then
+ do_unlock_systemd "$name" "$device" "$password" "$options"
+ else
+ do_unlock_legacy "$name" "$device" "$password" "$options"
+ fi
+ ;;
+ /*|none|-)
+ do_unlock_systemd "$name" "$device" "$password" "$options"
+ ;;
+ *)
+ do_unlock_legacy "$name" "$device" "$password" "$options"
+ ;;
+ esac
+ return $?
+}
+
read_crypttab() {
# $1 = function to call with the split out line from the crypttab
local line nspo failed=0
- while read line; do
+ while read line <&3; do
[[ $line && $line != '#'* ]] || continue
eval nspo=("${line%#*}")
if $1 "${nspo[0]}" "${nspo[1]}" "${nspo[2]}" "${nspo[*]:3}"; then
@@ -471,7 +525,7 @@ read_crypttab() {
else
failed=1
fi
- done < /etc/crypttab
+ done 3< /etc/crypttab
return $failed
}
@@ -588,8 +642,6 @@ bootlogd_stop() {
touch /var/log/boot
kill $(< /run/bootlogd.pid)
rm -f /run/bootlogd.pid
- sed -i -r -e 's/\^\[\[[0-9]?;?[0-9]?[0-9]?;?[0-9]?[0-9]?[ms]//g' \
- -e 's/\^\[(\[1?[0-9][0-9]|%)G//g' -e 's/\^\[\[0;1//g' /var/log/boot
}
###############################
diff --git a/rc.multi b/rc.multi
index daf2372..7d4acaa 100755
--- a/rc.multi
+++ b/rc.multi
@@ -31,4 +31,6 @@ run_hook multi_end
bootlogd_stop
+rm -f /run/nologin
+
# vim: set ts=2 sw=2 noet:
diff --git a/rc.sysinit b/rc.sysinit
index 2d7df3e..0514343 100755
--- a/rc.sysinit
+++ b/rc.sysinit
@@ -50,16 +50,17 @@ esac
if [[ $HWCLOCK_PARAMS ]]; then
stat_busy "Adjusting system time and setting kernel time zone"
- # Adjust the system time for time zone offset if rtc is not in UTC
- # 1. Make creation time on device nodes sane (FS#8665)
- # 2. Filesystem checks can depend on system time
- # 3. This also sets the kernel time zone, used by e.g. vfat
- # If TIMEZONE is not set in /etc/rc.conf, the time zone stored in /etc/localtime
- # is used. If HARDWARECLOCK is not set in /etc/rc.conf, the value in
- # /var/lib/hwclock/adjfile is used (in this case, /var cannot be a separate
- # partition).
+ # Adjust the system time for time zone offset if rtc is not in UTC, as
+ # filesystem checks can depend on system time. This also sets the kernel
+ # time zone, used by e.g. vfat.
+ # If TIMEZONE is not set in rc.conf, the time zone stored in /etc/localtime
+ # is used. If HARDWARECLOCK is not set in rc.conf, the value in
+ # /etc/adjfile is used.
+
[[ $TIMEZONE ]] && export TZ=$TIMEZONE
+
hwclock $HWCLOCK_PARAMS && stat_done || stat_fail
+
unset TZ
fi
@@ -148,6 +149,20 @@ stat_busy "Saving dmesg log"
fi
(( $? == 0 )) && stat_done || stat_fail
+if [[ -f /etc/adjtime ]]; then
+ ( read ; read ; read ADJTIME) < /etc/adjtime
+
+ if [[ $ADJTIME == 'LOCAL' ]]; then
+ if [[ $HARDWARECLOCK == 'UTC' ]]; then
+ printf "${C_FAIL}/etc/rc.conf says the RTC is in UTC, but /etc/adjtime says it is in localtime.\n${C_OTHER}."
+ fi
+ else
+ if [[ $HARDWARECLOCK == 'LOCALTIME' ]]; then
+ printf "${C_FAIL}/etc/rc.conf says the RTC is in localtime, but hwclock (/etc/adjtime) thinks it is in UTC.\n${C_OTHER}."
+ fi
+ fi
+fi
+
run_hook sysinit_end
# End of file