bluepill 0.0.39 → 0.0.40

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.39
1
+ 0.0.40
data/bin/bluepill CHANGED
@@ -2,17 +2,11 @@
2
2
  require 'optparse'
3
3
  require 'bluepill'
4
4
 
5
- # Check for root
6
- unless ::Process.euid == 0
7
- $stderr.puts "You must run bluepill as root."
8
- exit(3)
9
- end
10
-
11
-
12
5
  # Default options
13
6
  options = {
14
- :log_file => "/var/log/bluepill.log",
15
- :base_dir => "/var/bluepill"
7
+ :log_file => "/var/log/bluepill.log",
8
+ :base_dir => "/var/bluepill",
9
+ :privileged => true
16
10
  }
17
11
 
18
12
  OptionParser.new do |opts|
@@ -30,6 +24,10 @@ OptionParser.new do |opts|
30
24
  exit
31
25
  end
32
26
 
27
+ opts.on("--[no-]privileged", "Allow/disallow to run #{$0} as non-privileged process. disallowed by default") do |v|
28
+ options[:privileged] = v
29
+ end
30
+
33
31
  help = lambda do
34
32
  puts opts
35
33
  puts
@@ -51,6 +49,12 @@ OptionParser.new do |opts|
51
49
  help.call if ARGV.empty?
52
50
  end.parse!
53
51
 
52
+ # Check for root
53
+ if options[:privileged] && ::Process.euid != 0
54
+ $stderr.puts "You must run bluepill as root or use --no-privileged option."
55
+ exit(3)
56
+ end
57
+
54
58
  APPLICATION_COMMANDS = %w(status start stop restart unmonitor quit log)
55
59
 
56
60
  controller = Bluepill::Controller.new(options.slice(:base_dir, :log_file))
@@ -100,4 +104,4 @@ if options[:command] == "load"
100
104
  else
101
105
  target = ARGV.shift
102
106
  controller.handle_command(options[:application], options[:command], target)
103
- end
107
+ end
data/bluepill.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{bluepill}
8
- s.version = "0.0.39"
8
+ s.version = "0.0.40"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Arya Asemanfar", "Gary Tsang", "Rohith Ravi"]
12
- s.date = %q{2010-08-02}
12
+ s.date = %q{2010-08-21}
13
13
  s.default_executable = %q{bluepill}
14
14
  s.description = %q{Bluepill keeps your daemons up while taking up as little resources as possible. After all you probably want the resources of your server to be used by whatever daemons you are running rather than the thing that's supposed to make sure they are brought back up, should they die or misbehave.}
15
15
  s.email = %q{entombedvirus@gmail.com}
@@ -171,23 +171,25 @@ module Bluepill
171
171
  def kill_previous_bluepill
172
172
  if File.exists?(self.pid_file)
173
173
  previous_pid = File.read(self.pid_file).to_i
174
- begin
175
- ::Process.kill(0, previous_pid)
176
- puts "Killing previous bluepilld[#{previous_pid}]"
177
- ::Process.kill(2, previous_pid)
178
- rescue Exception => e
179
- $stderr.puts "Encountered error trying to kill previous bluepill:"
180
- $stderr.puts "#{e.class}: #{e.message}"
181
- exit(4) unless e.is_a?(Errno::ESRCH)
182
- else
183
- 10.times do |i|
184
- sleep 0.5
185
- break unless System.pid_alive?(previous_pid)
186
- end
187
-
188
- if System.pid_alive?(previous_pid)
189
- $stderr.puts "Previous bluepilld[#{previous_pid}] didn't die"
190
- exit(4)
174
+ if System.pid_alive?(previous_pid)
175
+ begin
176
+ ::Process.kill(0, previous_pid)
177
+ puts "Killing previous bluepilld[#{previous_pid}]"
178
+ ::Process.kill(2, previous_pid)
179
+ rescue Exception => e
180
+ $stderr.puts "Encountered error trying to kill previous bluepill:"
181
+ $stderr.puts "#{e.class}: #{e.message}"
182
+ exit(4) unless e.is_a?(Errno::ESRCH)
183
+ else
184
+ 10.times do |i|
185
+ sleep 0.5
186
+ break unless System.pid_alive?(previous_pid)
187
+ end
188
+
189
+ if System.pid_alive?(previous_pid)
190
+ $stderr.puts "Previous bluepilld[#{previous_pid}] didn't die"
191
+ exit(4)
192
+ end
191
193
  end
192
194
  end
193
195
  end
@@ -192,12 +192,14 @@ module Bluepill
192
192
  # be sure to call this from a fork otherwise it will modify the attributes
193
193
  # of the bluepill daemon
194
194
  def drop_privileges(uid, gid)
195
- uid_num = Etc.getpwnam(uid).uid if uid
196
- gid_num = Etc.getgrnam(gid).gid if gid
195
+ if ::Process::Sys.geteuid == 0
196
+ uid_num = Etc.getpwnam(uid).uid if uid
197
+ gid_num = Etc.getgrnam(gid).gid if gid
197
198
 
198
- ::Process.groups = [gid_num] if gid
199
- ::Process::Sys.setgid(gid_num) if gid
200
- ::Process::Sys.setuid(uid_num) if uid
199
+ ::Process.groups = [gid_num] if gid
200
+ ::Process::Sys.setgid(gid_num) if gid
201
+ ::Process::Sys.setuid(uid_num) if uid
202
+ end
201
203
  end
202
204
 
203
205
  def can_write_pid_file(pid_file, logger)
@@ -1,3 +1,3 @@
1
1
  module Bluepill
2
- VERSION = "0.0.39"
2
+ VERSION = "0.0.40"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bluepill
3
3
  version: !ruby/object:Gem::Version
4
- hash: 81
4
+ hash: 79
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 39
10
- version: 0.0.39
9
+ - 40
10
+ version: 0.0.40
11
11
  platform: ruby
12
12
  authors:
13
13
  - Arya Asemanfar
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2010-08-02 00:00:00 -07:00
20
+ date: 2010-08-21 00:00:00 -07:00
21
21
  default_executable: bluepill
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency