git: initrd/oinit: chdir to the new root before chroot to it

Sascha Wildner swildner at crater.dragonflybsd.org
Mon Mar 12 00:23:24 PDT 2018


commit e112f3ff35c1e493d85b52014ad2bbdf7c9a9c39
Author: Aaron LI <aly at aaronly.me>
Date:   Mon Mar 12 12:10:39 2018 +0800

    initrd/oinit: chdir to the new root before chroot to it
    
    chroot(2) doesn't change the working directory of the current process,
    therefore a single chroot(2) to a new root (during the early boot with
    encrypted root) causes getcwd(3) fail, which further causes problems for
    some rc scripts.
    
    For example:
    Without this fix, and by placing a 'echo "PWD=`pwd`"' to the beginning
    of /etc/rc, the following messages were logged on the console:
    Mar 12 10:40:28 dfly kernel: pwd: .: No such file or directory
    Mar 12 10:40:28 dfly kernel: PWD=
    
    Another example with "unbound" rc start:
    Mar  3 09:28:11 dfly kernel: Obtaining a trust anchor:
    Mar  3 09:28:11 dfly kernel: _su: No such file or directory
    Mar  3 09:28:11 dfly kernel: _su: Trying to start from "/"
    Mar  3 09:28:12 dfly kernel: .
    Mar  3 09:28:12 dfly kernel: [1520040492] unbound-checkconf[1138:0] error: cannot getcwd: No such file or directory
    Mar  3 09:28:12 dfly kernel: Starting unbound.
    Mar  3 09:28:12 dfly kernel: [1520040492] unbound[1139:0] warning: unbound is already running as pid 1139.
    
    uWSGI rc startup also failed to setup correct working directory due to
    this problem.

Summary of changes:
 share/initrd/mini_init/oinit.c | 4 ++++
 1 file changed, 4 insertions(+)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/e112f3ff35c1e493d85b52014ad2bbdf7c9a9c39


-- 
DragonFly BSD source repository



More information about the Commits mailing list