Module: Process::Daemon::Priviledges
- Defined in:
- lib/process/daemon/priviledges.rb
Class Method Summary collapse
-
.change_user(user) ⇒ Object
Set the user of the current process.
-
.current_user ⇒ Object
Get the user of the current process.
Class Method Details
.change_user(user) ⇒ Object
Set the user of the current process. Supply either a user ID or a user name.
28 29 30 31 32 33 34 |
# File 'lib/process/daemon/priviledges.rb', line 28 def self.change_user(user) if user.kind_of?(String) user = Etc.getpwnam(user).uid end Process::Sys.setuid(user) end |
.current_user ⇒ Object
Get the user of the current process. Returns the user name.
37 38 39 40 41 |
# File 'lib/process/daemon/priviledges.rb', line 37 def self.current_user uid = Process::Sys.getuid Etc.getpwuid(uid).name end |