rails_pwnerer 0.6.4 → 0.6.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +2 -0
- data/lib/pwnage/app/config.rb +7 -9
- data/lib/pwnage/util/kill_process_set.rb +19 -9
- data/rails_pwnerer.gemspec +3 -3
- metadata +2 -2
data/CHANGELOG
CHANGED
data/lib/pwnage/app/config.rb
CHANGED
@@ -8,11 +8,13 @@ class RailsPwnage::App::Config
|
|
8
8
|
# setup: this effectively creates the baseline configuration db
|
9
9
|
# update: this adds keys that might have been added in new versions of rpwn
|
10
10
|
def populate_defaults(app_name, instance_name, app_db)
|
11
|
+
# the path to application main files
|
12
|
+
app_db[:app_path] = File.join(RailsPwnage::Config.path_to(:apps), app_name + '.' + instance_name)
|
11
13
|
# the path to application backups
|
12
14
|
app_db[:backup_path] ||= File.join(RailsPwnage::Config.path_to(:backups), app_name + '.' + instance_name)
|
13
15
|
|
14
16
|
# the user which will receive the "keys" to the production system
|
15
|
-
app_db[:pwnerer_user] ||=
|
17
|
+
app_db[:pwnerer_user] ||= RailsPwnage::Config[:host][:pwnerer_user]
|
16
18
|
# the number of frontends for the application instance
|
17
19
|
app_db[:frontends] ||= 4
|
18
20
|
# the first internal port for the application instance
|
@@ -39,25 +41,21 @@ class RailsPwnage::App::Config
|
|
39
41
|
|
40
42
|
# allocates room for the application and creates the application configuration database
|
41
43
|
def alloc(app_name, instance_name)
|
42
|
-
app_path = File.join(RailsPwnage::Config.path_to(:apps), app_name + '.' + instance_name)
|
43
|
-
FileUtils.mkpath app_path
|
44
|
-
|
45
44
|
app_db_name = RailsPwnage::Config.app_db_name(app_name, instance_name)
|
46
45
|
app_db = RailsPwnage::Config.create_db app_db_name
|
47
|
-
|
48
|
-
# default settings
|
49
|
-
app_db[:app_path] = app_path
|
50
46
|
populate_defaults app_name, instance_name, app_db
|
47
|
+
|
48
|
+
FileUtils.mkpath app_db[:app_path]
|
51
49
|
|
52
50
|
RailsPwnage::Config.flush_db app_db
|
53
|
-
return app_path
|
51
|
+
return app_db[:app_path]
|
54
52
|
end
|
55
53
|
|
56
54
|
# pushes config changes from the application file to the database
|
57
55
|
def update(app_name, instance_name)
|
58
56
|
app_config = RailsPwnage::Config[app_name, instance_name]
|
59
57
|
app_config.clear
|
60
|
-
populate_defaults app_name, instance_name,
|
58
|
+
populate_defaults app_name, instance_name, app_config
|
61
59
|
Dir.chdir app_config[:app_path] do
|
62
60
|
["config/rails_pwnerer/.yml", "config/rails_pwnerer/#{instance_name}.yml"].each do |fname|
|
63
61
|
next unless File.exists? fname
|
@@ -11,10 +11,20 @@ module RailsPwnage::Util
|
|
11
11
|
# Phase 1: kill order (only if there's a PID file)
|
12
12
|
pid_patterns = [pid_patterns] unless pid_patterns.kind_of? Enumerable
|
13
13
|
unless options[:force_script]
|
14
|
-
pid_files = pid_patterns.map { |pattern| Dir.glob(pattern) }.flatten
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
pid_files = pid_patterns.map { |pattern| Dir.glob(pattern) }.flatten
|
15
|
+
end
|
16
|
+
if options[:force_script] or !(pid_files.empty? or kill_script.nil?)
|
17
|
+
print "Issuing kill order: #{kill_script}\n" if options[:verbose]
|
18
|
+
success = Kernel.system kill_script unless kill_script.nil?
|
19
|
+
if !success and options[:verbose]
|
20
|
+
print "Kill order failed with exit code #{$CHILD_STATUS.exitstatus}\n"
|
21
|
+
end
|
22
|
+
|
23
|
+
deadline_time = Time.now + (options[:script_delay] || 0.5)
|
24
|
+
while Time.now < deadline_time
|
25
|
+
pid_files = pid_patterns.map { |pattern| Dir.glob(pattern) }.flatten
|
26
|
+
break if pid_files.empty?
|
27
|
+
sleep 0.05
|
18
28
|
end
|
19
29
|
end
|
20
30
|
|
@@ -27,14 +37,14 @@ module RailsPwnage::Util
|
|
27
37
|
process_cmdline = pinfo[pid][:cmdline]
|
28
38
|
# avoid killing innocent victims
|
29
39
|
if pinfo[pid].nil? or process_patterns.all? { |pattern| process_cmdline.index pattern }
|
30
|
-
print "Killing #{pid}: #{process_cmdline}\n"
|
40
|
+
print "Killing #{pid}: #{process_cmdline}\n" if options[:verbose]
|
31
41
|
Process.kill 'TERM', pid.to_i
|
32
42
|
end
|
33
43
|
rescue
|
34
44
|
# just in case the file gets wiped before we see it
|
35
45
|
end
|
36
46
|
begin
|
37
|
-
print "Deleting #{fname}\n"
|
47
|
+
print "Deleting #{fname}\n" if options[:verbose]
|
38
48
|
File.delete fname if File.exists? fname
|
39
49
|
rescue
|
40
50
|
# prevents crashing if the file is wiped after we call exists?
|
@@ -45,8 +55,8 @@ module RailsPwnage::Util
|
|
45
55
|
pinfo = process_info()
|
46
56
|
pinfo.each do |pid, info|
|
47
57
|
next unless process_patterns.all? { |pattern| info[:cmdline].index pattern }
|
48
|
-
print "Killing #{pid}: #{pinfo[pid][:cmdline]}\n"
|
58
|
+
print "Killing #{pid}: #{pinfo[pid][:cmdline]}\n" if options[:verbose]
|
49
59
|
Process.kill 'TERM', pid.to_i
|
50
60
|
end
|
51
|
-
end
|
52
|
-
end
|
61
|
+
end
|
62
|
+
end
|
data/rails_pwnerer.gemspec
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
|
2
|
-
# Gem::Specification for Rails_pwnerer-0.6.
|
2
|
+
# Gem::Specification for Rails_pwnerer-0.6.5
|
3
3
|
# Originally generated by Echoe
|
4
4
|
|
5
5
|
--- !ruby/object:Gem::Specification
|
6
6
|
name: rails_pwnerer
|
7
7
|
version: !ruby/object:Gem::Version
|
8
|
-
version: 0.6.
|
8
|
+
version: 0.6.5
|
9
9
|
platform: ruby
|
10
10
|
authors:
|
11
11
|
- Victor Costan
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
|
15
|
-
date: 2008-09-
|
15
|
+
date: 2008-09-21 00:00:00 -04:00
|
16
16
|
default_executable:
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_pwnerer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Costan
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-09-
|
12
|
+
date: 2008-09-21 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|