File tircd-daemon.patch of Package tircd

--- tircd.pl.orig	2009-04-09 19:22:30.000000000 +0200
+++ tircd.pl	2009-04-10 00:17:58.000000000 +0200
@@ -81,6 +81,13 @@
   );
 }
 
+if (defined($config{'pidfile'})) {
+  my $pidfd;
+  open($pidfd, '>'.$config{'pidfile'}) or die "failed to create PID file \"".$config{'pidfile'}."\": $!";
+  print $pidfd $$;
+  close($pidfd);
+}
+
 #setup our 'irc server'
 POE::Component::Server::TCP->new(
   Alias			=> "tircd",              
@@ -137,6 +144,19 @@
 sub tircd_setup {
   $_[KERNEL]->call('logger','log',"tircd $VERSION started, using config from: $config_file.");
   $_[KERNEL]->call('logger','log',"Listening on: $config{'address'}:$config{'port'}."); 
+  if (defined($config{'user'})) {
+    if ($> == 0) {
+      my ($name, $passwd, $uid) = getpwnam($config{'user'});
+      if (defined($name)) {
+        $_[KERNEL]->call('logger','log',"Switching user to ".$config{'user'}.".");
+        $> = $uid;
+      } else {
+        $_[KERNEL]->call('logger','log',"Unknown user ".$config{'user'}.".");
+      }
+    } else {
+      $_[KERNEL]->call('logger','log',"Not switching user to ".$config{'user'}.", not running as root.");
+    }
+  }
 }
 
 #setup our logging session
openSUSE Build Service is sponsored by