rails_pwnerer 0.5.8 → 0.5.9

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.9. Better method for locating gems.
2
+
1
3
  v0.5.8. Fixed crashing in base/process.rb when sys-proctable isn't there (scaffolding time).
2
4
 
3
5
  v0.5.7. Better procedure for removing an instance.
data/Manifest CHANGED
@@ -34,7 +34,7 @@ lib/pwnage/scaffolds/hook_dyndns.rb
34
34
  lib/pwnage/scaffolds/mysql_config.rb
35
35
  lib/pwnage/scaffolds/packages.rb
36
36
  lib/pwnage/scaffolds/rubygems.rb
37
- lib/rails_pwnage.rb
37
+ lib/rails_pwnerer.rb
38
38
  LICENSE
39
39
  Manifest
40
40
  Rakefile
data/README CHANGED
@@ -41,9 +41,9 @@ sudo rpwn scaffold
41
41
 
42
42
  If this doesn't work, you have a retarded Debian version of rubygems.
43
43
  Workaround:
44
- a) gem which rails_pwnerer
45
- b) see where the gem lives (e.g. /var/lib/gems/1.8/gems/rails_pwnerer)
46
- c) run rpwn from there:
44
+
45
+ a) Find the path to the gems: gem environment gemdir (e.g. /var/lib/gems/1.8/gems/)
46
+ b) run bin/rpwn from there:
47
47
  sudo /var/lib/gems/1.8/bin/rails_pwnerer scaffold
48
48
 
49
49
  After you scaffold, you'll get good rubygems which put rpwn in your path.
data/bin/rpwn CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'rubygems'
3
- require 'rails_pwnage'
3
+ require 'rails_pwnerer'
4
4
 
5
5
  RailsPwnage::Executor.new.run ARGV
data/bin/rpwnctl CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'rubygems'
3
- require 'rails_pwnage'
3
+ require 'rails_pwnerer'
4
4
 
5
5
  RailsPwnage::CtlExecutor.new.run ARGV
data/bin/rpwndev CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'rubygems'
3
- require 'rails_pwnage'
3
+ require 'rails_pwnerer'
4
4
 
5
5
  RailsPwnage::DevExecutor.new.run ARGV
@@ -14,21 +14,28 @@ module RailsPwnage::Base
14
14
  # update the metadata for all the gems
15
15
  def update_gems()
16
16
  system "gem update --system"
17
- # patch Ubuntu's broken rubygems installation
18
- system "cp /usr/bin/gem1.8 /usr/bin/gem"
19
17
  end
20
18
 
21
19
  # locates the main file in a gem (used to locate the gem)
22
20
  def path_to_gem(gem_name, discard_suffix = '')
23
21
  # TODO: use the rubygems API instead of this hack
24
22
 
25
- # look for the main file in the gem
26
- output = `gem which '#{gem_name}'`
23
+ # method 1: peek inside rubygems' treasure chest
24
+ begin
25
+ gem_pattern = File.join `gem environment gemdir`.strip, 'gems', gem_name
26
+ gem_path = Dir.glob(gem_pattern + '*').max
27
+ rescue
28
+ gem_path = nil
29
+ end
30
+ return gem_path unless gem_path.nil? or gem_path.empty?
31
+
32
+ # method 2: look for the main file in the gem
33
+ gem_path = `gem which '#{gem_name}'`.strip
27
34
  # discard the given suffix
28
- if output[-(discard_suffix.lenth)..-1] == discard_suffix
29
- output[-(discard_suffix.lenth)..-1] = ''
35
+ if gem_path[-(discard_suffix.length)..-1] == discard_suffix
36
+ gem_path[-(discard_suffix.length)..-1] = ''
30
37
  end
31
- return output
38
+ return gem_path
32
39
  end
33
40
  end
34
41
 
@@ -23,6 +23,7 @@ class RailsPwnage::Executor
23
23
  when 'packages'
24
24
  Packages.go
25
25
  when 'rubygems'
26
+ RubyGems.pre_go
26
27
  RubyGems.go
27
28
  when 'ddns'
28
29
  if args.length < 5
@@ -30,7 +31,8 @@ class RailsPwnage::Executor
30
31
  else
31
32
  HookDyndns.go args[2], args[3], args[4]
32
33
  end
33
- else
34
+ when nil
35
+ RubyGems.pre_go
34
36
  Packages.go
35
37
  RubyGems.go
36
38
  Gems.go
@@ -39,6 +41,8 @@ class RailsPwnage::Executor
39
41
  DirPermissions.go
40
42
  MysqlConfig.go
41
43
  HookDaemon.go
44
+ else
45
+ print "Unrecognized scaffold command #{args[1]}\n"
42
46
  end
43
47
 
44
48
  when 'install', 'micro'
@@ -5,7 +5,7 @@ class RailsPwnage::Scaffolds::HookDaemon
5
5
 
6
6
  # runner
7
7
  def run
8
- daemon_ctl = path_to_gem('rails_pwnage', 'lib/rails_pwnage.rb') + 'bin/rpwnctl'
8
+ daemon_ctl = File.join path_to_gem('rails_pwnerer', '/lib/rails_pwnerer.rb'), 'bin/rpwnctl'
9
9
  hook_boot_script daemon_ctl, 'rpwn'
10
10
  end
11
11
 
@@ -35,8 +35,8 @@ class RailsPwnage::Scaffolds::Packages
35
35
  # wipe the old version (and pray we don't die until we're done, otherwise we're on a ruby-less system)
36
36
  remove_packages %w(ruby1.8 libruby1.8)
37
37
 
38
- # install ruby from source (get
39
- install_packages %w(ruby1.8 rdoc libsetup-ruby1.8 ruby-pkg-tools rubygems irb), :source => true
38
+ # install ruby from source
39
+ install_packages %w(ruby1.8 rdoc libsetup-ruby1.8 ruby-pkg-tools rubygems1.8 rubygems irb), :source => true
40
40
  end
41
41
 
42
42
  # the packages for a mysql server and development libraries
@@ -46,19 +46,33 @@ class RailsPwnage::Scaffolds::RubyGems
46
46
  end
47
47
 
48
48
  def run
49
- # save old lib path, in case we need to wipe it
50
- old_gems = path_to_gem('rubygems', '/1.8/rubygems.rb')
49
+ # get the old path set by pre-go
50
+ old_gems = @@old_gems
51
51
 
52
52
  # remove the (retarded) Debian gems package and install from source
53
53
  remove_packages %w(rubygems)
54
54
  install_rubygems
55
55
 
56
+ # patch Ubuntu's broken rubygems installation
57
+ system "cp /usr/bin/gem1.8 /usr/bin/gem"
58
+
56
59
  # remove the gems that are trailing behind
57
- new_gems = path_to_gem('rubygems', '/1.8/rubygems.rb')
60
+ new_gems = File.dirname(File.dirname(path_to_gem('sources', '/lib/sources.rb')))
58
61
  return if new_gems == old_gems # don't wipe the new dir by mistake
59
62
  FileUtils.rm_r old_gems
60
63
  end
61
64
 
65
+ def preflight
66
+ # save old lib path, in case we need to wipe it
67
+ # we need to do this because setting up packages might wipe Ubuntu's gems
68
+ @@old_gems = File.dirname(File.dirname(path_to_gem('sources', '/lib/sources.rb')))
69
+ end
70
+
71
+ # called before packages get installed
72
+ def self.pre_go
73
+ self.new.preflight
74
+ end
75
+
62
76
  # standalone runner
63
77
  def self.go
64
78
  self.new.run
File without changes
@@ -1,18 +1,18 @@
1
1
 
2
- # Gem::Specification for Rails_pwnerer-0.5.8
2
+ # Gem::Specification for Rails_pwnerer-0.5.9
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
8
+ version: 0.5.9
9
9
  platform: ruby
10
10
  authors:
11
11
  - Victor Costan
12
12
  autorequire:
13
13
  bindir: bin
14
14
 
15
- date: 2008-08-20 00:00:00 -04:00
15
+ date: 2008-08-22 00:00:00 -04:00
16
16
  default_executable:
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
@@ -70,7 +70,7 @@ extra_rdoc_files:
70
70
  - lib/pwnage/scaffolds/mysql_config.rb
71
71
  - lib/pwnage/scaffolds/packages.rb
72
72
  - lib/pwnage/scaffolds/rubygems.rb
73
- - lib/rails_pwnage.rb
73
+ - lib/rails_pwnerer.rb
74
74
  - LICENSE
75
75
  - README
76
76
  files:
@@ -110,7 +110,7 @@ files:
110
110
  - lib/pwnage/scaffolds/mysql_config.rb
111
111
  - lib/pwnage/scaffolds/packages.rb
112
112
  - lib/pwnage/scaffolds/rubygems.rb
113
- - lib/rails_pwnage.rb
113
+ - lib/rails_pwnerer.rb
114
114
  - LICENSE
115
115
  - Manifest
116
116
  - Rakefile
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.8
4
+ version: 0.5.9
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-08-20 00:00:00 -04:00
12
+ date: 2008-08-22 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -67,7 +67,7 @@ extra_rdoc_files:
67
67
  - lib/pwnage/scaffolds/mysql_config.rb
68
68
  - lib/pwnage/scaffolds/packages.rb
69
69
  - lib/pwnage/scaffolds/rubygems.rb
70
- - lib/rails_pwnage.rb
70
+ - lib/rails_pwnerer.rb
71
71
  - LICENSE
72
72
  - README
73
73
  files:
@@ -107,7 +107,7 @@ files:
107
107
  - lib/pwnage/scaffolds/mysql_config.rb
108
108
  - lib/pwnage/scaffolds/packages.rb
109
109
  - lib/pwnage/scaffolds/rubygems.rb
110
- - lib/rails_pwnage.rb
110
+ - lib/rails_pwnerer.rb
111
111
  - LICENSE
112
112
  - Manifest
113
113
  - Rakefile