Module: Mizuno::Daemonizer::UnixClassMethods

Defined in:
lib/mizuno/runner.rb

Instance Method Summary collapse

Instance Method Details

#setgid(options) ⇒ Object

Like setuid, but for groups.



49
50
51
52
53
54
55
# File 'lib/mizuno/runner.rb', line 49

def setgid(options)
    entry = Etc.getgrnam(options[:group])
    die("Can't find --group named '#{options[:group]}'") \
        unless entry
    return unless (_setgid(entry.gid) != 0)
    die("Can't switch to group '#{options[:group]}'")
end

#setuid(options) ⇒ Object

Switch the process over to a new user id; will abort the process if it fails. options is the full list of options passed to a server.



38
39
40
41
42
43
44
# File 'lib/mizuno/runner.rb', line 38

def setuid(options)
    entry = Etc.getpwnam(options[:user])
    die("Can't find --user named '#{options[:user]}'") \
        unless entry
    return unless (_setuid(entry.uid) != 0)
    die("Can't switch to user '#{options[:user]}'")
end