diff options
author | Yoann Vandoorselaere <yoann@mandriva.com> | 2000-04-19 11:04:30 +0000 |
---|---|---|
committer | Yoann Vandoorselaere <yoann@mandriva.com> | 2000-04-19 11:04:30 +0000 |
commit | c77a8473ba07df8819f0beff435395d21f257a02 (patch) | |
tree | 5c34e175080073cb9587354622c78c5ec6d9712e /init-sh | |
parent | 6e017963ac9136d06d1c811d06bfb55fbee560e1 (diff) | |
download | msec-c77a8473ba07df8819f0beff435395d21f257a02.tar msec-c77a8473ba07df8819f0beff435395d21f257a02.tar.gz msec-c77a8473ba07df8819f0beff435395d21f257a02.tar.bz2 msec-c77a8473ba07df8819f0beff435395d21f257a02.tar.xz msec-c77a8473ba07df8819f0beff435395d21f257a02.zip |
*** empty log message ***
Diffstat (limited to 'init-sh')
-rw-r--r-- | init-sh/lib.sh | 107 |
1 files changed, 68 insertions, 39 deletions
diff --git a/init-sh/lib.sh b/init-sh/lib.sh index 2625b23..d1802f6 100644 --- a/init-sh/lib.sh +++ b/init-sh/lib.sh @@ -45,6 +45,10 @@ AddRules() { AddBegRules() { echo "Modifying config in ${2}..." + + if [[ ! -f ${file} ]]; then + return; + fi export VAL=$1 perl -pi -e '/^#/ or /^$/ or $m++ or print "$ENV{COMMENT}\n$ENV{VAL}\n"' $2 @@ -134,64 +138,86 @@ Ttylog() { LoaderUpdate() { - loader=`/usr/sbin/detectloader` - - case "${loader}" in - "LILO") - file="/etc/lilo.conf" - at_exit="/sbin/lilo" - ;; - "GRUB") - file="/boot/grub/menu.lst" - at_exit="" - ;; - esac - - if [[ ${LILO_PASSWORD+set} != set ]]; then + + # Ask only if we're not inside DrakX. + if [[ -z ${DRAKX_PASSWORD} ]]; then echo "Do you want a password authentication at boot time ?" echo "Be very carefull," echo "this will prevent your server to reboot without an operator to enter password". - WaitAnswer; + WaitAnswer; if [[ ${answer} == yes ]]; then echo -n "Please enter the password which will be used at boot time : " read password else password="" fi - else - password=${LILO_PASSWORD} - fi - - if [[ ! -z ${password} ]]; then - tmpfile=`mktemp /tmp/secure.XXXXXX` - cp ${file} ${tmpfile} - cat ${tmpfile} | grep -v password > ${file} - - rm -f ${tmpfile} - clear - AddBegRules "password=$password" ${file} + if [[ ! -z ${password} ]]; then + if [[ -f /etc/lilo.conf ]]; then + AddBegRules "password=$password" /etc/lilo.conf + chmod 600 /etc/lilo.conf + fi + if [[ -f /boot/grub/menu.lst ]]; then + AddBegRules "password $password" /boot/grub/menu.lst + chmod 600 /boot/grub/menu.lst + fi + + loader=`/usr/sbin/detectloader` + case "${loader}" in + "LILO") + /sbin/lilo + ;; + "GRUB") + ;; + esac + fi fi - - ${at_exit}; } -CleanLoaderRules() { +# Do something only if DRAKX_PASSWORD set ( we're in DrakX ) +LoaderDrakX() { + if [[ -n "${DRAKX_PASSWORD}" ]]; then + if [[ -f /etc/lilo.conf ]]; then + AddBegRules "password=$DRAKX_PASSWORD" /etc/lilo.conf + chmod 600 /etc/lilo.conf + fi + if [[ -f /boot/grub/menu.lst ]]; then + AddBegRules "password $DRAKX_PASSWORD" /boot/grub/menu.lst + chmod 600 /boot/grub/menu.lst + fi + loader=`/usr/sbin/detectloader` - file="" case "${loader}" in + "LILO") + /sbin/lilo + ;; + "GRUB") + ;; + esac + fi +} + + +CleanLoaderRules() { + if [[ -f /etc/lilo.conf ]]; then + CleanRules /etc/lilo.conf + chmod 644 /etc/lilo.conf + fi + if [[ -f /boot/grub/menu.lst ]]; then + CleanRules /boot/grub/menu.lst + chmod 644 /boot/grub/menu.lst + fi + + if [[ -z ${DRAKX_PASSWORD} ]]; then + loader=`/usr/sbin/detectloader` + case "${loader}" in "LILO") - file="/etc/lilo.conf" - at_exit="/sbin/lilo" + /sbin/lilo ;; "GRUB") - file="/boot/grub/menu.lst" - at_exit="" ;; - esac - - CleanRules ${file} - ${at_exit}; + esac + fi } # If we are currently installing our @@ -213,7 +239,10 @@ CommentUserRules /etc/securetty CleanRules /etc/security/msec/security.conf CommentUserRules /etc/security/msec/security.conf CleanRules /etc/profile + CleanLoaderRules +LoaderDrakX + CleanRules /etc/logrotate.conf CleanRules /etc/rc.d/rc.local CleanRules /etc/rc.d/rc.firewall |