masquerade 0.3.0 → 0.4.0

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.rdoc CHANGED
@@ -1,6 +1,10 @@
1
1
  = Changelog
2
+ == Release 0.4.0 - April 14, 2011
2
3
 
3
- == Release 0.30 - April 14, 2011
4
+ * CHANGE: Use euid and eguid as opposed to uid and gid to switch user
5
+ * CHANGE: Make summary more descriptive
6
+
7
+ == Release 0.4.0 - April 14, 2011
4
8
 
5
9
  * CHANGE: Use yield instead of block.call to invoke block
6
10
 
data/Rakefile CHANGED
@@ -2,9 +2,9 @@ require "rubygems"
2
2
  require "rake"
3
3
  require "echoe"
4
4
 
5
- Echoe.new("masquerade", "0.3.0") do |p|
6
- p.description = "A user/group impersonator"
7
- p.summary = "Run a block of code as another user/group."
5
+ Echoe.new("masquerade", "0.4.0") do |p|
6
+ p.description = "A user/group impersonator. Allows you to run a block of code as another user or group."
7
+ p.summary = "A user/group impersonator. Allows you to run a block of code as another user or group"
8
8
  p.url = "http://rubygems.org/gems/masquerade"
9
9
  p.author = "Nitesh Goel"
10
10
  p.email = "nitesh@wikinvest.com"
data/lib/masquerade.rb CHANGED
@@ -48,20 +48,8 @@ Returns the result of the block call. So you can do:
48
48
  module Masquerade
49
49
  def self.as(who)
50
50
  begin
51
- current_uid = Process.uid
52
- current_gid = Process.gid
53
- if who.include? :user
54
- user_struct = nil
55
- if who[:user].kind_of? String
56
- # get user info by name
57
- user_struct = Etc.getpwnam(who[:user])
58
- elsif who[:user].kind_of? Numeric
59
- # get user info by uid
60
- user_struct = Etc.getpwuid(who[:user])
61
- end
62
- # set the uid of the current process to that of the chosen user
63
- Process.uid = user_struct.uid
64
- end
51
+ current_uid = Process.euid
52
+ current_gid = Process.egid
65
53
  if who.include? :group
66
54
  group_struct = nil
67
55
  if who[:group].kind_of? String
@@ -72,13 +60,25 @@ module Masquerade
72
60
  group_struct = Etc.getgrgid(who[:group])
73
61
  end
74
62
  # set the gid of the current process to that of the chosen group
75
- Process.gid = group_struct.gid
63
+ Process.egid = group_struct.gid
64
+ end
65
+ if who.include? :user
66
+ user_struct = nil
67
+ if who[:user].kind_of? String
68
+ # get user info by name
69
+ user_struct = Etc.getpwnam(who[:user])
70
+ elsif who[:user].kind_of? Numeric
71
+ # get user info by uid
72
+ user_struct = Etc.getpwuid(who[:user])
73
+ end
74
+ # set the uid of the current process to that of the chosen user
75
+ Process.euid = user_struct.uid
76
76
  end
77
77
  # run the block
78
78
  response = yield who
79
79
  # restore process uid and gid
80
- Process.uid = current_uid
81
- Process.gid = current_gid
80
+ Process.euid = current_euid
81
+ Process.egid = current_egid
82
82
  return response
83
83
  rescue Errno::EPERM
84
84
  raise PermissionsError, "You do not have permissions to impersonate this user or group"
data/masquerade.gemspec CHANGED
@@ -2,12 +2,12 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{masquerade}
5
- s.version = "0.3.0"
5
+ s.version = "0.4.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Nitesh Goel"]
9
- s.date = %q{2011-04-14}
10
- s.description = %q{A user/group impersonator}
9
+ s.date = %q{2011-04-15}
10
+ s.description = %q{A user/group impersonator. Allows you to run a block of code as another user or group.}
11
11
  s.email = %q{nitesh@wikinvest.com}
12
12
  s.extra_rdoc_files = ["CHANGELOG.rdoc", "README.rdoc", "lib/masquerade.rb"]
13
13
  s.files = ["CHANGELOG.rdoc", "Manifest", "README.rdoc", "Rakefile", "lib/masquerade.rb", "masquerade.gemspec"]
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
16
16
  s.require_paths = ["lib"]
17
17
  s.rubyforge_project = %q{masquerade}
18
18
  s.rubygems_version = %q{1.7.2}
19
- s.summary = %q{Run a block of code as another user/group.}
19
+ s.summary = %q{A user/group impersonator. Allows you to run a block of code as another user or group}
20
20
 
21
21
  if s.respond_to? :specification_version then
22
22
  s.specification_version = 3
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: masquerade
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 3
8
+ - 4
9
9
  - 0
10
- version: 0.3.0
10
+ version: 0.4.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Nitesh Goel
@@ -15,10 +15,10 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-14 00:00:00 Z
18
+ date: 2011-04-15 00:00:00 Z
19
19
  dependencies: []
20
20
 
21
- description: A user/group impersonator
21
+ description: A user/group impersonator. Allows you to run a block of code as another user or group.
22
22
  email: nitesh@wikinvest.com
23
23
  executables: []
24
24
 
@@ -73,6 +73,6 @@ rubyforge_project: masquerade
73
73
  rubygems_version: 1.7.2
74
74
  signing_key:
75
75
  specification_version: 3
76
- summary: Run a block of code as another user/group.
76
+ summary: A user/group impersonator. Allows you to run a block of code as another user or group
77
77
  test_files: []
78
78