diff options
author | Antoine Jacoutot <ajacoutot@cvs.openbsd.org> | 2009-03-27 15:17:32 +0000 |
---|---|---|
committer | Antoine Jacoutot <ajacoutot@cvs.openbsd.org> | 2009-03-27 15:17:32 +0000 |
commit | d618b8a1cc45f47e9f2984d6d4a9183386334dc7 (patch) | |
tree | d90e0f1886680cdfbfc172164f99a6a0521dd7c9 | |
parent | 7029b26c0f6f86c966cb097e4b97d44f6f7dde2c (diff) |
Mitigate the risk of leaving the system in an inconsistent state
when a "special" file has been installed (e.g. master.passwd) but
sysmerge was interrupted: we now run the corresponding command
right after installing the file and not at the end of sysmerge run.
When DESTDIR is set and a new aliases file has been installed, try
to run newaliases from chrooted DESTDIR.
input from and ok sthen@
-rw-r--r-- | usr.sbin/sysmerge/sysmerge.sh | 56 |
1 files changed, 23 insertions, 33 deletions
diff --git a/usr.sbin/sysmerge/sysmerge.sh b/usr.sbin/sysmerge/sysmerge.sh index e495749dd55..217c77887ac 100644 --- a/usr.sbin/sysmerge/sysmerge.sh +++ b/usr.sbin/sysmerge/sysmerge.sh @@ -1,6 +1,6 @@ #!/bin/sh - # -# $OpenBSD: sysmerge.sh,v 1.31 2009/03/25 18:02:12 ajacoutot Exp $ +# $OpenBSD: sysmerge.sh,v 1.32 2009/03/27 15:17:31 ajacoutot Exp $ # # This script is based on the FreeBSD mergemaster script, written by # Douglas Barton <DougB@FreeBSD.org> @@ -239,16 +239,30 @@ mm_install() { case "${1#.}" in /dev/MAKEDEV) - NEED_MAKEDEV=1 + echo -n "===> A new ${DESTDIR}/dev/MAKEDEV script was installed, " + echo "MAKEDEV will be run" + cd ${DESTDIR}/dev && /bin/sh MAKEDEV all ;; /etc/login.conf) - if [ -f ${DESTDIR}/etc/login.conf.db ]; then NEED_CAP_MKDB=1; fi + if [ -f ${DESTDIR}/etc/login.conf.db ]; then + echo -n "===> A new ${DESTDIR}/etc/login.conf file was installed, " + echo "cap_mkdb will be run" + cap_mkdb ${DESTDIR}/etc/login.conf + fi ;; /etc/mail/aliases) - NEED_NEWALIASES=1 + echo -n "===> A new ${DESTDIR}/etc/mail/aliases file was installed, " + echo "newaliases will be run" + if [ "${DESTDIR}" ]; then + chroot ${DESTDIR} newaliases || NEED_NEWALIASES=1 + else + newaliases + fi ;; /etc/master.passwd) - NEED_PWD_MKDB=1 + echo -n "===> A new ${DESTDIR}/etc/master.passwd file was installed, " + echo "pwd_mkdb will be run" + pwd_mkdb -d ${DESTDIR}/etc -p ${DESTDIR}/etc/master.passwd ;; esac } @@ -501,35 +515,11 @@ do_post() { echo "${AUTO_INSTALLED_FILES}" > ${WRKDIR}/auto_installed_files fi - if [ "${NEED_CAP_MKDB}" ]; then - echo -n "===> A new ${DESTDIR}/etc/login.conf file was installed, " - echo "running cap_mkdb..." - cap_mkdb ${DESTDIR}/etc/login.conf - fi - - if [ "${NEED_PWD_MKDB}" ]; then - echo -n "===> A new ${DESTDIR}/etc/master.passwd file was installed, " - echo "running pwd_mkdb..." - pwd_mkdb -d ${DESTDIR}/etc -p ${DESTDIR}/etc/master.passwd - fi - - if [ "${NEED_MAKEDEV}" ]; then - echo -n "===> A new ${DESTDIR}/dev/MAKEDEV script was installed, " - echo "running MAKEDEV..." - cd ${DESTDIR}/dev && /bin/sh MAKEDEV all - fi - if [ "${NEED_NEWALIASES}" ]; then - echo -n "===> A new ${DESTDIR}/etc/mail/aliases file was installed, " - if [ "${DESTDIR}" ]; then - echo "\n but the newaliases command is limited to the directories configured" - echo " in sendmail.cf. Make sure to create your aliases database by" - echo " hand when your sendmail configuration is done." - else - echo "running newaliases..." - newaliases - fi - fi + echo "===> A new ${DESTDIR}/etc/mail/aliases file was installed." + echo "However ${DESTDIR}/usr/bin/newaliases could not be run, you will" + echo "need to rebuild your aliases database manually." + fi clean_src rm -rf ${OTEMPROOT} |