diff options
author | Colin Guthrie <colin@mageia.org> | 2011-11-03 22:26:54 +0000 |
---|---|---|
committer | Colin Guthrie <colin@mageia.org> | 2011-11-03 22:26:54 +0000 |
commit | 1e6179bf54cbc84b4ad33480e7f2f713418bb28a (patch) | |
tree | 794b2654be506d551421bcc47d3ad97822e2861c /rc.d/init.d/functions | |
parent | 87589b49d1543595188dcb26aa5a09d33e5e0a4e (diff) | |
parent | 6ce3e4700baa4e37e6b16e4160c00b2ebea58d81 (diff) | |
download | initscripts-1e6179bf54cbc84b4ad33480e7f2f713418bb28a.tar initscripts-1e6179bf54cbc84b4ad33480e7f2f713418bb28a.tar.gz initscripts-1e6179bf54cbc84b4ad33480e7f2f713418bb28a.tar.bz2 initscripts-1e6179bf54cbc84b4ad33480e7f2f713418bb28a.tar.xz initscripts-1e6179bf54cbc84b4ad33480e7f2f713418bb28a.zip |
Merge commit 'initscripts-9.34-1' into mga-34
This brings our fully patched initscripts branch up to version 9.34.
Some code was not easily merged and thus not all functionality relating
to multiple IP addresses per interface were merged in.
Conflicts:
Makefile
lang.csh
lang.sh
prefdm
rc.d/init.d/functions
rc.d/init.d/netfs
rc.d/init.d/network
rc.d/rc
rc.d/rc.local
rc.d/rc.sysinit
service
sysconfig.txt
sysconfig/network-scripts/ifdown-eth
sysconfig/network-scripts/ifup-eth
sysconfig/network-scripts/ifup-ipv6
sysconfig/network-scripts/ifup-sit
sysconfig/network-scripts/ifup-tunnel
sysconfig/network-scripts/network-functions
systemd/system/fedora-sysinit-unhack.service
Diffstat (limited to 'rc.d/init.d/functions')
-rw-r--r-- | rc.d/init.d/functions | 88 |
1 files changed, 59 insertions, 29 deletions
diff --git a/rc.d/init.d/functions b/rc.d/init.d/functions index 6f989ba4..43b3abe4 100644 --- a/rc.d/init.d/functions +++ b/rc.d/init.d/functions @@ -64,17 +64,23 @@ systemctl_redirect () { [ -z "${COLUMNS:-}" ] && COLUMNS=80 function load_i18_settings() { - if [ -f /etc/sysconfig/i18n -a -z "$NOLOCALE" ]; then - . /etc/sysconfig/i18n - if [ "$CONSOLETYPE" != "pty" ]; then - [ "$CONSOLE_NOT_LOCALIZED" = "yes" ] && GP_LANG=C - [ "$CONSOLE_NOT_LOCALIZED" = "yes" ] && GP_LANGUAGE=C - fi - if [ -z "$GP_LANG" ]; then - [ -n "$LC_CTYPE" ] && GP_LANG=$LC_CTYPE || GP_LANG=$LC_MESSAGES - fi - if [ -z "$GP_LANGUAGE" ]; then - [ -n "$LANGUAGE" ] && GP_LANGUAGE=$LANGUAGE || GP_LANGUAGE=$GP_LANG + if [ -f /etc/sysconfig/i18n -o -f /etc/locale.conf ]; then + if [ -z "$NOLOCALE" ]; then + if [ -f /etc/locale.conf ]; then + . /etc/locale.conf + else + . /etc/sysconfig/i18n + fi + if [ "$CONSOLETYPE" != "pty" ]; then + [ "$CONSOLE_NOT_LOCALIZED" = "yes" ] && GP_LANG=C + [ "$CONSOLE_NOT_LOCALIZED" = "yes" ] && GP_LANGUAGE=C + fi + if [ -z "$GP_LANG" ]; then + [ -n "$LC_CTYPE" ] && GP_LANG=$LC_CTYPE || GP_LANG=$LC_MESSAGES + fi + if [ -z "$GP_LANGUAGE" ]; then + [ -n "$LANGUAGE" ] && GP_LANGUAGE=$LANGUAGE || GP_LANGUAGE=$GP_LANG + fi fi fi } @@ -198,17 +204,17 @@ __fgrep() { return 1 } -# __umount_loop awk_program fstab_file first_msg retry_msg umount_args +# __umount_loop awk_program fstab_file first_msg retry_msg retry_umount_args # awk_program should process fstab_file and return a list of fstab-encoded # paths; it doesn't have to handle comments in fstab_file. __umount_loop() { - local remaining sig= + local remaining sig=-15 local retry=3 count remaining=$(LC_ALL=C awk "/^#/ {next} $1" "$2" | sort -r) while [ -n "$remaining" -a "$retry" -gt 0 ]; do if [ "$retry" -eq 3 ]; then - action "$3" fstab-decode umount $5 $remaining + action "$3" fstab-decode umount $remaining else action "$4" fstab-decode umount $5 $remaining fi @@ -230,7 +236,7 @@ __umount_loop() { # Similar to __umount loop above, specialized for loopback devices __umount_loopback_loop() { - local remaining devremaining sig= + local remaining devremaining sig=-15 local retry=3 remaining=$(awk '$1 ~ /^\/dev\/loop/ && $2 != "/" && $2 !~ /^\/live\// {print $2}' /proc/mounts) @@ -387,7 +393,7 @@ daemon() { # A function to stop a program. killproc() { - local RC killlevel= base pid pid_file= delay + local RC killlevel= base pid pid_file= delay try RC=0; delay=3 # Test syntax. @@ -432,12 +438,18 @@ killproc() { if checkpid $pid 2>&1; then # TERM first, then KILL if not dead kill -TERM $pid >/dev/null 2>&1 - usleep 100000 - if checkpid $pid && sleep 1 && - checkpid $pid && sleep $delay && - checkpid $pid ; then - kill -KILL $pid >/dev/null 2>&1 - usleep 100000 + usleep 50000 + if checkpid $pid ; then + try=0 + while [ $try -lt $delay ] ; do + checkpid $pid || break + sleep 1 + let try+=1 + done + if checkpid $pid ; then + kill -KILL $pid >/dev/null 2>&1 + usleep 50000 + fi fi fi checkpid $pid @@ -827,6 +839,15 @@ is_false() { return 1 } +# Apply sysctl settings, including files in /etc/sysctl.d +apply_sysctl() { + sysctl -e -p /etc/sysctl.conf >/dev/null 2>&1 + for file in /etc/sysctl.d/* ; do + is_ignored_file "$file" && continue + test -f "$file" && sysctl -e -p "$file" >/dev/null 2>&1 + done +} + key_is_random() { [ "$1" = "/dev/urandom" -o "$1" = "/dev/hw_random" \ -o "$1" = "/dev/random" ] @@ -846,7 +867,7 @@ find_crypto_mount_point() { # Because of a chicken/egg problem, init_crypto must be run twice. /var may be # encrypted but /var/lib/random-seed is needed to initialize swap. init_crypto() { - local have_random dst src key opt mode owner params makeswap skip arg opt + local have_random dst src key opt lsl owner params makeswap skip arg opt local param value rc ret mke2fs mdir prompt mount_point ret=0 @@ -861,8 +882,8 @@ init_crypto() { if test -e "$key" ; then owner=$(ls -l $key | (read a b owner rest; echo $owner)) if ! key_is_random "$key"; then - mode=$(ls -l "$key" | cut -c 5-10) - if [ "$mode" != "------" ]; then + lsl=$(ls -l "$key") + if [ "${lsl:4:6}" != "------" ]; then gprintf "INSECURE MODE FOR %s\n" $key fi fi @@ -926,6 +947,9 @@ init_crypto() { skip="yes" fi ;; + noauto) + skip="yes" + ;; verify) params="$params -y" ;; @@ -968,10 +992,16 @@ init_crypto() { fi fi else - [ -z "$key" ] && plymouth --hide-splash - /sbin/cryptsetup $params ${key:+-d $key} create "$dst" "$src" <&1 2>/dev/null && success || failure - rc=$? - [ -z "$key" ] && plymouth --show-splash + if [ -z "$key" ]; then + mount_point="$(find_crypto_mount_point $dst)" + [ -n "$mount_point" ] || mount_point=${src##*/} + prompt=$(printf $"%s is password protected" "$mount_point") + plymouth ask-for-password --prompt "$prompt" --command="/sbin/cryptsetup $params create $dst $src" <&1 + rc=$? + else + /sbin/cryptsetup $params ${key:+-d $key} create "$dst" "$src" <&1 2>/dev/null && success || failure + rc=$? + fi fi if [ $rc -ne 0 ]; then ret=1 |