From 22fcb0ce30c038d8d8d40da11de9c3a58cd7a923 Mon Sep 17 00:00:00 2001 From: roy Date: Thu, 2 Apr 2020 13:04:09 +0000 Subject: [PATCH] postinstall: move dhcpcd files to the chroot --- usr.sbin/postinstall/postinstall.in | 39 ++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/usr.sbin/postinstall/postinstall.in b/usr.sbin/postinstall/postinstall.in index c76542d63c0d..50f27d983f4b 100755 --- a/usr.sbin/postinstall/postinstall.in +++ b/usr.sbin/postinstall/postinstall.in @@ -1,6 +1,6 @@ #!/bin/sh # -# $NetBSD: postinstall.in,v 1.15 2020/02/25 10:27:01 nakayama Exp $ +# $NetBSD: postinstall.in,v 1.16 2020/04/02 13:04:09 roy Exp $ # # Copyright (c) 2002-2015 The NetBSD Foundation, Inc. # All rights reserved. @@ -943,32 +943,59 @@ do_dhcpcd() populate_dir "$op" true "${dir}" "${DEST_DIR}/etc" 644 dhcpcd.conf failed=$(( ${failed} + $? )) - check_dir "${op}" "${DEST_DIR}/var/db/dhcpcd" 755 + dstdir="${DESTDIR}/var/chroot/dhcpcd" + + check_dir "${op}" "${dstdir}/var/db/dhcpcd" 755 failed=$(( ${failed} + $? )) move_file "${op}" \ "${DEST_DIR}/etc/dhcpcd.duid" \ - "${DEST_DIR}/var/db/dhcpcd/duid" + "${dstdir}/var/db/dhcpcd/duid" failed=$(( ${failed} + $? )) move_file "${op}" \ "${DEST_DIR}/etc/dhcpcd.secret" \ - "${DEST_DIR}/var/db/dhcpcd/secret" + "${dstdir}/var/db/dhcpcd/secret" failed=$(( ${failed} + $? )) move_file "${op}" \ "${DEST_DIR}/var/db/dhcpcd-rdm.monotonic" \ - "${DEST_DIR}/var/db/dhcpcd/rdm_monotonic" + "${dstdir}/var/db/dhcpcd/rdm_monotonic" failed=$(( ${failed} + $? )) for lease in "${DEST_DIR}/var/db/dhcpcd-"*.lease*; do [ -f "${lease}" ] || continue new_lease=$(basename "${lease}" | ${SED} -e 's/dhcpcd-//') - new_lease="${DEST_DIR}/var/db/dhcpcd/${new_lease}" + new_lease="${dstdir}/var/db/dhcpcd/${new_lease}" move_file "${op}" "${lease}" "${new_lease}" failed=$(( ${failed} + $? )) done + move_file "${op}" \ + "${DEST_DIR}/var/db/dhcpcd/duid" \ + "${dstdir}/var/db/dhcpcd/duid" + failed=$(( ${failed} + $? )) + + move_file "${op}" \ + "${DEST_DIR}/var/db/dhcpcd/secret" \ + "${dstdir}/var/db/dhcpcd/secret" + failed=$(( ${failed} + $? )) + + move_file "${op}" \ + "${DEST_DIR}/var/db/dhcpcd/rdm_monotonic" \ + "${dstdir}/var/db/dhcpcd/rdm_monotonic" + failed=$(( ${failed} + $? )) + + for lease in "${DEST_DIR}/var/db/dhcpcd/"*.lease*; do + [ -f "${lease}" ] || continue + new_lease="${dstdir}/var/db/dhcpcd/$(basename ${lease})" + move_file "${op}" "${lease}" "${new_lease}" + failed=$(( ${failed} + $? )) + done + + contents_owner "${op}" "${dstdir}/var/db/dhcpcd" _dhcpcd _dhcpcd + failed=$(( ${failed} + $? )) + return ${failed} }