masquerade 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc CHANGED
@@ -1,5 +1,9 @@
1
1
  = Changelog
2
2
 
3
+ == Relase 0.7.0 - May 03, 2011
4
+
5
+ * FIX: Catching an invalid user or group error also catching the block's ArgumentErrors
6
+
3
7
  == Release 0.6.0 - April 15, 2011
4
8
 
5
9
  * CHANGE: Change both uid+euid and gid+egid to switch user
data/Manifest CHANGED
@@ -3,4 +3,3 @@ Manifest
3
3
  README.rdoc
4
4
  Rakefile
5
5
  lib/masquerade.rb
6
- masquerade.gemspec
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require "rubygems"
2
2
  require "rake"
3
3
  require "echoe"
4
4
 
5
- Echoe.new("masquerade", "0.6.0") do |p|
5
+ Echoe.new("masquerade", "0.7.0") do |p|
6
6
  p.description = "A user/group impersonator. Allows you to run a block of code as another user or group."
7
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"
data/lib/masquerade.rb CHANGED
@@ -47,11 +47,11 @@ Returns the result of the block call. So you can do:
47
47
  =end
48
48
  module Masquerade
49
49
  def self.as(who)
50
+ current_euid = Process.euid
51
+ current_egid = Process.egid
52
+ current_uid = Process.uid
53
+ current_gid = Process.gid
50
54
  begin
51
- current_euid = Process.euid
52
- current_egid = Process.egid
53
- current_uid = Process.uid
54
- current_gid = Process.gid
55
55
  if who.include? :group
56
56
  group_struct = nil
57
57
  if who[:group].kind_of? String
@@ -78,19 +78,19 @@ module Masquerade
78
78
  Process.euid = user_struct.uid
79
79
  Process.uid = user_struct.uid
80
80
  end
81
- # run the block
82
- response = yield who
83
- # restore process uid and gid
84
- Process.uid = current_uid
85
- Process.euid = current_euid
86
- Process.gid = current_gid
87
- Process.egid = current_egid
88
- return response
89
81
  rescue Errno::EPERM
90
82
  raise PermissionsError, "You do not have permissions to impersonate this user or group"
91
83
  rescue ArgumentError
92
84
  raise BadUserOrGroupError, "The user or group does not exist"
93
85
  end
86
+ # run the block
87
+ response = yield who
88
+ # restore process uid and gid
89
+ Process.uid = current_uid
90
+ Process.euid = current_euid
91
+ Process.gid = current_gid
92
+ Process.egid = current_egid
93
+ return response
94
94
  end
95
95
 
96
96
  class PermissionsError < StandardError
data/masquerade.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{masquerade}
5
- s.version = "0.6.0"
5
+ s.version = "0.7.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-16}
9
+ s.date = %q{2011-05-03}
10
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"]
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: 7
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 6
8
+ - 7
9
9
  - 0
10
- version: 0.6.0
10
+ version: 0.7.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Nitesh Goel
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-16 00:00:00 Z
18
+ date: 2011-05-03 00:00:00 Z
19
19
  dependencies: []
20
20
 
21
21
  description: A user/group impersonator. Allows you to run a block of code as another user or group.