Skip to content
This repository was archived by the owner on Nov 30, 2022. It is now read-only.

Commit 72b87b9

Browse files
Merge pull request #23 from codenamephp/setFileAndFolderPermissions
The init could execute the file.
2 parents bb58488 + c32def3 commit 72b87b9

5 files changed

Lines changed: 36 additions & 18 deletions

File tree

resources/cookbook_file.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
action_class do
1515
def create_file(folder, user, filename, cookbook_file)
1616
cookbook_file 'create file from cookbook_file' do
17-
mode '0640'
17+
mode '0770'
1818
owner user
19+
group user
1920
path "#{folder}/.bashrc.d/#{filename}"
2021
source cookbook_file
2122
cookbook new_resource.cookbook

resources/file.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ def create_file(folder, user, filename, file_content)
2121
# Managed by Chef. Local changes will be overwritten.
2222
#{file_content}
2323
FILE
24-
mode '0640'
24+
mode '0770'
2525
owner user
26+
group user
2627
path "#{folder}/.bashrc.d/#{filename}"
2728
end
2829
end

resources/manage.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@
1616
def init(folder, user)
1717
directory 'create .bashrc.d folder' do
1818
path "#{folder}/.bashrc.d"
19-
mode '0640'
19+
mode '0770'
2020
owner user
21+
group user
2122
end
2223

2324
file 'copy default .bashrc to init in dropfolder' do
2425
path "#{folder}/.bashrc.d/000-init"
25-
mode '0640'
26+
mode '0770'
2627
owner user
28+
group user
2729
content(lazy { ::File.read("#{folder}/.bashrc") })
2830
action :create_if_missing
2931
end
@@ -32,8 +34,9 @@ def init(folder, user)
3234
path "#{folder}/.bashrc"
3335
source '.bashrc.erb'
3436
cookbook 'codenamephp_bash'
35-
mode '0640'
37+
mode '0770'
3638
owner user
39+
group user
3740
end
3841
end
3942

resources/template.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
action_class do
1515
def create_file(folder, user, filename, source)
1616
template 'create file from template' do
17-
mode '0640'
17+
mode '0770'
1818
owner user
19+
group user
1920
path "#{folder}/.bashrc.d/#{filename}"
2021
source source
2122
cookbook new_resource.cookbook

test/smoke/default/default_test.rb

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,47 +17,53 @@
1717
it { should exist }
1818
it { should be_file }
1919
its('content') { should match(%r{# To manually add resources to the bashrc, create a file in the \~\/\.bashrc\.d folder and add your changes there\.}) }
20-
its('mode') { should cmp '0640' }
20+
its('mode') { should cmp '0770' }
2121
its('owner') { should eq 'root' }
22+
its('group') { should eq 'root' }
2223
end
2324

2425
describe file('/etc/skel/.bashrc.d') do
2526
it { should exist }
2627
it { should be_directory }
27-
its('mode') { should cmp '0640' }
28+
its('mode') { should cmp '0770' }
2829
its('owner') { should eq 'root' }
30+
its('group') { should eq 'root' }
2931
end
3032

3133
describe file('/etc/skel/.bashrc.d/000-init') do
3234
it { should exist }
3335
it { should be_file }
3436
its('content') { should match(%r{# \~\/\.bashrc: executed by bash\(1\) for non-login shells\.}) }
35-
its('mode') { should cmp '0640' }
37+
its('mode') { should cmp '0770' }
3638
its('owner') { should eq 'root' }
39+
its('group') { should eq 'root' }
3740
end
3841

3942
describe file('/etc/skel/.bashrc.d/100-content') do
4043
it { should exist }
4144
it { should be_file }
4245
its('content') { should match('just some test') }
43-
its('mode') { should cmp '0640' }
46+
its('mode') { should cmp '0770' }
4447
its('owner') { should eq 'root' }
48+
its('group') { should eq 'root' }
4549
end
4650

4751
describe file('/etc/skel/.bashrc.d/200-file') do
4852
it { should exist }
4953
it { should be_file }
5054
its('content') { should match('just some test file') }
51-
its('mode') { should cmp '0640' }
55+
its('mode') { should cmp '0770' }
5256
its('owner') { should eq 'root' }
57+
its('group') { should eq 'root' }
5358
end
5459

5560
describe file('/etc/skel/.bashrc.d/300-template') do
5661
it { should exist }
5762
it { should be_file }
5863
its('content') { should match('just some test template') }
59-
its('mode') { should cmp '0640' }
64+
its('mode') { should cmp '0770' }
6065
its('owner') { should eq 'root' }
66+
its('group') { should eq 'root' }
6167
end
6268
describe file('/etc/skel/.bashrc.d/400-content') do
6369
it { should_not exist }
@@ -70,47 +76,53 @@
7076
it { should exist }
7177
it { should be_file }
7278
its('content') { should match(%r{# To manually add resources to the bashrc, create a file in the \~\/\.bashrc\.d folder and add your changes there\.}) }
73-
its('mode') { should cmp '0640' }
79+
its('mode') { should cmp '0770' }
7480
its('owner') { should eq 'user1' }
81+
its('group') { should eq 'user1' }
7582
end
7683

7784
describe file('/home/user1/.bashrc.d') do
7885
it { should exist }
7986
it { should be_directory }
80-
its('mode') { should cmp '0640' }
87+
its('mode') { should cmp '0770' }
8188
its('owner') { should eq 'user1' }
89+
its('group') { should eq 'user1' }
8290
end
8391

8492
describe file('/home/user1/.bashrc.d/000-init') do
8593
it { should exist }
8694
it { should be_file }
8795
its('content') { should match(%r{# \~\/\.bashrc: executed by bash\(1\) for non-login shells\.}) }
88-
its('mode') { should cmp '0640' }
96+
its('mode') { should cmp '0770' }
8997
its('owner') { should eq 'user1' }
98+
its('group') { should eq 'user1' }
9099
end
91100

92101
describe file('/home/user1/.bashrc.d/100-content') do
93102
it { should exist }
94103
it { should be_file }
95104
its('content') { should match('just some test') }
96-
its('mode') { should cmp '0640' }
105+
its('mode') { should cmp '0770' }
97106
its('owner') { should eq 'user1' }
107+
its('group') { should eq 'user1' }
98108
end
99109

100110
describe file('/home/user1/.bashrc.d/200-file') do
101111
it { should exist }
102112
it { should be_file }
103113
its('content') { should match('just some test file') }
104-
its('mode') { should cmp '0640' }
114+
its('mode') { should cmp '0770' }
105115
its('owner') { should eq 'user1' }
116+
its('group') { should eq 'user1' }
106117
end
107118

108119
describe file('/home/user1/.bashrc.d/300-template') do
109120
it { should exist }
110121
it { should be_file }
111122
its('content') { should match('just some test template') }
112-
its('mode') { should cmp '0640' }
123+
its('mode') { should cmp '0770' }
113124
its('owner') { should eq 'user1' }
125+
its('group') { should eq 'user1' }
114126
end
115127
describe file('/home/user1/.bashrc.d/400-content') do
116128
it { should_not exist }

0 commit comments

Comments
 (0)