Running a Go server in a chroot

295 views
Skip to first unread message

Juliusz Chroboczek

unread,
Oct 23, 2017, 6:11:15 AM10/23/17
to golan...@googlegroups.com
Hi,

I'm running a statically linked (CGO_ENABLED=0) Go network server in
a chroot under Linux. The chroot is completely empty (except for the
server's data files), yet, to my surprise, the only issue I'm seeing is
that the timezone is wrong.

So two questions, perhaps three:

1. Which file(s) do I copy into the chroot in order to have the correct
timezone ?

2. Any other files or device nodes I should copy into the chroot?

3. Am I cargo-culting, should I use a different setup instead? I'm not
too concerned about security, since the host is a VM connected to our
DMZ, just reasonably paranoid.

Thanks,

-- Juliusz

paul.to...@gmail.com

unread,
Oct 23, 2017, 9:23:25 AM10/23/17
to golang-nuts
I'm running a statically linked (CGO_ENABLED=0) Go network server in
a chroot under Linux.  The chroot is completely empty (except for the
server's data files), yet, to my surprise, the only issue I'm seeing is
that the timezone is wrong.
  1. Which file(s) do I copy into the chroot in order to have the correct
     timezone ?
  2. Any other files or device nodes I should copy into the chroot?

strace could be handy to show you which files it tries to open

Cheers,
Paul 

Serge Voilokov

unread,
Oct 24, 2017, 12:36:47 AM10/24/17
to golang-nuts
you need /usr/local/go/lib/time/zoneinfo.zip. time.LoadLocation is using it. Also /usr/local/go/lib/time/ has a script to refresh timezones.

Juliusz Chroboczek

unread,
Oct 24, 2017, 3:35:43 PM10/24/17
to golan...@googlegroups.com
> you need /usr/local/go/lib/time/zoneinfo.zip. time.LoadLocation is using
> it. Also /usr/local/go/lib/time/ has a script to refresh timezones.

It turns out that copying /etc/localtime into the chroot was enough.
Thanks to the person who helped me by private mail (he'll know who he
is).

-- Juliusz

Reply all
Reply to author
Forward
0 new messages