• Guido Trotter's avatar
    Apply the right permissions to /etc/hosts · 9b977740
    Guido Trotter authored
    In the current Ganeti version when modifying /etc/hosts we mistakenly
    give it the permissions of the temporary file we create to define its
    content, which is by default 0600. This breaks most non-root
    applications, and thus must be corrected. This patch forces the mode to
    be 0644 (but we might decide to just use the mode of the previous
    /etc/hosts, if we want to be more polite against any eventual
    administrative choice). We also add a new assertFileMode() method for
    unit tests and actually check in the SetEtcHostsEntry and
    RemoveEtcHostsEntry tests that the mode is correct, to be sure not to
    reintroduce this bug again. Also, a FIXME is added in the original
    functions stating that it would be nice to use WriteFile+fn() rather
    than reimplementing its functionality again.
    
    Reviewed-by: iustinp
    9b977740
utils.py 54.6 KB