itamae-plugin-resource-security_context 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9b8d401721e7d5dacaa4dfa672e6d407fa3e6139
4
+ data.tar.gz: 4b7c369724fe0a0e08454d9d895013b53c73c579
5
+ SHA512:
6
+ metadata.gz: a4e86551acf59e23e0205dee3f63dd9ada4d29888c1b95dee47f5fcef893812b93e95c7a7e689d0185aecb01811753d20459dca446237372903999ea550fb361
7
+ data.tar.gz: 70d91bb369339d6e3e8e590b4c7fa81957dada717fec482190d66ac25420029bdfe68f36282bbce98625c5098530c3199ed4b1df3a553ddeeb21498fed0ab363
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ README.md
3
+ ChangeLog.md
4
+
5
+ COPYING.txt
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ /.bundle
2
+ /Gemfile.lock
3
+ /html/
4
+ /pkg/
5
+ /vendor/cache/*.gem
data/.rdoc_options ADDED
@@ -0,0 +1,16 @@
1
+ --- !ruby/object:RDoc::Options
2
+ encoding: UTF-8
3
+ static_path: []
4
+ rdoc_include:
5
+ - .
6
+ charset: UTF-8
7
+ exclude:
8
+ hyperlink_all: false
9
+ line_numbers: false
10
+ main_page: README.md
11
+ markup: markdown
12
+ show_hash: false
13
+ tab_width: 8
14
+ title: itamae-plugin-resource-security_context Documentation
15
+ visibility: :protected
16
+ webcvs:
data/COPYING.txt ADDED
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
data/ChangeLog.md ADDED
@@ -0,0 +1,4 @@
1
+ ### 0.1.0 / 2016-01-20
2
+
3
+ * Initial release:
4
+
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/README.md ADDED
@@ -0,0 +1,85 @@
1
+ itamae-plugin-resource-security_context
2
+ =======================================
3
+
4
+ * [Homepage](https://rubygems.org/gems/itamae-plugin-resource-security_context)
5
+ * [Documentation](http://rubydoc.info/gems/itamae-plugin-resource-security_context/frames)
6
+ * [Email](mailto:KitaitiMakoto at gmail.com)
7
+
8
+ Description
9
+ -----------
10
+
11
+ [Itamae][] resource plugin to handle with SELinux security context.
12
+
13
+ Features
14
+ --------
15
+
16
+ * Restoring security context
17
+
18
+ Currently, only the feature above is supported.
19
+
20
+ Examples
21
+ --------
22
+
23
+ At first, load this plugin.
24
+
25
+ require 'itamae/plugin/resource/security_context'
26
+
27
+ ### Restoring security context every time Itamae runs
28
+
29
+ security_context '/etc/nginx/nginx.conf' do
30
+ action :restore
31
+ end
32
+
33
+ Note that default action of `security_context` is `:nothing`, you need to write `action` directory when you want to restore security context.
34
+
35
+ You can also restore context recursively:
36
+
37
+ security_context '/etc/httpd/conf.d' do
38
+ action :restore
39
+ recursive true
40
+ end
41
+
42
+ ### Restoring security context when file is modified
43
+
44
+ security_context '/etc/nginx/nginx.conf' do
45
+ action :nothing
46
+ end
47
+
48
+ template '/etc/nginx/nginx.conf' do
49
+ source :auto
50
+ owner 'root'
51
+ group 'root'
52
+ mode '644'
53
+ notifies :restore, 'security_context[/etc/nginx/nginx.conf]'
54
+ end
55
+
56
+ As noted earlier, the default action of `security_context` is `:nothing`, so you can ommit block:
57
+
58
+ security_context '/etc/nginx/nginx.conf'
59
+
60
+ template '/etc/nginx/nginx.conf' do
61
+ source :auto
62
+ owner 'root'
63
+ group 'root'
64
+ mode '644'
65
+ notifies :restore, 'security_context[/etc/nginx/nginx.conf]'
66
+ end
67
+
68
+ Requirements
69
+ ------------
70
+
71
+ * [Itamae][]
72
+
73
+ Install
74
+ -------
75
+
76
+ $ gem install itamae-plugin-resource-security_context
77
+
78
+ Copyright
79
+ ---------
80
+
81
+ Copyright (c) 2016 KITAITI Makoto
82
+
83
+ See COPYING.txt for details.
84
+
85
+ [Itamae]: http://itamae.kitchen
data/Rakefile ADDED
@@ -0,0 +1,26 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+
5
+ begin
6
+ require 'bundler/setup'
7
+ rescue LoadError => e
8
+ abort e.message
9
+ end
10
+
11
+ require 'rake'
12
+
13
+
14
+ require 'rubygems/tasks'
15
+ Gem::Tasks.new
16
+
17
+ require 'rdoc/task'
18
+ RDoc::Task.new
19
+ task :doc => :rdoc
20
+
21
+ require 'rake/testtask'
22
+ Rake::TestTask.new do |test|
23
+ test.libs << 'test'
24
+ test.pattern = 'test/**/test_*.rb'
25
+ test.verbose = true
26
+ end
@@ -0,0 +1,38 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'itamae/plugin/resource/security_context/version'
6
+
7
+ Gem::Specification.new do |gem|
8
+ gem.name = "itamae-plugin-resource-security_context"
9
+ gem.version = Itamae::Plugin::Resource::SecurityContext::VERSION
10
+ gem.summary = %q{Itamae SELinux security context resource plugin}
11
+ gem.description = %q{Itamae resource plugin to handle with SELinux security context.}
12
+ gem.license = "LGPL"
13
+ gem.authors = ["KITAITI Makoto"]
14
+ gem.email = "KitaitiMakoto@gmail.com"
15
+ gem.homepage = "https://rubygems.org/gems/itamae-plugin-resource-security_context"
16
+
17
+ gem.files = `git ls-files`.split($/)
18
+
19
+ `git submodule --quiet foreach --recursive pwd`.split($/).each do |submodule|
20
+ submodule.sub!("#{Dir.pwd}/",'')
21
+
22
+ Dir.chdir(submodule) do
23
+ `git ls-files`.split($/).map do |subpath|
24
+ gem.files << File.join(submodule,subpath)
25
+ end
26
+ end
27
+ end
28
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
29
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
30
+ gem.require_paths = ['lib']
31
+
32
+ gem.add_runtime_dependency 'itamae'
33
+
34
+ gem.add_development_dependency 'bundler', '~> 1.10'
35
+ gem.add_development_dependency 'rake', '~> 10.0'
36
+ gem.add_development_dependency 'rdoc', '~> 4.0'
37
+ gem.add_development_dependency 'rubygems-tasks', '~> 0.2'
38
+ end
@@ -0,0 +1,19 @@
1
+ require 'itamae/plugin/resource/security_context/version'
2
+
3
+ module Itamae
4
+ module Plugin
5
+ module Resource
6
+ class SecurityContext < ::Itamae::Resource::Base
7
+ define_attribute :action, default: :nothing
8
+ define_attribute :path, type: [String], default_name: true
9
+ define_attribute :recursive, type: [TrueClass, FalseClass], default: false
10
+
11
+ def action_restore(options)
12
+ cmd = ['restorecon', attributes.path]
13
+ cmd << '-R' if attributes.recursive
14
+ run_command cmd
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,28 @@
1
+ #
2
+ # Copyright (c) 2016 KITAITI Makoto (KitaitiMakoto at gmail.com)
3
+ #
4
+ # itamae-plugin-resource-security_context is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU Lesser General Public License as published
6
+ # by the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # itamae-plugin-resource-security_context is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU Lesser General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU Lesser General Public License
15
+ # along with itamae-plugin-resource-security_context. If not, see <http://www.gnu.org/licenses/>.
16
+ #
17
+ require 'itamae'
18
+
19
+ module Itamae
20
+ module Plugin
21
+ module Resource
22
+ class SecurityContext < ::Itamae::Resource::Base
23
+ # itamae-plugin-resource-security_context version
24
+ VERSION = "0.1.0"
25
+ end
26
+ end
27
+ end
28
+ end
data/test/helper.rb ADDED
@@ -0,0 +1,12 @@
1
+ require 'rubygems'
2
+
3
+ begin
4
+ require 'bundler/setup'
5
+ rescue LoadError => error
6
+ abort error.message
7
+ end
8
+
9
+ require 'test/unit'
10
+
11
+ class Test::Unit::TestCase
12
+ end
@@ -0,0 +1,12 @@
1
+ require 'helper'
2
+ require 'itamae/plugin/resource/security_context'
3
+
4
+ class TestItamae::Plugin::Resource::SecurityContext < Test::Unit::TestCase
5
+
6
+ def test_version
7
+ version = Itamae::Plugin::Resource::SecurityContext.const_get('VERSION')
8
+
9
+ assert !version.empty?, 'should have a VERSION constant'
10
+ end
11
+
12
+ end
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: itamae-plugin-resource-security_context
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - KITAITI Makoto
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-01-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: itamae
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.10'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.10'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rdoc
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '4.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '4.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubygems-tasks
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.2'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.2'
83
+ description: Itamae resource plugin to handle with SELinux security context.
84
+ email: KitaitiMakoto@gmail.com
85
+ executables: []
86
+ extensions: []
87
+ extra_rdoc_files: []
88
+ files:
89
+ - ".document"
90
+ - ".gitignore"
91
+ - ".rdoc_options"
92
+ - COPYING.txt
93
+ - ChangeLog.md
94
+ - Gemfile
95
+ - README.md
96
+ - Rakefile
97
+ - itamae-plugin-resource-security_context.gemspec
98
+ - lib/itamae/plugin/resource/security_context.rb
99
+ - lib/itamae/plugin/resource/security_context/version.rb
100
+ - test/helper.rb
101
+ - test/test_itamae-plugin-resource-security_context.rb
102
+ homepage: https://rubygems.org/gems/itamae-plugin-resource-security_context
103
+ licenses:
104
+ - LGPL
105
+ metadata: {}
106
+ post_install_message:
107
+ rdoc_options: []
108
+ require_paths:
109
+ - lib
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ requirements: []
121
+ rubyforge_project:
122
+ rubygems_version: 2.5.1
123
+ signing_key:
124
+ specification_version: 4
125
+ summary: Itamae SELinux security context resource plugin
126
+ test_files:
127
+ - test/helper.rb
128
+ - test/test_itamae-plugin-resource-security_context.rb