Skip to content

Instantly share code, notes, and snippets.

@equick
Created October 11, 2015 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save equick/da99a509a5091c125030 to your computer and use it in GitHub Desktop.
Save equick/da99a509a5091c125030 to your computer and use it in GitHub Desktop.
* selinux_policy_port[8029] action addormodify
Recipe: selinux_policy::helper_scripts
* remote_directory[/var/chef/cache/selinux_policy/helper_scripts] action create
Recipe: <Dynamically Defined Resource>
* cookbook_file[/var/chef/cache/selinux_policy/helper_scripts/port_locate.py] action create
- update content in file /var/chef/cache/selinux_policy/helper_scripts/port_locate.py from 56fc8f to ed1da3
--- /var/chef/cache/selinux_policy/helper_scripts/port_locate.py 2015-10-11 20:44:27.410039803 +0100
+++ /var/chef/cache/selinux_policy/helper_scripts/.port_locate.py20151011-32335-yvsok0 2015-10-11 21:10:48.229041347 +0100
@@ -34,7 +34,7 @@
import seobject
pr=seobject.portRecords().get_all()
-matching_key = find(lambda k: k[0]<=start_port and k[1]>=end_port and k[2]==protocol ,pr.keys())
+matching_key = find(lambda k: k[0]<=port_start and k[1]>=port_end and k[2]==protocol ,pr.keys())
actual_label = pr[matching_key][0]
if matching_key:
if (not label) or (label == actual_label):
- restore selinux security context
* execute[selinux-port-8029-addormodify] action run
================================================================================
Error executing action `run` on resource 'execute[selinux-port-8029-addormodify]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of if /var/chef/cache/selinux_policy/helper_scripts/port_locate.py tcp 8029 ; then
/usr/sbin/semanage port -m -t http_port_t -p tcp 8029
else
/usr/sbin/semanage port -a -t http_port_t -p tcp 8029
fi
----
STDOUT: Label mismatch (1024, 32767, 'tcp') unreserved_port_t
STDERR: ValueError: Port tcp/8029 already defined
---- End output of if /var/chef/cache/selinux_policy/helper_scripts/port_locate.py tcp 8029 ; then
/usr/sbin/semanage port -m -t http_port_t -p tcp 8029
else
/usr/sbin/semanage port -a -t http_port_t -p tcp 8029
fi
----
Ran if /var/chef/cache/selinux_policy/helper_scripts/port_locate.py tcp 8029 ; then
/usr/sbin/semanage port -m -t http_port_t -p tcp 8029
else
/usr/sbin/semanage port -a -t http_port_t -p tcp 8029
fi
returned 1
Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/selinux_policy/providers/port.rb
52: execute "selinux-port-#{new_resource.port}-addormodify" do
53: command <<-EOT
54: if #{port_defined(new_resource.port, new_resource.protocol)}; then
55: /usr/sbin/semanage port -m -t #{new_resource.secontext} -p #{new_resource.protocol} #{new_resource.port}
56: else
57: /usr/sbin/semanage port -a -t #{new_resource.secontext} -p #{new_resource.protocol} #{new_resource.port}
58: fi
59: EOT
60: not_if port_defined(new_resource.port, new_resource.protocol, new_resource.secontext)
61: only_if {use_selinux}
62: end
63: end
Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/selinux_policy/providers/port.rb:52:in `block in class_from_file'
execute("selinux-port-8029-addormodify") do
action "run"
retries 0
retry_delay 2
default_guard_interpreter :execute
command " if /var/chef/cache/selinux_policy/helper_scripts/port_locate.py tcp 8029 ; then\n /usr/sbin/semanage port -m -t http_port_t -p tcp 8029\n else\n /usr/sbin/semanage port -a -t http_port_t -p tcp 8029\n fi\n"
backup 5
returns 0
declared_type :execute
cookbook_name "tomcat-examples"
not_if "/var/chef/cache/selinux_policy/helper_scripts/port_locate.py tcp 8029 http_port_t"
only_if { #code block }
end
================================================================================
Error executing action `addormodify` on resource 'selinux_policy_port[8029]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
execute[selinux-port-8029-addormodify] (/var/chef/cache/cookbooks/selinux_policy/providers/port.rb line 52) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of if /var/chef/cache/selinux_policy/helper_scripts/port_locate.py tcp 8029 ; then
/usr/sbin/semanage port -m -t http_port_t -p tcp 8029
else
/usr/sbin/semanage port -a -t http_port_t -p tcp 8029
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment