From 4582685fce259b0252e0b510c2a2bde630a62a5b Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Fri, 9 Jan 2015 12:38:11 -0800 Subject: [PATCH] stage1/init: handle relative /etc/localtime symlinks --- stage1/init/init.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/stage1/init/init.go b/stage1/init/init.go index 0655724..80622ab 100644 --- a/stage1/init/init.go +++ b/stage1/init/init.go @@ -33,15 +33,23 @@ const ( nspawnBin = "/usr/bin/systemd-nspawn" // Path to the interpreter within the stage1 rootfs interpBin = "/usr/lib/ld-linux-x86-64.so.2" + // Path to the localtime file/symlink in host + localtimePath = "/etc/localtime" ) // mirrorLocalZoneInfo tries to reproduce the /etc/localtime target in stage1/ to satisfy systemd-nspawn func mirrorLocalZoneInfo(root string) { - zif, err := os.Readlink("/etc/localtime") + zif, err := os.Readlink(localtimePath) if err != nil { return } + // On some systems /etc/localtime is a relative symlink, make it absolute + if !filepath.IsAbs(zif) { + zif = filepath.Join(filepath.Dir(localtimePath), zif) + zif = filepath.Clean(zif) + } + src, err := os.Open(zif) if err != nil { return