Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use sudo rather than su for init scripts #369

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .kitchen.dokken.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ transport:
provisioner:
name: dokken

# TODO: uncomment after converting to inspec
# verifier:
# name: inspec
verifier:
root_path: '/opt/verifier'
# TODO: uncomment after converting to inspec
# name: inspec

platforms:
- name: amazonlinux
Expand Down
3 changes: 2 additions & 1 deletion templates/default/redis.init.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ REDISNAME=<%= @name %>
REDISPORT=<%= @port %>
<% case @platform %>
<% when 'ubuntu','debian','fedora' %>
EXEC="su -s /bin/sh -c '<%= File.join(@bin_path, 'redis-server') %> <%= @configdir %>/${REDISNAME}.conf' <%= @user %>"
# EXEC="su -s /bin/sh -c '<%= File.join(@bin_path, 'redis-server') %> <%= @configdir %>/${REDISNAME}.conf' <%= @user %>"
EXEC="SHELL=/bin/sh sudo -s '<%= File.join(@bin_path, 'redis-server') %> <%= @configdir %>/${REDISNAME}.conf' <%= @user %>"
<% else %>
EXEC="runuser <%= @user %> -c \"<%= File.join(@bin_path, 'redis-server') %> <%= @configdir %>/${REDISNAME}.conf\""
<% end %>
Expand Down
3 changes: 2 additions & 1 deletion templates/default/redis.upstart.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ end script
respawn
respawn limit 10 30

exec su -s /bin/sh -c 'exec "$0" "$@"' <%= @user %> <%= File.join(@bin_path, 'redis-server') %> <%= @configdir %>/<%= @name %>.conf
# exec su -s /bin/sh -c 'exec "$0" "$@"' <%= @user %> <%= File.join(@bin_path, 'redis-server') %> <%= @configdir %>/<%= @name %>.conf
exec SHELL=/bin/sh sudo -s 'exec "$0" "$@"' <%= @user %> <%= File.join(@bin_path, 'redis-server') %> <%= @configdir %>/<%= @name %>.conf

3 changes: 2 additions & 1 deletion templates/default/sentinel.init.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
SENTINELNAME=<%= @name %>
<% case @platform %>
<% when 'ubuntu','debian','fedora' %>
EXEC="su -s /bin/sh -c '<%= File.join(@bin_path, 'redis-server') %> <%= @configdir %>/${SENTINELNAME}.conf --sentinel' <%= @user %>"
# EXEC="su -s /bin/sh -c '<%= File.join(@bin_path, 'redis-server') %> <%= @configdir %>/${SENTINELNAME}.conf --sentinel' <%= @user %>"
EXEC="SHELL=/bin/sh sudo -s '<%= File.join(@bin_path, 'redis-server') %> <%= @configdir %>/${SENTINELNAME}.conf --sentinel' <%= @user %>"
<% else %>
EXEC="runuser <%= @user %> -c \"<%= File.join(@bin_path, 'redis-server') %> <%= @configdir %>/${SENTINELNAME}.conf --sentinel\""
<% end %>
Expand Down
3 changes: 2 additions & 1 deletion templates/default/sentinel.upstart.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ end script
respawn
respawn limit 10 30

exec su -s /bin/sh -c 'exec "$0" "$@"' -- <%= @user %> <%= File.join(@bin_path, 'redis-server') %> <%= @configdir %>/<%= @name %>.conf --sentinel
# exec su -s /bin/sh -c 'exec "$0" "$@"' -- <%= @user %> <%= File.join(@bin_path, 'redis-server') %> <%= @configdir %>/<%= @name %>.conf --sentinel
exec SHELL=/bin/sh sudo -s 'exec "$0" "$@"' -- <%= @user %> <%= File.join(@bin_path, 'redis-server') %> <%= @configdir %>/<%= @name %>.conf --sentinel