aboutsummaryrefslogtreecommitdiff
path: root/saxrobot
diff options
context:
space:
mode:
authorDavid Phillips <david@sighup.nz>2017-03-17 21:40:20 +1300
committerDavid Phillips <david@sighup.nz>2017-03-17 21:40:20 +1300
commit165301c42b14a7096eaa31f631c402361872db88 (patch)
tree12222660f46df9a9f053b7c78f7fff4094e4a71c /saxrobot
parent84664ecaacaa1d480d02dc836dfd6a33f552e325 (diff)
downloadidalius-165301c42b14a7096eaa31f631c402361872db88.tar.xz
Add privellege dropping
Diffstat (limited to 'saxrobot')
-rwxr-xr-xsaxrobot8
1 files changed, 8 insertions, 0 deletions
diff --git a/saxrobot b/saxrobot
index 0dcd5f1..065e01a 100755
--- a/saxrobot
+++ b/saxrobot
@@ -2,6 +2,7 @@
use strict;
use warnings;
+use POSIX qw(setuid setgid);
use POE;
use POE::Kernel;
use POE::Component::IRC;
@@ -33,8 +34,15 @@ POE::Session->create(
heap => { irc => $irc },
);
+drop_priv();
+
$poe_kernel->run();
+sub drop_priv {
+ setgid($config{gid}) or die "Failed to setgid: $!\n";
+ setuid($config{uid}) or die "Failed to setuid: $!\n";
+}
+
sub _start {
my $heap = $_[HEAP];
my $irc = $heap->{irc};