Something keeps overwriting /etc/hosts

  • Done
  • quality assurance status badge
Details
4 participants
  • Alex Kost
  • Danny Milosavljevic
  • Leo Famulari
  • Ludovic Courtès
Owner
unassigned
Submitted by
Danny Milosavljevic
Severity
normal
D
D
Danny Milosavljevic wrote on 9 Mar 2016 21:42
(address . bug-guix@gnu.org)
20160309214232.027164e0@scratchpost.org

D
D
Danny Milosavljevic wrote on 10 Mar 2016 00:28
(address . 22962@debbugs.gnu.org)
20160310002811.0b59a57f@scratchpost.org
If I make it immutable, I get the following message on guix system reconfigure ... :

guix system: error: copy-file: Permission denied: "/etc/hosts"

Aha!
L
L
Leo Famulari wrote on 10 Mar 2016 02:43
(name . Danny Milosavljevic)(address . dannym@scratchpost.org)(address . 22962@debbugs.gnu.org)
20160310014323.GA29687@jasmine
On Thu, Mar 10, 2016 at 12:28:11AM +0100, Danny Milosavljevic wrote:
Toggle quote (6 lines)
> If I make it immutable, I get the following message on guix system reconfigure ... :
>
> guix system: error: copy-file: Permission denied: "/etc/hosts"
>
> Aha!

I think that on GuixSD, the hosts file is generated from the system
configuration, specifically the 'hosts-file' field, which is mentioned
in section 7.2.2 Operating System Reference [0].

I assume that the resulting file is recreated each time you reconfigure.

In that case, you'd want to leave the file /etc/hosts alone, and make
your changes in the operating system configuration.

I say "I think" and "I assume" because I haven't actually used
'hosts-file' yet, nor have I looked at that part of the code.

Does that help?

[0]
A
A
Alex Kost wrote on 10 Mar 2016 09:39
(name . Leo Famulari)(address . leo@famulari.name)
87k2la682j.fsf@gmail.com
Leo Famulari (2016-03-10 04:43 +0300) wrote:

Toggle quote (19 lines)
> On Thu, Mar 10, 2016 at 12:28:11AM +0100, Danny Milosavljevic wrote:
>> If I make it immutable, I get the following message on guix system reconfigure ... :
>>
>> guix system: error: copy-file: Permission denied: "/etc/hosts"
>>
>> Aha!
>
> I think that on GuixSD, the hosts file is generated from the system
> configuration, specifically the 'hosts-file' field, which is mentioned
> in section 7.2.2 Operating System Reference [0].
>
> I assume that the resulting file is recreated each time you reconfigure.
>
> In that case, you'd want to leave the file /etc/hosts alone, and make
> your changes in the operating system configuration.
>
> I say "I think" and "I assume" because I haven't actually used
> 'hosts-file' yet, nor have I looked at that part of the code.

You are absolutely right! On GuixSD, to modify /etc/hosts a user need
to adjust his/her system config.

Danny, you can keep your hosts file wherever you want, let's say
"~/my-config/hosts"; and you can add this line to your operating-system
declaration:

(hosts-file (local-file (string-append (getenv "HOME")
"/my-config/hosts")))

After reconfiguring your system, this file will be put into the store,
and /etc/hosts will have the same contents after reboot.

Moreover, every time you change this file and make a new system, a new
version of "hosts" will be put to the store. So if you boot into some
old system, it will be booted with the hosts file that was used at that
time (as you can see, every system in /var/guix/profiles, has its own
"etc/hosts").

--
Alex
L
L
Ludovic Courtès wrote on 23 Mar 2016 19:18
control message for bug #22962
(address . control@debbugs.gnu.org)
871t71ukg4.fsf@gnu.org
tags 22962 notabug
L
L
Ludovic Courtès wrote on 23 Mar 2016 19:19
(address . control@debbugs.gnu.org)
87zitpt5uw.fsf@gnu.org
tags 22962 fixed
close 22962 0.9.1
?
Your comment

This issue is archived.

To comment on this conversation send an email to 22962@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 22962
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch