FiXato-ubuntu-machine 0.5.3.2.10 → 0.5.3.2.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -41,9 +41,12 @@ end
41
41
 
42
42
  def sudo_add_to_file(file,lines)
43
43
  tmpfile = "#{File.basename(file)}.tmp"
44
- run "cp #{file} #{tmpfile}"
44
+ sudo "cp #{file} #{tmpfile}"
45
+ # Temporarily make world read/writable so it can be appended to.
46
+ sudo "chmod 0777 #{tmpfile} && sudo chown #{user}:#{user} #{tmpfile}"
45
47
  add_to_file(tmpfile,lines)
46
- sudo "mv #{tmpfile} #{file}"
48
+ # Use cp + rm instead mv so the destination file will keep its owner/modes.
49
+ sudo "cp #{tmpfile} #{file} && rm #{tmpfile}"
47
50
  end
48
51
 
49
52
  # Re-activate sudo session if it has expired.
@@ -56,7 +59,7 @@ end
56
59
  # - period should be a valid crontab period
57
60
  # - use_sudo can be set to true if you want to edit the root crontab.
58
61
  def add_to_crontab(commands,period,use_sudo=false)
59
- send_cmd = use_sudo ? :run : :sudo
62
+ send_cmd = use_sudo ? :sudo : :run
60
63
  tmp_cron="/tmp/cron.tmp"
61
64
  cron_lines = [*commands].map{|cmd| "#{period} #{cmd}"}
62
65
  self.send(send_cmd, "rm -f #{tmp_cron} && crontab -l || true > #{tmp_cron}")
@@ -1,5 +1,7 @@
1
1
  namespace :ssh do
2
2
  _cset :ssh_secundary_keys, []
3
+ _cset(:ssh_config_port) {ssh_options[:port] || 22}
4
+
3
5
  desc <<-DESC
4
6
  Setup SSH on the gateway host. Runs `upload_keys`, `install_ovh_ssh_key` AND \
5
7
  `configure_sshd` then reloads the SSH service to finalize the changes.
@@ -2,7 +2,7 @@
2
2
  # See the sshd(8) manpage for details
3
3
 
4
4
  # What ports, IPs and protocols we listen for
5
- Port <%= ssh_options[:port] %>
5
+ Port <%= ssh_config_port %>
6
6
  # Use these options to restrict which interfaces/protocols sshd will bind to
7
7
  #ListenAddress ::
8
8
  #ListenAddress 0.0.0.0
@@ -77,4 +77,4 @@ Subsystem sftp /usr/lib/openssh/sftp-server
77
77
 
78
78
  UseDNS no
79
79
 
80
- AllowUsers <%= user %>
80
+ AllowUsers root <%= user %>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: FiXato-ubuntu-machine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3.2.10
4
+ version: 0.5.3.2.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Balthazar