Permalink
Browse files

Added ability to drop privileges.

  • Loading branch information...
david committed Jun 27, 2008
1 parent d8f528a commit d6a5e6bd9c8301b1fe99c6931f4c7b91ac71cc18
Showing with 8 additions and 0 deletions.
  1. +8 −0 lib/minibot/daemon.rb
View
@@ -1,4 +1,5 @@
require 'socket'
+require 'etc'
module MiniBot
class Daemon
@@ -37,6 +38,13 @@ def initialize(config)
@realname = config[:realname] || @nick
end
+ def run_as(user, group)
+ uid = Etc.getpwnam(user).uid
+ gid = Etc.getgrnam(group).gid
+ Process::GID.change_privilege gid
+ Process::UID.change_privilege uid
+ end
+
def connect(server, port = 6667)
@server = Server.connect server, port
end

0 comments on commit d6a5e6b

Please sign in to comment.