Skip to content

Commit 1b85117

Browse files
author
Sean OMeara
committed
Fixing bug where unprivileged users cannot connect over a local socket. Adding integration test.
Fixing bug in mysql_grants_cmd generation
1 parent a8b6a63 commit 1b85117

File tree

5 files changed

+12
-5
lines changed

5 files changed

+12
-5
lines changed

libraries/helpers.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def assign_root_password_cmd
3838
def install_grants_cmd
3939
str = '/usr/bin/mysql'
4040
str << ' -u root '
41-
node['mysql']['server_root_password'].empty? ? str << ' < /etc/mysql_grants.sql' : str << " -p#{node['mysql']['server_root_password']}"
41+
node['mysql']['server_root_password'].empty? ? str << ' < /etc/mysql_grants.sql' : str << " -p#{node['mysql']['server_root_password']} < /etc/mysql_grants.sql"
4242
end
4343
end
4444
end

recipes/_server_debian.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,11 @@
3131
end
3232

3333
node['mysql']['server']['directories'].each do |key, value|
34-
log "DEBUG: #{value}"
3534
directory value do
3635
owner 'mysql'
3736
group 'mysql'
38-
mode '0770'
37+
mode '0775'
3938
action :create
40-
recursive true
4139
end
4240
end
4341

recipes/_server_rhel.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
directory value do
1212
owner 'mysql'
1313
group 'mysql'
14+
mode '0775'
1415
action :create
15-
recursive true
1616
end
1717
end
1818

test/cookbooks/mysql_test/recipes/server.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,7 @@
3636
EOF}
3737
not_if "echo 'SELECT count(name) FROM tv_chef' | mysql #{mysql_conn_args} --skip-column-names #{node['mysql_test']['database']} | grep '^3$'"
3838
end
39+
40+
user "unprivileged" do
41+
action :create
42+
end

test/integration/server/serverspec/localhost/server_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,8 @@
55
expect(port 3306).to be_listening
66
end
77
end
8+
9+
10+
describe command("su -s /bin/sh -c \"mysql --protocol socket -uroot -pilikerandompasswords -e 'show databases;'\" unprivileged") do
11+
it { should return_exit_status 0 }
12+
end

0 commit comments

Comments
 (0)