rails_pwnerer 0.5.4 → 0.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +2 -0
- data/lib/pwnage/app/cluster_config.rb +2 -1
- data/lib/pwnage/app/config.rb +1 -1
- data/lib/pwnage/app/database.rb +22 -0
- data/lib/pwnage/scaffolds/mysql_config.rb +1 -1
- data/lib/pwnage/scaffolds/packages.rb +3 -0
- data/rails_pwnerer.gemspec +2 -2
- metadata +1 -1
data/CHANGELOG
CHANGED
@@ -111,7 +111,8 @@ class RailsPwnage::App::ClusterConfig
|
|
111
111
|
# alloc a port if somehow that slipped through the cracks
|
112
112
|
if app_config[:port0] == 0
|
113
113
|
manage_ports app_name, instance_name, :alloc
|
114
|
-
configure_mongrels app_name, instance_name
|
114
|
+
configure_mongrels app_name, instance_name
|
115
|
+
RailsPwnage::App::NginxConfig.new app_name, instance_name
|
115
116
|
end
|
116
117
|
|
117
118
|
Dir.chdir app_config[:app_path] do
|
data/lib/pwnage/app/config.rb
CHANGED
@@ -28,7 +28,7 @@ class RailsPwnage::App::Config
|
|
28
28
|
# the datbase user for the given application
|
29
29
|
app_db[:db_user] = (app_name + '_' + instance_name)[0...16] # mySQL doesn't like long user names
|
30
30
|
# the password of the database user for the given application
|
31
|
-
app_db[:db_pass] =
|
31
|
+
app_db[:db_pass] = (0...16).map { |i| "0123456789abcdef"[rand(16),1]}.join
|
32
32
|
# a DNS name for server-based filtering (multiple apps on the same box)
|
33
33
|
app_db[:dns_name] = ''
|
34
34
|
# the maximum request size (megabytes) to be accepted by an application
|
data/lib/pwnage/app/database.rb
CHANGED
@@ -38,6 +38,27 @@ ENDSQL
|
|
38
38
|
File.delete('admin_db.sql')
|
39
39
|
end
|
40
40
|
end
|
41
|
+
|
42
|
+
def mysql_host_info()
|
43
|
+
# try UNIX sockets first, for best performance
|
44
|
+
begin
|
45
|
+
socket_line = `mysql_config --socket`
|
46
|
+
socket_line.strip!
|
47
|
+
return {'socket' => socket_line} unless socket_line.empty?
|
48
|
+
rescue
|
49
|
+
end
|
50
|
+
|
51
|
+
# oh well, TCP will have to suffice
|
52
|
+
begin
|
53
|
+
port_line = `mysql_config --port`
|
54
|
+
port = port_line.strip.to_i
|
55
|
+
return {'host' => 'localhost', 'port' => port} unless port == 0
|
56
|
+
rescue
|
57
|
+
end
|
58
|
+
|
59
|
+
# giving up, the mysql gem will have to figure it out
|
60
|
+
return {}
|
61
|
+
end
|
41
62
|
|
42
63
|
# configures rails to use the database in the production environment
|
43
64
|
def configure_rails(app_name, instance_name)
|
@@ -47,6 +68,7 @@ ENDSQL
|
|
47
68
|
config_file = File.join app_config[:app_path], 'config', 'database.yml'
|
48
69
|
configuration = File.open(config_file, 'r') { |f| YAML.load f }
|
49
70
|
configuration['production'].merge! 'adapter' => 'mysql', 'database' => db_name, 'username' => db_user, 'password' => db_pass
|
71
|
+
configuration['production'].merge! mysql_host_info()
|
50
72
|
File.open(config_file, 'w') { |f| YAML.dump(configuration, f) }
|
51
73
|
|
52
74
|
# bonus: lock down the database so only the right user can access it
|
@@ -25,6 +25,9 @@ class RailsPwnage::Scaffolds::Packages
|
|
25
25
|
|
26
26
|
# needed by sqlite-3 ruby gem in tools
|
27
27
|
install_packages %w(libsqlite3-0 libsqlite3-dev sqlite3), :source => true
|
28
|
+
|
29
|
+
# useful to be able to work with compressed data
|
30
|
+
install_packages %w(tar zip bzip2 gzip)
|
28
31
|
end
|
29
32
|
|
30
33
|
# the packages comprising ruby
|
data/rails_pwnerer.gemspec
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
|
2
|
-
# Gem::Specification for Rails_pwnerer-0.5.
|
2
|
+
# Gem::Specification for Rails_pwnerer-0.5.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.5.
|
8
|
+
version: 0.5.5
|
9
9
|
platform: ruby
|
10
10
|
authors:
|
11
11
|
- Victor Costan
|