Merge pull request #113209 from luozhiwenn/personal/etc-host

ensure etc-host file permission is 644 whatever umask is
This commit is contained in:
Kubernetes Prow Robot 2023-05-16 01:41:35 -07:00 committed by GitHub
commit 03b2e84183
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -344,7 +344,11 @@ func ensureHostsFile(fileName string, hostIPs []string, hostName, hostDomainName
hostsFileContent = managedHostsFileContent(hostIPs, hostName, hostDomainName, hostAliases)
}
return os.WriteFile(fileName, hostsFileContent, 0644)
hostsFilePerm := os.FileMode(0644)
if err := os.WriteFile(fileName, hostsFileContent, hostsFilePerm); err != nil {
return err
}
return os.Chmod(fileName, hostsFilePerm)
}
// nodeHostsFileContent reads the content of node's hosts file.