Merge pull request #142 from shadeslayer/github_master

Make sure we also write to the /etc/hosts file
main
Teo Mrnjavac 10 years ago
commit 294d6a34ca

@ -64,5 +64,22 @@ Calamares::JobResult SetHostNameJob::exec()
out << m_hostname << "\n"; out << m_hostname << "\n";
hostfile.close(); hostfile.close();
QFile hostsfile( destDir + "/etc/hosts" );
if ( !hostfile.open( QFile::WriteOnly ) )
{
cLog() << "Can't write to hosts file";
return Calamares::JobResult::error( tr( "Cannot write hostname to target system" ) );
}
// We also need to write the appropriate entries for /etc/hosts
QTextStream out( &hostsfile );
// ipv4 support
out << "127.0.0.1" << "\t" << "localhost" << "\n";
out << "127.0.1.1" << "\t" << m_hostname << "\n";
// ipv6 support
out << "::1" << "\t" << "localhost ip6-localhost ip6-loopback" << "\n";
out << "ff02::1 ip6-allnodes" << "\n" << "ff02::2 ip6-allrouters" << "\n";
hostsfile.close();
return Calamares::JobResult::ok(); return Calamares::JobResult::ok();
} }

Loading…
Cancel
Save