Skip to content
Snippets Groups Projects
Commit eea3b572 authored by Bernardo Dal Seno's avatar Bernardo Dal Seno
Browse files

noded: Fix /etc/hosts group ownership


When Ganeti was compiled with the option of running as a different
user/group, the group ownership of /etc/hosts was set to gnt-daemons.  Now
permissions for /etc/hosts are preserved (or set correctly).

Signed-off-by: default avatarBernardo Dal Seno <bdalseno@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 0d20cc42
No related branches found
No related tags found
No related merge requests found
......@@ -62,7 +62,8 @@ def SetEtcHostsEntry(file_name, ip, hostname, aliases):
out.write(line)
_write_entry(written)
io.WriteFile(file_name, data=out.getvalue(), mode=0644)
io.WriteFile(file_name, data=out.getvalue(), uid=0, gid=0, mode=0644,
keep_perms=io.KP_IF_EXISTS)
def AddHostToEtcHosts(hostname, ip):
......@@ -104,7 +105,8 @@ def RemoveEtcHostsEntry(file_name, hostname):
out.write(line)
io.WriteFile(file_name, data=out.getvalue(), mode=0644)
io.WriteFile(file_name, data=out.getvalue(), uid=0, gid=0, mode=0644,
keep_perms=io.KP_IF_EXISTS)
def RemoveHostFromEtcHosts(hostname):
......
......@@ -44,6 +44,7 @@ class TestEtcHosts(testutils.GanetiTestCase):
handle.write("192.0.2.1 router gw\n")
finally:
handle.close()
os.chmod(self.tmpname, 0644)
def testSettingNewIp(self):
utils.SetEtcHostsEntry(self.tmpname, "198.51.100.4", "myhost.example.com",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment