Skip to content

Commit fcaea76

Browse files
Kevin Reeuwijkglennsarti
authored andcommitted
(MODULES-6356) Fixes a problem still remaining from MODULES-2904
As described in MODULES-2904, installation fails with an array of SQL Admins. This was fixed in the use_discrete=true block (line 171-178. However the double quotes also needed to be removed from the list of accounts for the /SQLSYSADMINACCOUNTS switch parameter. This appears to be due to the arguments being interpretted literally, including the double quotes when doing account lookups. Without the fix, the only setting that works is /SQLSYSADMINACCOUNTS="BUILTIN\Administrators", all other settings (both local and domain accounts/groups) will fail, particularly those with whitespace.
1 parent a044ce1 commit fcaea76

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

lib/puppet/provider/sqlserver_instance/mssql.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,9 @@ def format_cmd_args_array(switch, arr, cmd_args, use_discrete = false)
171171
if use_discrete
172172
arr.map.with_index { |var,i|
173173
if i == 0
174-
cmd_args << "#{switch}=\"#{var}\""
174+
cmd_args << "#{switch}=#{var}"
175175
else
176-
cmd_args << "\"#{var}\""
176+
cmd_args << "#{var}"
177177
end
178178
}
179179
else

spec/acceptance/sqlserver_instance_spec.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ def sql_query_is_user_sysadmin(username)
6060
context "Create an instance", {:testrail => ['88978', '89028', '89031', '89043', '89061']} do
6161

6262
before(:context) do
63-
@ExtraAdminUser = 'ExtraSQLAdmin'
63+
# Use a username with a space to test argument parsing works correctly
64+
@ExtraAdminUser = 'Extra SQLAdmin'
6465
pp = <<-MANIFEST
6566
user { '#{@ExtraAdminUser}':
6667
ensure => present,
@@ -83,7 +84,8 @@ def sql_query_is_user_sysadmin(username)
8384
features = ['SQLEngine', 'Replication', 'FullText', 'DQ']
8485

8586
it "create #{inst_name} instance", :tier_high => true do
86-
ensure_sqlserver_instance(features, inst_name,'present',"['Administrator','ExtraSQLAdmin']")
87+
host_computer_name = on(host, 'CMD /C ECHO %COMPUTERNAME%').stdout.chomp
88+
ensure_sqlserver_instance(features, inst_name,'present',"['Administrator','#{host_computer_name}\\#{@ExtraAdminUser}']")
8789

8890
validate_sql_install(host, {:version => version}) do |r|
8991
expect(r.stdout).to match(/#{Regexp.new(inst_name)}/)
@@ -95,7 +97,7 @@ def sql_query_is_user_sysadmin(username)
9597
end
9698

9799
it "#{inst_name} instance has ExtraSQLAdmin as a sysadmin", :tier_low => true do
98-
run_sql_query(host, run_sql_query_opts(inst_name, sql_query_is_user_sysadmin('ExtraSQLAdmin'), expected_row_count = 1))
100+
run_sql_query(host, run_sql_query_opts(inst_name, sql_query_is_user_sysadmin(@ExtraAdminUser), expected_row_count = 1))
99101
end
100102

101103
it "remove #{inst_name} instance", :tier_high => true do

spec/unit/puppet/provider/sqlserver_instance_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ def stub_uninstall(args, installed_features, exit_code = 0)
6060
cmd_args << "/SECURITYMODE=SQL"
6161
end
6262

63-
# wrap each arg in doublequotes
64-
admin_args = execute_args[:sql_sysadmin_accounts].map { |a| "\"#{a}\"" }
63+
# Extrace the SQL Sysadmins
64+
admin_args = execute_args[:sql_sysadmin_accounts].map { |a| "#{a}" }
6565
# prepend first arg only with CLI switch
6666
admin_args[0] = "/SQLSYSADMINACCOUNTS=" + admin_args[0]
6767
cmd_args += admin_args

0 commit comments

Comments
 (0)