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

Using relative file modes can result very wrong in some cases #222

Closed
igalic opened this issue Sep 5, 2019 · 1 comment
Closed

Using relative file modes can result very wrong in some cases #222

igalic opened this issue Sep 5, 2019 · 1 comment

Comments

@igalic
Copy link

igalic commented Sep 5, 2019

Describe the bug

Let's assume someone ("accidentally") set a funky mode for /etc/crontab, such as 5777.
Since our code sets the mode relatively:

  ensure_resources ('file',
  { '/etc/crontab' => {
      ensure       => file,
      mode         => 'og-rwx',
      owner        => 'root',
      group        => 'root',
    }
  })

This can lead to unexpected or at least unwanted results.

Expected behavior
I want the file modes to be deterministic, no matter what their (wrongly) pre-configured state.

Actual behavior

% ls -l /etc/crontab
-rwsrwxrwt. 1 root root 722 Nov 16  2017 /etc/crontab

After applying

class { 'os_hardening::minimize_access':
  manage_cron_permissions = true,
}

our crontab now like this:

% ls -l /etc/crontab
-rws-----T. 1 root root 722 Nov 16  2017 /etc/crontab

which is still wrong.

OS / Environment

Red Hat Enterprise Linux Server 7.6

Puppet Version

5.5.16
@mcgege
Copy link
Member

mcgege commented Sep 11, 2019

@igalic Thanks for reporting this ... indeed the current solution cannot fix all misconfigurations, but I doubt this can be solved easily. For this to work you would have to define a sane file mode for all relevant files on all supported distributions ... we could limit this (for now) to /etc/crontab, but what about the rest of files / directories we manage?

@mcgege mcgege closed this as completed Jul 9, 2021
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

No branches or pull requests

2 participants