rails_pwnerer 0.5.4 → 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,5 @@
1
+ v0.5.5. Stronger database passwords, better mySQL configuration.
2
+
1
3
  v0.5.4. Bugfix release: the manifest was busted in 0.5.3.
2
4
 
3
5
  v0.5.3. Better control of mongrels using the process table and configuration database.
@@ -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
@@ -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] = instance_name # TODO: use random number generator here instead
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
@@ -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
@@ -5,7 +5,7 @@ class RailsPwnage::Scaffolds::MysqlConfig
5
5
 
6
6
  # runner
7
7
  def run
8
- Kernel.system 'ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock'
8
+ # nothing to do anymore, used to configure socket
9
9
  end
10
10
 
11
11
  # standalone runner
@@ -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
@@ -1,11 +1,11 @@
1
1
 
2
- # Gem::Specification for Rails_pwnerer-0.5.4
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.4
8
+ version: 0.5.5
9
9
  platform: ruby
10
10
  authors:
11
11
  - Victor Costan
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.5.4
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Costan