diff options
35 files changed, 155 insertions, 36 deletions
@@ -17,6 +17,12 @@ group(:maintenance) do gem "netrc" end +group(:pry) do + gem "pry" + gem "pry-byebug" + gem "pry-stack_explorer" +end + group(:ruby_prof) do # may need to disable this in insolation on fussy builds like AIX, RHEL4, etc gem "ruby-prof" @@ -31,10 +37,6 @@ group(:development, :test) do gem "chefstyle", git: "https://github.com/chef/chefstyle.git", branch: "master" gem "ruby-shadow", platforms: :ruby unless RUBY_PLATFORM.downcase =~ /(aix|cygwin)/ - - gem "pry" - gem "pry-byebug" - gem "pry-stack_explorer" end group(:travis) do diff --git a/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/top_cookbooks.rb b/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/top_cookbooks.rb index 3098b334ce..83271d243d 100644 --- a/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/top_cookbooks.rb +++ b/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/top_cookbooks.rb @@ -19,5 +19,25 @@ class TopCookbooks < Chef::Resource repository "learn-chef/learn-chef-acceptance" cookbook_relative_dir "cookbooks/learn-the-basics-windows" end + + cookbook_kitchen "#{command} powershell" do + end + + cookbook_kitchen "#{command} windows" do + end + + cookbook_kitchen "#{command} iis" do + end + + cookbook_kitchen "#{command} sql_server" do + end + + cookbook_kitchen "#{command} winbox" do + repository "adamedx/winbox" + end + + cookbook_kitchen "#{command} chocolatey" do + repository "chocolatey/chocolatey-cookbook" + end end end diff --git a/acceptance/top-cookbooks/.kitchen.chocolatey.yml b/acceptance/top-cookbooks/.kitchen.chocolatey.yml new file mode 100644 index 0000000000..7d7529d69f --- /dev/null +++ b/acceptance/top-cookbooks/.kitchen.chocolatey.yml @@ -0,0 +1,6 @@ +suites: + - name: default + run_list: + - recipe[chocolatey::default] + - recipe[chocolatey_test::default] + includes: [windows-2012r2] diff --git a/acceptance/top-cookbooks/.kitchen.iis.yml b/acceptance/top-cookbooks/.kitchen.iis.yml new file mode 100644 index 0000000000..ffbc23caba --- /dev/null +++ b/acceptance/top-cookbooks/.kitchen.iis.yml @@ -0,0 +1,4 @@ +suites: + - name: iis + run_list: ["recipe[iis::default]"] + includes: [windows-2012r2] diff --git a/acceptance/top-cookbooks/.kitchen.powershell.yml b/acceptance/top-cookbooks/.kitchen.powershell.yml new file mode 100644 index 0000000000..6fad2364bb --- /dev/null +++ b/acceptance/top-cookbooks/.kitchen.powershell.yml @@ -0,0 +1,4 @@ +suites: + - name: powershell + run_list: ["recipe[powershell::powershell2]"] + includes: [windows-2012r2] diff --git a/acceptance/top-cookbooks/.kitchen.sql_server.yml b/acceptance/top-cookbooks/.kitchen.sql_server.yml new file mode 100644 index 0000000000..51a6bd6616 --- /dev/null +++ b/acceptance/top-cookbooks/.kitchen.sql_server.yml @@ -0,0 +1,5 @@ +suites: + - name: sql_server + run_list: ["recipe[sql_server::default]"] + attributes: { sql_server: { accept_eula: true } } + includes: [windows-2012r2] diff --git a/acceptance/top-cookbooks/.kitchen.winbox.yml b/acceptance/top-cookbooks/.kitchen.winbox.yml new file mode 100644 index 0000000000..9cf39a0d5b --- /dev/null +++ b/acceptance/top-cookbooks/.kitchen.winbox.yml @@ -0,0 +1,8 @@ +suites: + - name: default + run_list: + - recipe[winbox::default] + includes: [windows-2012r2] + +verifier: + name: dummy diff --git a/acceptance/top-cookbooks/.kitchen.windows.yml b/acceptance/top-cookbooks/.kitchen.windows.yml new file mode 100644 index 0000000000..38c86ff322 --- /dev/null +++ b/acceptance/top-cookbooks/.kitchen.windows.yml @@ -0,0 +1,38 @@ +suites: + # Waiting on https://github.com/chef-cookbooks/windows/pull/350 + # - name: tasks + # run_list: + # - recipe[windows::default] + # - recipe[minimal::tasks] + # includes: [windows-2012r2] + - name: path + run_list: + - recipe[windows::default] + - recipe[minimal::path] + includes: [windows-2012r2] + - name: certificate + run_list: + - recipe[windows::default] + - recipe[minimal::certificate] + includes: [windows-2012r2] + # Package is deprecated + # - name: package + # run_list: + # - recipe[windows::default] + # - recipe[minimal::package] + # includes: [windows-2012r2] + - name: feature + run_list: + - recipe[windows::default] + - recipe[minimal::feature] + includes: [windows-2012r2] + - name: http_acl + run_list: + - recipe[windows::default] + - recipe[minimal::http_acl] + includes: [windows-2012r2] + - name: font + run_list: + - recipe[windows::default] + - recipe[minimal::font] + includes: [windows-2012r2] diff --git a/chef-config/lib/chef-config/config.rb b/chef-config/lib/chef-config/config.rb index 3a20469397..d2a4bddba0 100644 --- a/chef-config/lib/chef-config/config.rb +++ b/chef-config/lib/chef-config/config.rb @@ -703,6 +703,9 @@ module ChefConfig # Use atomic updates (i.e. move operation) while updating contents # of the files resources. When set to false copy operation is # used to update files. + # + # NOTE: CHANGING THIS SETTING MAY CAUSE CORRUPTION, DATA LOSS AND + # INSTABILITY. default :file_atomic_update, true # There are 3 possible values for this configuration setting. diff --git a/chef-config/lib/chef-config/path_helper.rb b/chef-config/lib/chef-config/path_helper.rb index 42047b5e22..0c00e116ea 100644 --- a/chef-config/lib/chef-config/path_helper.rb +++ b/chef-config/lib/chef-config/path_helper.rb @@ -128,6 +128,17 @@ module ChefConfig abs_path end + # This is the INVERSE of Pathname#cleanpath, it converts forward + # slashes to backwhacks for Windows. Since the Ruby API and the + # Windows APIs all consume forward slashes, this helper function + # should only be used for *DISPLAY* logic to send strings back + # to the user with backwhacks. Internally, filename paths should + # generally be stored with forward slashes for consistency. It is + # not necessary or desired to blindly convert pathnames to have + # backwhacks on Windows. + # + # Generally, if the user isn't going to be seeing it, you should be + # using Pathname#cleanpath intead of this function. def self.cleanpath(path) path = Pathname.new(path).cleanpath.to_s # ensure all forward slashes are backslashes diff --git a/lib/chef/cookbook/syntax_check.rb b/lib/chef/cookbook/syntax_check.rb index fd7835db96..f8559433dc 100644 --- a/lib/chef/cookbook/syntax_check.rb +++ b/lib/chef/cookbook/syntax_check.rb @@ -114,7 +114,7 @@ class Chef end def ruby_files - path = Chef::Util::PathHelper.escape_glob(cookbook_path) + path = Chef::Util::PathHelper.escape_glob_dir(cookbook_path) files = Dir[File.join(path, "**", "*.rb")] files = remove_ignored_files(files) files = remove_uninteresting_ruby_files(files) @@ -133,7 +133,7 @@ class Chef end def template_files - remove_ignored_files Dir[File.join(Chef::Util::PathHelper.escape_glob(cookbook_path), "**/templates/**", "*.erb")] + remove_ignored_files Dir[File.join(Chef::Util::PathHelper.escape_glob_dir(cookbook_path), "**/templates/**", "*.erb")] end def untested_template_files diff --git a/lib/chef/cookbook_loader.rb b/lib/chef/cookbook_loader.rb index 9367936c32..72c878618e 100644 --- a/lib/chef/cookbook_loader.rb +++ b/lib/chef/cookbook_loader.rb @@ -179,7 +179,7 @@ class Chef @all_files_in_repo_paths ||= begin @repo_paths.inject([]) do |all_children, repo_path| - all_children += Dir[File.join(Chef::Util::PathHelper.escape_glob(repo_path), "*")] + all_children += Dir[File.join(Chef::Util::PathHelper.escape_glob_dir(repo_path), "*")] end end end diff --git a/lib/chef/deprecation/provider/file.rb b/lib/chef/deprecation/provider/file.rb index 4db9101d8d..edb0052fdf 100644 --- a/lib/chef/deprecation/provider/file.rb +++ b/lib/chef/deprecation/provider/file.rb @@ -181,7 +181,7 @@ class Chef # Clean up after the number of backups slice_number = @new_resource.backup - backup_files = Dir[Chef::Util::PathHelper.escape_glob(prefix, ".#{@new_resource.path}") + ".chef-*"].sort { |a, b| b <=> a } + backup_files = Dir[Chef::Util::PathHelper.escape_glob_dir(prefix, ".#{@new_resource.path}") + ".chef-*"].sort { |a, b| b <=> a } if backup_files.length >= @new_resource.backup remainder = backup_files.slice(slice_number..-1) remainder.each do |backup_to_delete| diff --git a/lib/chef/deprecation/provider/remote_directory.rb b/lib/chef/deprecation/provider/remote_directory.rb index 4e28fdc3fa..5e5188f28b 100644 --- a/lib/chef/deprecation/provider/remote_directory.rb +++ b/lib/chef/deprecation/provider/remote_directory.rb @@ -33,7 +33,7 @@ class Chef # List all excluding . and .. def ls(path) - files = Dir.glob(::File.join(Chef::Util::PathHelper.escape_glob(path), "**", "*"), + files = Dir.glob(::File.join(Chef::Util::PathHelper.escape_glob_dir(path), "**", "*"), ::File::FNM_DOTMATCH) # Remove current directory and previous directory diff --git a/lib/chef/file_cache.rb b/lib/chef/file_cache.rb index b4beee4a66..cefc9da1eb 100644 --- a/lib/chef/file_cache.rb +++ b/lib/chef/file_cache.rb @@ -158,9 +158,9 @@ class Chef # [String] - An array of file cache keys matching the glob def find(glob_pattern) keys = Array.new - Dir[File.join(Chef::Util::PathHelper.escape_glob(file_cache_path), glob_pattern)].each do |f| + Dir[File.join(Chef::Util::PathHelper.escape_glob_dir(file_cache_path), glob_pattern)].each do |f| if File.file?(f) - keys << f[/^#{Regexp.escape(Dir[Chef::Util::PathHelper.escape_glob(file_cache_path)].first) + File::Separator}(.+)/, 1] + keys << f[/^#{Regexp.escape(Dir[Chef::Util::PathHelper.escape_glob_dir(file_cache_path)].first) + File::Separator}(.+)/, 1] end end keys diff --git a/lib/chef/http/ssl_policies.rb b/lib/chef/http/ssl_policies.rb index 51db01c232..74c8093f98 100644 --- a/lib/chef/http/ssl_policies.rb +++ b/lib/chef/http/ssl_policies.rb @@ -77,7 +77,7 @@ class Chef http_client.cert_store.set_default_paths end if config.trusted_certs_dir - certs = Dir.glob(File.join(Chef::Util::PathHelper.escape_glob(config.trusted_certs_dir), "*.{crt,pem}")) + certs = Dir.glob(File.join(Chef::Util::PathHelper.escape_glob_dir(config.trusted_certs_dir), "*.{crt,pem}")) certs.each do |cert_file| cert = OpenSSL::X509::Certificate.new(File.read(cert_file)) add_trusted_cert(cert) diff --git a/lib/chef/knife/core/bootstrap_context.rb b/lib/chef/knife/core/bootstrap_context.rb index d96e07c03c..18cbe46232 100644 --- a/lib/chef/knife/core/bootstrap_context.rb +++ b/lib/chef/knife/core/bootstrap_context.rb @@ -199,7 +199,7 @@ CONFIG def trusted_certs_content content = "" if @chef_config[:trusted_certs_dir] - Dir.glob(File.join(Chef::Util::PathHelper.escape_glob(@chef_config[:trusted_certs_dir]), "*.{crt,pem}")).each do |cert| + Dir.glob(File.join(Chef::Util::PathHelper.escape_glob_dir(@chef_config[:trusted_certs_dir]), "*.{crt,pem}")).each do |cert| content << "cat > /etc/chef/trusted_certs/#{File.basename(cert)} <<'EOP'\n" + IO.read(File.expand_path(cert)) + "\nEOP\n" end diff --git a/lib/chef/knife/core/gem_glob_loader.rb b/lib/chef/knife/core/gem_glob_loader.rb index 78726feee7..f5eff26903 100644 --- a/lib/chef/knife/core/gem_glob_loader.rb +++ b/lib/chef/knife/core/gem_glob_loader.rb @@ -47,7 +47,7 @@ class Chef def find_subcommands_via_dirglob # The "require paths" of the core knife subcommands bundled with chef - files = Dir[File.join(Chef::Util::PathHelper.escape_glob(File.expand_path("../../../knife", __FILE__)), "*.rb")] + files = Dir[File.join(Chef::Util::PathHelper.escape_glob_dir(File.expand_path("../../../knife", __FILE__)), "*.rb")] subcommand_files = {} files.each do |knife_file| rel_path = knife_file[/#{CHEF_ROOT}#{Regexp.escape(File::SEPARATOR)}(.*)\.rb/, 1] @@ -82,7 +82,7 @@ class Chef if check_load_path files = $LOAD_PATH.map { |load_path| - Dir["#{File.expand_path glob, Chef::Util::PathHelper.escape_glob(load_path)}#{Gem.suffix_pattern}"] + Dir["#{File.expand_path glob, Chef::Util::PathHelper.escape_glob_dir(load_path)}#{Gem.suffix_pattern}"] }.flatten.select { |file| File.file? file.untaint } end @@ -116,7 +116,7 @@ class Chef spec.require_paths.first end - glob = File.join(Chef::Util::PathHelper.escape_glob(spec.full_gem_path, dirs), glob) + glob = File.join(Chef::Util::PathHelper.escape_glob_dir(spec.full_gem_path, dirs), glob) Dir[glob].map { |f| f.untaint } end diff --git a/lib/chef/knife/core/object_loader.rb b/lib/chef/knife/core/object_loader.rb index 04496933e4..b08483f9a2 100644 --- a/lib/chef/knife/core/object_loader.rb +++ b/lib/chef/knife/core/object_loader.rb @@ -71,14 +71,14 @@ class Chef # # @api public def find_all_objects(path) - path = File.join(Chef::Util::PathHelper.escape_glob(File.expand_path(path)), "*") + path = File.join(Chef::Util::PathHelper.escape_glob_dir(File.expand_path(path)), "*") path << ".{json,rb}" objects = Dir.glob(path) objects.map { |o| File.basename(o) } end def find_all_object_dirs(path) - path = File.join(Chef::Util::PathHelper.escape_glob(File.expand_path(path)), "*") + path = File.join(Chef::Util::PathHelper.escape_glob_dir(File.expand_path(path)), "*") objects = Dir.glob(path) objects.delete_if { |o| !File.directory?(o) } objects.map { |o| File.basename(o) } diff --git a/lib/chef/knife/core/subcommand_loader.rb b/lib/chef/knife/core/subcommand_loader.rb index 72329d8b95..0dcb54fc0d 100644 --- a/lib/chef/knife/core/subcommand_loader.rb +++ b/lib/chef/knife/core/subcommand_loader.rb @@ -139,7 +139,7 @@ class Chef # def find_subcommands_via_dirglob # The "require paths" of the core knife subcommands bundled with chef - files = Dir[File.join(Chef::Util::PathHelper.escape_glob(File.expand_path("../../../knife", __FILE__)), "*.rb")] + files = Dir[File.join(Chef::Util::PathHelper.escape_glob_dir(File.expand_path("../../../knife", __FILE__)), "*.rb")] subcommand_files = {} files.each do |knife_file| rel_path = knife_file[/#{CHEF_ROOT}#{Regexp.escape(File::SEPARATOR)}(.*)\.rb/, 1] @@ -197,12 +197,12 @@ Please use Chef::Knife::SubcommandLoader.for_config(chef_config_dir, env)" user_specific_files = [] if chef_config_dir - user_specific_files.concat Dir.glob(File.expand_path("plugins/knife/*.rb", Chef::Util::PathHelper.escape_glob(chef_config_dir))) + user_specific_files.concat Dir.glob(File.expand_path("plugins/knife/*.rb", Chef::Util::PathHelper.escape_glob_dir(chef_config_dir))) end # finally search ~/.chef/plugins/knife/*.rb Chef::Util::PathHelper.home(".chef", "plugins", "knife") do |p| - user_specific_files.concat Dir.glob(File.join(Chef::Util::PathHelper.escape_glob(p), "*.rb")) + user_specific_files.concat Dir.glob(File.join(Chef::Util::PathHelper.escape_glob_dir(p), "*.rb")) end user_specific_files diff --git a/lib/chef/knife/data_bag_from_file.rb b/lib/chef/knife/data_bag_from_file.rb index e029ec4b22..30b9de3386 100644 --- a/lib/chef/knife/data_bag_from_file.rb +++ b/lib/chef/knife/data_bag_from_file.rb @@ -102,7 +102,7 @@ class Chef paths = Array.new args.each do |path| if File.directory?(path) - paths.concat(Dir.glob(File.join(Chef::Util::PathHelper.escape_glob(path), "*.json"))) + paths.concat(Dir.glob(File.join(Chef::Util::PathHelper.escape_glob_dir(path), "*.json"))) else paths << path end diff --git a/lib/chef/provider/deploy.rb b/lib/chef/provider/deploy.rb index 7274ab2e8f..4c758033ac 100644 --- a/lib/chef/provider/deploy.rb +++ b/lib/chef/provider/deploy.rb @@ -242,7 +242,7 @@ class Chef end def all_releases - Dir.glob(Chef::Util::PathHelper.escape_glob(@new_resource.deploy_to) + "/releases/*").sort + Dir.glob(Chef::Util::PathHelper.escape_glob_dir(@new_resource.deploy_to) + "/releases/*").sort end def update_cached_repo diff --git a/lib/chef/provider/deploy/revision.rb b/lib/chef/provider/deploy/revision.rb index 9e2bb94f5b..f61e439486 100644 --- a/lib/chef/provider/deploy/revision.rb +++ b/lib/chef/provider/deploy/revision.rb @@ -44,7 +44,7 @@ class Chef known_releases = sorted_releases - Dir["#{Chef::Util::PathHelper.escape_glob(new_resource.deploy_to)}/releases/*"].each do |release_dir| + Dir["#{Chef::Util::PathHelper.escape_glob_dir(new_resource.deploy_to)}/releases/*"].each do |release_dir| unless known_releases.include?(release_dir) converge_by("Remove unknown release in #{release_dir}") do FileUtils.rm_rf(release_dir) @@ -87,7 +87,7 @@ class Chef end def sorted_releases_from_filesystem - Dir.glob(Chef::Util::PathHelper.escape_glob(new_resource.deploy_to) + "/releases/*").sort_by { |d| ::File.ctime(d) } + Dir.glob(Chef::Util::PathHelper.escape_glob_dir(new_resource.deploy_to) + "/releases/*").sort_by { |d| ::File.ctime(d) } end def load_cache diff --git a/lib/chef/provider/mount/mount.rb b/lib/chef/provider/mount/mount.rb index 265911b54c..c815c9ccb8 100644 --- a/lib/chef/provider/mount/mount.rb +++ b/lib/chef/provider/mount/mount.rb @@ -193,7 +193,7 @@ class Chef def device_should_exist? ( @new_resource.device != "none" ) && ( not network_device? ) && - ( not %w{ cgroup tmpfs fuse }.include? @new_resource.fstype ) + ( not %w{ cgroup tmpfs fuse vboxsf }.include? @new_resource.fstype ) end private diff --git a/lib/chef/provider/mount/windows.rb b/lib/chef/provider/mount/windows.rb index 3ffe326cac..0fb5aa7645 100644 --- a/lib/chef/provider/mount/windows.rb +++ b/lib/chef/provider/mount/windows.rb @@ -80,6 +80,12 @@ class Chef end end + private + + def mount_options_unchanged? + @current_resource.device == @new_resource.device + end + end end end diff --git a/lib/chef/provider/package/freebsd/pkg.rb b/lib/chef/provider/package/freebsd/pkg.rb index b42bd62c61..78d9449454 100644 --- a/lib/chef/provider/package/freebsd/pkg.rb +++ b/lib/chef/provider/package/freebsd/pkg.rb @@ -88,7 +88,7 @@ class Chef end def file_candidate_version_path - Dir[Chef::Util::PathHelper.escape_glob("#{@new_resource.source}/#{@current_resource.package_name}") + "*"][-1].to_s + Dir[Chef::Util::PathHelper.escape_glob_dir("#{@new_resource.source}/#{@current_resource.package_name}") + "*"][-1].to_s end def file_candidate_version diff --git a/lib/chef/provider/package/portage.rb b/lib/chef/provider/package/portage.rb index 7127fa723f..7c52e43bff 100644 --- a/lib/chef/provider/package/portage.rb +++ b/lib/chef/provider/package/portage.rb @@ -37,8 +37,8 @@ class Chef category, pkg = %r{^#{PACKAGE_NAME_PATTERN}$}.match(@new_resource.package_name)[1, 2] - globsafe_category = category ? Chef::Util::PathHelper.escape_glob(category) : nil - globsafe_pkg = Chef::Util::PathHelper.escape_glob(pkg) + globsafe_category = category ? Chef::Util::PathHelper.escape_glob_dir(category) : nil + globsafe_pkg = Chef::Util::PathHelper.escape_glob_dir(pkg) possibilities = Dir["/var/db/pkg/#{globsafe_category || "*"}/#{globsafe_pkg}-*"].map { |d| d.sub(%r{/var/db/pkg/}, "") } versions = possibilities.map do |entry| if entry =~ %r{[^/]+/#{Regexp.escape(pkg)}\-(\d[\.\d]*((_(alpha|beta|pre|rc|p)\d*)*)?(-r\d+)?)} diff --git a/lib/chef/provider/remote_directory.rb b/lib/chef/provider/remote_directory.rb index b592b13ccf..e3bc579107 100644 --- a/lib/chef/provider/remote_directory.rb +++ b/lib/chef/provider/remote_directory.rb @@ -104,7 +104,7 @@ class Chef # def purge_unmanaged_files if purge - Dir.glob(::File.join(Chef::Util::PathHelper.escape_glob(path), "**", "*"), ::File::FNM_DOTMATCH).sort!.reverse!.each do |file| + Dir.glob(::File.join(Chef::Util::PathHelper.escape_glob_dir(path), "**", "*"), ::File::FNM_DOTMATCH).sort!.reverse!.each do |file| # skip '.' and '..' next if [".", ".."].include?(Pathname.new(file).basename().to_s) diff --git a/lib/chef/provider/service/gentoo.rb b/lib/chef/provider/service/gentoo.rb index 66f2f10f23..56064bc03a 100644 --- a/lib/chef/provider/service/gentoo.rb +++ b/lib/chef/provider/service/gentoo.rb @@ -33,7 +33,7 @@ class Chef::Provider::Service::Gentoo < Chef::Provider::Service::Init super @current_resource.enabled( - Dir.glob("/etc/runlevels/**/#{Chef::Util::PathHelper.escape_glob(@current_resource.service_name)}").any? do |file| + Dir.glob("/etc/runlevels/**/#{Chef::Util::PathHelper.escape_glob_dir(@current_resource.service_name)}").any? do |file| @found_script = true exists = ::File.exists? file readable = ::File.readable? file diff --git a/lib/chef/provider/service/insserv.rb b/lib/chef/provider/service/insserv.rb index 7f92ef1eb4..76b2ee7477 100644 --- a/lib/chef/provider/service/insserv.rb +++ b/lib/chef/provider/service/insserv.rb @@ -36,7 +36,7 @@ class Chef super # Look for a /etc/rc.*/SnnSERVICE link to signify that the service would be started in a runlevel - if Dir.glob("/etc/rc**/S*#{Chef::Util::PathHelper.escape_glob(current_resource.service_name)}").empty? + if Dir.glob("/etc/rc**/S*#{Chef::Util::PathHelper.escape_glob_dir(current_resource.service_name)}").empty? current_resource.enabled false else current_resource.enabled true diff --git a/lib/chef/provider/service/macosx.rb b/lib/chef/provider/service/macosx.rb index 63485903c3..e6e57e4695 100644 --- a/lib/chef/provider/service/macosx.rb +++ b/lib/chef/provider/service/macosx.rb @@ -236,7 +236,7 @@ class Chef plists = PLIST_DIRS.inject([]) do |results, dir| edir = ::File.expand_path(dir) entries = Dir.glob( - "#{edir}/*#{Chef::Util::PathHelper.escape_glob(@current_resource.service_name)}*.plist" + "#{edir}/*#{Chef::Util::PathHelper.escape_glob_dir(@current_resource.service_name)}*.plist" ) entries.any? ? results << entries : results end diff --git a/lib/chef/provider/user/dscl.rb b/lib/chef/provider/user/dscl.rb index fecfb73e2d..e933bf9dc0 100644 --- a/lib/chef/provider/user/dscl.rb +++ b/lib/chef/provider/user/dscl.rb @@ -331,7 +331,7 @@ user password using shadow hash.") src = current_resource.home FileUtils.mkdir_p(new_resource.home) - files = ::Dir.glob("#{Chef::Util::PathHelper.escape_glob(src)}/*", ::File::FNM_DOTMATCH) - ["#{src}/.", "#{src}/.."] + files = ::Dir.glob("#{Chef::Util::PathHelper.escape_glob_dir(src)}/*", ::File::FNM_DOTMATCH) - ["#{src}/.", "#{src}/.."] ::FileUtils.mv(files, new_resource.home, :force => true) ::FileUtils.rmdir(src) ::FileUtils.chown_R(new_resource.username, new_resource.gid.to_s, new_resource.home) diff --git a/lib/chef/role.rb b/lib/chef/role.rb index ed22bc87e4..9b6fa1c59d 100644 --- a/lib/chef/role.rb +++ b/lib/chef/role.rb @@ -253,7 +253,7 @@ class Chef def self.from_disk(name) paths = Array(Chef::Config[:role_path]) paths.each do |path| - roles_files = Dir.glob(File.join(Chef::Util::PathHelper.escape_glob(path), "**", "**")) + roles_files = Dir.glob(File.join(Chef::Util::PathHelper.escape_glob_dir(path), "**", "**")) js_files = roles_files.select { |file| file.match(/\/#{name}\.json$/) } rb_files = roles_files.select { |file| file.match(/\/#{name}\.rb$/) } if js_files.count > 1 or rb_files.count > 1 diff --git a/spec/functional/util/path_helper_spec.rb b/spec/functional/util/path_helper_spec.rb index f1a953ebad..fd484adff2 100644 --- a/spec/functional/util/path_helper_spec.rb +++ b/spec/functional/util/path_helper_spec.rb @@ -30,7 +30,7 @@ describe Chef::Util::PathHelper, "escape_glob" do File.new(File.join(dir, file), "w").close end - pattern = File.join(PathHelper.escape_glob(dir), "*") + pattern = File.join(PathHelper.escape_glob_dir(dir), "*") expect(Dir.glob(pattern).map { |x| File.basename(x) }).to match_array(files) end end diff --git a/spec/unit/provider/mount/windows_spec.rb b/spec/unit/provider/mount/windows_spec.rb index ab7a161c08..ec1945de50 100644 --- a/spec/unit/provider/mount/windows_spec.rb +++ b/spec/unit/provider/mount/windows_spec.rb @@ -120,6 +120,18 @@ describe Chef::Provider::Mount::Windows do @provider.mount_fs end + context "mount_options_unchanged?" do + it "should return true if mounted device is the same" do + allow(@current_resource).to receive(:device).and_return(GUID) + expect(@provider.send :mount_options_unchanged?).to be true + end + + it "should return false if mounted device has changed" do + allow(@current_resource).to receive(:device).and_return("XXXX") + expect(@provider.send :mount_options_unchanged?).to be false + end + end + it "should not mount the filesystem if it is mounted and the options have not changed" do expect(@vol).to_not receive(:add) allow(@current_resource).to receive(:mounted).and_return(true) |