Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PUP-2289 Fix host type and provider. #3005

Closed
wants to merge 1 commit into from

Commits on Oct 23, 2014

  1. (PUP-2289) Fix host type newline validation

    This commit fix the first bug reported on PUP-2289.
    This is done by implementing validation of newlines
    on ip, hostname, comments and host_aliases, making
    sure we don't have any \n or \r.
    
    The bug and fix is on host resource type.
    
    Bellow is the problem description:
    
    If the ip address or hostname or host_aliases
    use double quoting and have \n, Puppet Will:
    
    1 - Write the wrong entry on /etc/hosts with the linebreak.
    This leads to a corrupted /etc/hosts, with some lines
    that could not be parsed by the host resource provider
    parsed.
    
    This leads to second bug on the second puppet run,
    where it will have error after failing to parse the file,
    but wipes out the /etc/hosts file, writing only the information
    on that file that is managed by puppet.
    
    How to reproduce it:
    1- backup /etc/hosts
    cp /etc/hosts /etc/hosts.orig
    2 - Create the script to reproduce the bug 01
    cat <<EOF > /tmp/hostsbug.pp
    host {'hostsbug': ip => "10.10.12.1\n" }
    EOF
    The same apply if you have newline on hostname, hostaliases or comment.
    3 - Run the script the first time to reproduce bug 01.
    puppet apply /tmp/hostsbug.pp
    4 - Check /etc/hosts
    cat /etc/hosts
    
    Leonardo Rodrigues de Mello
    
    PUP-2289 Fix bug on host resource provider
    
    The host resource provider parsed file wipes
    all entries of etc/hosts file if it gets one
    entry that could not be parsed.
    
    This commits fix this problem, considering that
    incomplete lines are :text_lines. This is the same
    solution that was used for mount resource provider.
    
    I  had checked that etc/hosts ignores invalid entries
    at least on linux, tested on rhel 5, 6, 7 and debian 5,6,7 and
    fedora 20.
    
    It would be great if someone could test it on other platforms.
    
    Thanks
    Leonardo Rodrigues  de Mello
    
    Fixes as required on the pull request
    lmello committed Oct 23, 2014
    Configuration menu
    Copy the full SHA
    44032d4 View commit details
    Browse the repository at this point in the history