Skip to content

(Maint) Don't change /etc/hosts permissions#577

Merged
slippycheeze merged 1 commit intopuppetlabs:2.7.xfrom
joshcooper:maint/2.7.x/fix-etc-hosts-test
Mar 14, 2012
Merged

(Maint) Don't change /etc/hosts permissions#577
slippycheeze merged 1 commit intopuppetlabs:2.7.xfrom
joshcooper:maint/2.7.x/fix-etc-hosts-test

Conversation

@joshcooper
Copy link
Copy Markdown
Contributor

Previously, the acceptance test was backing up /etc/hosts, modifying it,
verifying that puppet resource host returned all of the host records,
and then moving the backup over /etc/hosts. In doing so, the permissions
on /etc/hosts were overwritten.

Since puppet runs as root on agent nodes, the test was setting the mode
of /etc/hosts to 0600 (based on root's umask).

However, when the node is also a master, the puppet master cannot read
the file, since it runs as puppet. This causes problems for any later
test that uses with_master_running_on, e.g.
ticket_7117_broke_env_criteria_authconf.rb:

Could not resolve 192.168.100.114: Permission denied - /etc/hosts

This commit changes the test so that the existing /etc/hosts file is
truncated and the old contents restored, thereby preserving its old
mode.

Ideally, it would be nice to not have to overwrite /etc/hosts at all,
e.g. puppet resource host --param target=/my/tmp/file, but this only
works for a single host resource, not when querying all of them.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This no longer removes the backup file; can you manually delete that alsoL

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doh! Thanks, have updated the request

Previously, the acceptance test was backing up /etc/hosts, modifying it,
verifying that `puppet resource host` returned all of the host records,
and then moving the backup over /etc/hosts. In doing so, the permissions
on /etc/hosts were overwritten.

Since puppet runs as root on agent nodes, the test was setting the mode
of /etc/hosts to 0600 (based on root's umask).

However, when the node is also a master, the puppet master cannot read
the file, since it runs as `puppet`. This causes problems for any later
test that uses `with_master_running_on`, e.g.
ticket_7117_broke_env_criteria_authconf.rb:

   Could not resolve 192.168.100.114: Permission denied - /etc/hosts

This commit changes the test so that the existing /etc/hosts file is
truncated and the old contents restored, thereby preserving its old
mode.

Ideally, it would be nice to not have to overwrite /etc/hosts at all,
e.g. puppet resource host --param target=/my/tmp/file, but this only
works for a single host resource, not when querying all of them.
slippycheeze added a commit that referenced this pull request Mar 14, 2012
Don't change /etc/hosts permissions in acceptance tests.
@slippycheeze slippycheeze merged commit e1a4962 into puppetlabs:2.7.x Mar 14, 2012
melissa pushed a commit to melissa/puppet that referenced this pull request Mar 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants