Permalink
Browse files

Mode definitions in Chef shouldn't be strings.

There's no need for this and it breaks Food Critic FC002.  I've turned
them into 5 digit values
  • Loading branch information...
1 parent 65d9a43 commit d358433fdbc63f23cb39a3516464a428e20fce09 @tas50 tas50 committed Nov 20, 2012
View
2 Cookbook File/cookbook_file-full.sublime-snippet
@@ -6,7 +6,7 @@ cookbook_file "${1:name}" do
source "${4:source}"
owner "${5:root}"
group "${6:root}"
- mode "${7:0644}"
+ mode ${7:00644}
backup ${8:5}
cookbook "${9:cookbook}"
end
View
2 Cookbook File/cookbook_file.sublime-snippet
@@ -4,7 +4,7 @@ cookbook_file "${1:name}" do
source "${2:source}"
owner "root"
group "root"
- mode "0644"
+ mode 00644
end
]]></content>
View
2 Directory/directory-full.sublime-snippet
@@ -4,7 +4,7 @@ directory "${1:name}" do
action :${2:create}
owner "${3:root}"
group "${4:root}"
- mode "${5:0755}"
+ mode ${5:00755}
path "${6:name}"
recursive ${7:false}
end
View
2 Directory/directory-recursive.sublime-snippet
@@ -3,7 +3,7 @@
directory "${1:name}" do
owner "root"
group "root"
- mode "0755"
+ mode 00755
action :create
recursive true
end
View
2 Directory/directory.sublime-snippet
@@ -3,7 +3,7 @@
directory "${1:name}" do
owner "root"
group "root"
- mode "0755"
+ mode 00755
action :create
end
View
2 File/file-content.sublime-snippet
@@ -4,7 +4,7 @@ file "${1:name}" do
action :create
owner "root"
group "root"
- mode "0644"
+ mode 00644
content "${2:content here}"
end
View
2 File/file-full.sublime-snippet
@@ -6,7 +6,7 @@ file "${1:name}" do
backup ${4:5}
owner "${5:root}"
group "${6:root}"
- mode "${7:0644}"
+ mode ${7:00644}
content "${8:content here}"
end
View
2 File/file.sublime-snippet
@@ -4,7 +4,7 @@ file "${1:name}" do
action :create
owner "root"
group "root"
- mode "0644"
+ mode 00644
end
]]></content>
View
4 Remote Directory/remote_directory-full.sublime-snippet
@@ -5,10 +5,10 @@ remote_directory "${1:/tmp/remote_something}" do
files_backup ${3:10}
files_owner "${4:root}"
files_group "${5:root}"
- files_mode "${6:0644}"
+ files_mode ${6:00644}
owner "${7:root}"
group "${8:root}"
- mode "${9:0755}"
+ mode ${9:00755}
cookbook ${10:nil}
purge ${11:false}
overwrite ${12:true}
View
4 Remote Directory/remote_directory.sublime-snippet
@@ -4,10 +4,10 @@ remote_directory "${1:/tmp/remote_something}" do
source "${2:something}"
files_owner "${3:root}"
files_group "${4:root}"
- files_mode "${5:0644}"
+ files_mode ${5:00644}
owner "${6:root}"
group "${7:root}"
- mode "${8:0755}"
+ mode ${8:00755}
end
]]></content>
View
2 Remote File/remote_file.sublime-snippet
@@ -3,7 +3,7 @@
remote_file "${1:/tmp/remote_file}" do
owner "${2:root}"
group "${3:root}"
- mode "${4:0644}"
+ mode ${4:00644}
source "${5:http://www.example.com/remote_file}"
checksum "${6:sha256checksum}"
end
View
2 Remote File/remote_filef.sublime-snippet
@@ -5,7 +5,7 @@ remote_file "${1:/tmp/remote_file}" do
backup ${3:5}
owner "${4:root}"
group "${5:root}"
- mode "${6:0644}"
+ mode ${6:00644}
source "${7:http://www.example.com/remote_file}"
checksum "${8:sha256checksum}"
end
View
2 Remote File/remote_filem.sublime-snippet
@@ -4,7 +4,7 @@ remote_file "${1:/tmp/remote_file}" do
action ${2::create_if_missing}
owner "${3:root}"
group "${4:root}"
- mode "${5:0644}"
+ mode ${5:00644}
source "${6:http://www.example.com/remote_file}"
end
View
2 Template/template-variables.sublime-snippet
@@ -4,7 +4,7 @@ template "${1:name}" do
source "${2:source}.erb"
owner "root"
group "root"
- mode "0644"
+ mode 00644
variables( ${3::config_var => node[:configs][:config_var]} )
end
View
2 Template/template.sublime-snippet
@@ -4,7 +4,7 @@ template "${1:name}" do
source "${2:source}.erb"
owner "root"
group "root"
- mode "0644"
+ mode 00644
end
]]></content>

4 comments on commit d358433

@antage

What is a reason to use 5 digit mode value instead of 4 digit value?

@cabeca
Owner

Hi,

This is to ensure an octal number is passed to mode as described in the documentation ( http://docs.opscode.com/resource_file.html )

UNIX- and Linux-based systems: The octal mode that is passed to chmod. If the value is specified as a quoted string, it will work exactly as if the chmod command was passed. If the value is specified as an integer, prepend a zero (0) to the value to ensure it is interpreted as an octal number. For example, to assign read, write, and execute rights for all users, use 0777 or '777'; for the same rights, plus the sticky bit, use 01777 or '1777'.

@antage

@cabeca I see. But in ruby 00644 == 0644. Single leading zero is enough for an octal number constant. What is meaning to write two leading zero? I think it's noisy and ... unusual.

@cabeca
Owner

This is for when you need to use the sticky bit. The first zero is there to signify an octal constant. The second zero is there to specify the sticky bit. Imagine you use the directory snippet with a single leading zero:

directory "/foo" do
   owner "root"
   group "root"
   mode 0755
   action :create
   recursive true
 end

later you change your mind and update the sticky bit:

directory "foo" do
   owner "root"
   group "root"
   mode 1755
   action :create
   recursive true
 end

You now have an error that's difficult to debug. So, to simplify things and to avoid these kind of pitfalls, the snippets have two leading zeroes.

At least that's how I see the motivation behind the two zeroes in this pull request :-) /cc @tas50

Please sign in to comment.