Class: Tango::Contexts::User
- Inherits:
-
Object
- Object
- Tango::Contexts::User
- Defined in:
- lib/tango/contexts/user.rb
Instance Method Summary collapse
- #enter ⇒ Object
-
#initialize(username) ⇒ User
constructor
A new instance of User.
- #leave ⇒ Object
Constructor Details
#initialize(username) ⇒ User
Returns a new instance of User.
5 6 7 |
# File 'lib/tango/contexts/user.rb', line 5 def initialize(username) @username = username end |
Instance Method Details
#enter ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/tango/contexts/user.rb', line 9 def enter @uid, @gid = Process.euid, Process.egid Process::Sys.seteuid(0) if @uid != 0 info = Etc.getpwnam(@username) Process::Sys.setegid(info.gid) Process::Sys.seteuid(info.uid) end |
#leave ⇒ Object
17 18 19 20 |
# File 'lib/tango/contexts/user.rb', line 17 def leave Process::Sys.seteuid(@uid) Process::Sys.setegid(@gid) end |