1
0
mirror of https://github.com/cmur2/dyndnsd.git synced 2024-12-21 14:54:22 +01:00

Support dropping priviliges

This commit is contained in:
cn 2013-04-30 23:19:08 +02:00
parent f0bd538728
commit 1073312110
2 changed files with 8 additions and 0 deletions

View File

@ -24,6 +24,9 @@ Create a configuration file in YAML format somewhere:
# listen address and port
host: "0.0.0.0"
port: "80"
# optional: drop priviliges in case you want to but you may need sudo for external commands
user: "nobody"
group: "nogroup"
# logfile is optional, logs to STDOUT else
logfile: "dyndnsd.log"
# interal database file

View File

@ -1,5 +1,6 @@
#!/usr/bin/env ruby
require 'etc'
require 'logger'
require 'ipaddr'
require 'json'
@ -145,6 +146,10 @@ module Dyndnsd
Dyndnsd.logger.info "Starting..."
# drop privs (first change group than user)
Process::Sys.setgid(Etc.getgrnam(config['group']).gid) if config['group']
Process::Sys.setuid(Etc.getpwnam(config['user']).uid) if config['user']
# configure metriks
reporter = Metriks::Reporter::ProcTitle.new
reporter.add 'good', 'sec' do