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

Add a convenience wrapper for restorecon execs #205

Merged
merged 1 commit into from
Mar 31, 2017

Conversation

oranenj
Copy link
Contributor

@oranenj oranenj commented Mar 25, 2017

This wraps a restorecon exec so that it will execute after all other SELinux changes have been applied

Not yet very thorougly tested (or integrated with the fcontext define) but it should be useful enough standalone. Any comments?

}

exec {"selinux::exec_restorecon ${path}":
path => '/sbin:/usr/sbin',
Copy link
Contributor

Choose a reason for hiding this comment

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

everytime i see path set on exec in forge modules i start thinking what is right: setting it here or leave it up to the user to set global defaults?

but this will work on all our supported platforms.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this should be fine. If there's a need to fix it, that can be done without breaking things.

I like specifying paths explicitly so that the exec is not vulnerable to the user's environment being somehow compromised.

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, all resources inside receive the notify.

just wanted to know if the explicit notify was inteded. :) this is fine with me.

exec {"selinux::exec_restorecon ${path}":
path => '/sbin:/usr/sbin',
command => sprintf('%s %s', $command, shellquote($path)),
refreshonly => $refreshonly,
Copy link
Contributor

Choose a reason for hiding this comment

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

it's refershonly ... how does it receive notifys?

Is it tought a user defines explicit notifies?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you notify the define, I think all resources inside the define receive a notify too. That will work in this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And yeah, this is not integrated with the fcontext define yet. That's trickier to do, so for now it's just a convenience wrapper for the user's own manifests.

We can later extend the fcontext define to include an optional automatic restorecon exec

@@ -0,0 +1,45 @@
require 'spec_helper'

describe 'selinux::exec_restorecon' do
Copy link
Contributor

Choose a reason for hiding this comment

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

<3 tests. :) 👍

@vinzent vinzent added this to the 1.0.0 milestone Mar 29, 2017
@vinzent vinzent added the enhancement New feature or request label Mar 29, 2017
}

exec {"selinux::exec_restorecon ${path}":
path => '/sbin:/usr/sbin',
Copy link
Contributor

Choose a reason for hiding this comment

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

yes, all resources inside receive the notify.

just wanted to know if the explicit notify was inteded. :) this is fine with me.

@oranenj oranenj added the needs-feedback Further information is requested label Mar 29, 2017
Boolean $refreshonly = true,
Boolean $recurse = true,
Optional[String] $unless = undef,
Optional[String] $onlyif = undef,
Copy link
Member

Choose a reason for hiding this comment

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

can you reformat this to allign the =?

The vim plugin junegunn/vim-easy-align can easily do that for you.

This wraps restorecon execution so that it will execute
after all other SELinux changes have been applied
@oranenj
Copy link
Contributor Author

oranenj commented Mar 31, 2017

Given that it's a pretty useful convenience tool in many cases (we use a similar custom define ourselves), I'll just deem this reviewed well enough.

@oranenj oranenj merged commit feaaa55 into voxpupuli:master Mar 31, 2017
EmRowlands pushed a commit to EmRowlands/puppet-selinux that referenced this pull request Mar 29, 2023
Add a convenience wrapper for restorecon execs
cegeka-jenkins pushed a commit to cegeka/puppet-selinux that referenced this pull request Jan 10, 2025
Add a convenience wrapper for restorecon execs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs-feedback Further information is requested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants