masquerade 0.2.0 → 0.3.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 +4 -0
- data/Manifest +1 -0
- data/Rakefile +1 -1
- data/lib/masquerade.rb +4 -4
- data/masquerade.gemspec +1 -1
- metadata +3 -3
data/CHANGELOG.rdoc
CHANGED
data/Manifest
CHANGED
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@ require "rubygems"
|
|
2
2
|
require "rake"
|
3
3
|
require "echoe"
|
4
4
|
|
5
|
-
Echoe.new("masquerade", "0.
|
5
|
+
Echoe.new("masquerade", "0.3.0") do |p|
|
6
6
|
p.description = "A user/group impersonator"
|
7
7
|
p.summary = "Run a block of code as another user/group."
|
8
8
|
p.url = "http://rubygems.org/gems/masquerade"
|
data/lib/masquerade.rb
CHANGED
@@ -46,11 +46,11 @@ Returns the result of the block call. So you can do:
|
|
46
46
|
end
|
47
47
|
=end
|
48
48
|
module Masquerade
|
49
|
-
def self.as(who
|
49
|
+
def self.as(who)
|
50
50
|
begin
|
51
51
|
current_uid = Process.uid
|
52
52
|
current_gid = Process.gid
|
53
|
-
if who.include?
|
53
|
+
if who.include? :user
|
54
54
|
user_struct = nil
|
55
55
|
if who[:user].kind_of? String
|
56
56
|
# get user info by name
|
@@ -62,7 +62,7 @@ module Masquerade
|
|
62
62
|
# set the uid of the current process to that of the chosen user
|
63
63
|
Process.uid = user_struct.uid
|
64
64
|
end
|
65
|
-
if who.include?
|
65
|
+
if who.include? :group
|
66
66
|
group_struct = nil
|
67
67
|
if who[:group].kind_of? String
|
68
68
|
# get group info by name
|
@@ -75,7 +75,7 @@ module Masquerade
|
|
75
75
|
Process.gid = group_struct.gid
|
76
76
|
end
|
77
77
|
# run the block
|
78
|
-
response =
|
78
|
+
response = yield who
|
79
79
|
# restore process uid and gid
|
80
80
|
Process.uid = current_uid
|
81
81
|
Process.gid = current_gid
|
data/masquerade.gemspec
CHANGED
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:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 3
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Nitesh Goel
|