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
...@@ -62,7 +62,8 @@ def SetEtcHostsEntry(file_name, ip, hostname, aliases): ...@@ -62,7 +62,8 @@ def SetEtcHostsEntry(file_name, ip, hostname, aliases):
out.write(line) out.write(line)
_write_entry(written) _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): def AddHostToEtcHosts(hostname, ip):
...@@ -104,7 +105,8 @@ def RemoveEtcHostsEntry(file_name, hostname): ...@@ -104,7 +105,8 @@ def RemoveEtcHostsEntry(file_name, hostname):
out.write(line) 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): def RemoveHostFromEtcHosts(hostname):
......
...@@ -44,6 +44,7 @@ class TestEtcHosts(testutils.GanetiTestCase): ...@@ -44,6 +44,7 @@ class TestEtcHosts(testutils.GanetiTestCase):
handle.write("192.0.2.1 router gw\n") handle.write("192.0.2.1 router gw\n")
finally: finally:
handle.close() handle.close()
os.chmod(self.tmpname, 0644)
def testSettingNewIp(self): def testSettingNewIp(self):
utils.SetEtcHostsEntry(self.tmpname, "198.51.100.4", "myhost.example.com", utils.SetEtcHostsEntry(self.tmpname, "198.51.100.4", "myhost.example.com",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment