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

MODULES-10548: make files readonly #906

Merged
merged 1 commit into from
Feb 17, 2020
Merged

Conversation

anarcat
Copy link

@anarcat anarcat commented Feb 12, 2020

Files created by the apt module are mode writable by the
owner. Because those files are managed by Puppet, they should really
not be writable by anyone, even root. While root can bypass those
warnings, having files readonly does provide an immediate and reliable
indication that a file should not be edited on site, on top of the
usual top of file warnings.

This also fixes a problem with sources.list.d being non-executable,
which Puppet seems to ignore, but seems better to keep consistent.

@codecov
Copy link

codecov bot commented Feb 12, 2020

Codecov Report

Merging #906 into master will decrease coverage by 23.33%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           master     #906       +/-   ##
===========================================
- Coverage   73.07%   49.73%   -23.34%     
===========================================
  Files           5        5               
  Lines         260      382      +122     
===========================================
  Hits          190      190               
- Misses         70      192      +122     
Impacted Files Coverage Δ
lib/puppet/type/apt_key.rb 46.15% <0.00%> (-50.28%) ⬇️
lib/puppet/provider/apt_key/apt_key.rb 37.75% <0.00%> (-17.06%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dcb7116...ab2e06b. Read the comment docs.

@geor-g
Copy link

geor-g commented Feb 12, 2020

Thanks, LGTM.

Files created by the apt module are mode writable by the
owner. Because those files are managed by Puppet, they should really
not be writable by anyone, even root. While root can bypass those
warnings, having files readonly does provide an immediate and reliable
indication that a file should not be edited on site, on top of the
usual top of file warnings.

This also fixes a problem with sources.list.d being non-executable,
which Puppet seems to ignore, but seems better to keep consistent.
@carabasdaniel
Copy link

👍 LGTM, as there are no changes in Ruby code, the codecov should not have any impact in this PR

@carabasdaniel carabasdaniel merged commit 1bcd0b2 into puppetlabs:master Feb 17, 2020
@anarcat anarcat deleted the modes branch February 17, 2020 18:57
raoulbhatia added a commit to raoulbhatia/puppet-unattended_upgrades that referenced this pull request Mar 1, 2020
anarcat added a commit to anarcat/puppetlabs-apt that referenced this pull request Mar 11, 2020
MODULES-10583 makes a good point: "why are you messing with my file
permissions"? In my case, the entire reason I made the following
change (in PR puppetlabs#906):

ab2e06b MODULES-10548: make files readonly

... is exactly *because* Puppet was changing the file modes from under
me. I was migrating from our own in-house APT module to the forge one,
and our module did *not* intervene in those file modes: it left the
file resources alone. Which means we could have a directive like this:

    File {
        owner   => root,
        group   => root,
        mode    => '444',
        ensure  => file,
    }

... which made all files readonly by default. So when I migrated to
the Puppetlabs APT module, modes were changed to be writable, which I
did not want.

As I reasoned in MODULES-10548, having files readonly provides an
excellent indicator that a file is managed by Puppet, even if some
module does not add a warning header - either because it forgot or
because it's impossible. But I also understand if people do not like
that policy.

I think the proper way of doing this is not specifying a mode at all,
and let local site-specific policies apply. I specifically proppose
this as an alternative to puppetlabs#921 because I believe adding more
parameters to the resources will needlessly complicate the script,
when we have a native, Puppet-DSL supported way of changing those
modes according to the right scope and context.

In a similar way, we might want to reconsider user and group ownership
of the files, but that can be done in a later time.

This reverts commit 316fd8f.

Signed-off-by: Antoine Beaupré <anarcat@debian.org>
anarcat added a commit to anarcat/puppetlabs-apt that referenced this pull request Mar 11, 2020
MODULES-10583 makes a good point: "why are you messing with my file
permissions"? In my case, the entire reason I made the following
change (in PR puppetlabs#906):

ab2e06b MODULES-10548: make files readonly

... is exactly *because* Puppet was changing the file modes from under
me. I was migrating from our own in-house APT module to the forge one,
and our module did *not* intervene in those file modes: it left the
file resources alone. Which means we could have a directive like this:

    File {
        owner   => root,
        group   => root,
        mode    => '444',
        ensure  => file,
    }

... which made all files readonly by default. So when I migrated to
the Puppetlabs APT module, modes were changed to be writable, which I
did not want.

As I reasoned in MODULES-10548, having files readonly provides an
excellent indicator that a file is managed by Puppet, even if some
module does not add a warning header - either because it forgot or
because it's impossible. But I also understand if people do not like
that policy.

I think the proper way of doing this is not specifying a mode at all,
and let local site-specific policies apply. I specifically proppose
this as an alternative to puppetlabs#921 because I believe adding more
parameters to the resources will needlessly complicate the script,
when we have a native, Puppet-DSL supported way of changing those
modes according to the right scope and context.

In a similar way, we might want to reconsider user and group ownership
of the files, but that can be done in a later time.

This reverts commit 316fd8f.

Signed-off-by: Antoine Beaupré <anarcat@debian.org>
anarcat added a commit to anarcat/puppetlabs-apt that referenced this pull request Mar 11, 2020
MODULES-10583 makes a good point: "why are you messing with my file
permissions"? In my case, the entire reason I made the following
change (in PR puppetlabs#906):

ab2e06b MODULES-10548: make files readonly

... is exactly *because* Puppet was changing the file modes from under
me. I was migrating from our own in-house APT module to the forge one,
and our module did *not* intervene in those file modes: it left the
file resources alone. Which means we could have a directive like this:

    File {
        owner   => root,
        group   => root,
        mode    => '444',
        ensure  => file,
    }

... which made all files readonly by default. So when I migrated to
the Puppetlabs APT module, modes were changed to be writable, which I
did not want.

As I reasoned in MODULES-10548, having files readonly provides an
excellent indicator that a file is managed by Puppet, even if some
module does not add a warning header - either because it forgot or
because it's impossible. But I also understand if people do not like
that policy.

I think the proper way of doing this is not specifying a mode at all,
and let local site-specific policies apply. I specifically proppose
this as an alternative to puppetlabs#921 because I believe adding more
parameters to the resources will needlessly complicate the script,
when we have a native, Puppet-DSL supported way of changing those
modes according to the right scope and context.

In a similar way, we might want to reconsider user and group ownership
of the files, but that can be done in a later time.

This reverts commit 316fd8f.

Signed-off-by: Antoine Beaupré <anarcat@debian.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants