From 0e750ee3447c97a629de52b887cbbe44d28b0d76 Mon Sep 17 00:00:00 2001 From: rudolfkoenig Date: Sat, 29 Jan 2011 07:38:13 +0000 Subject: [PATCH] change to the fhem user before creating any logs git-svn-id: https://fhem.svn.sourceforge.net/svnroot/fhem/trunk/fhem@813 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem.pl | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/fhem.pl b/fhem.pl index 2e14927d7..425671959 100755 --- a/fhem.pl +++ b/fhem.pl @@ -165,7 +165,7 @@ my $nextat; # Time when next timer will be triggered. my $intAtCnt=0; my %duplicate; # Pool of received msg for multi-fhz/cul setups my $duplidx=0; # helper for the above pool -my $cvsid = '$Id: fhem.pl,v 1.124 2011-01-29 07:32:48 rudolfkoenig Exp $'; +my $cvsid = '$Id: fhem.pl,v 1.125 2011-01-29 07:38:13 rudolfkoenig Exp $'; my $namedef = "where is either:\n" . "- a single device name\n" . @@ -238,6 +238,15 @@ my $commonAttr = "eventMap"; Hlp=>" ,trigger notify command" }, ); +# If started as root, and there is a fhem user in the /etc/passwd, su to it +if($^O !~ m/Win/ && $< == 0) { + my @pw = getpwnam("fhem"); + if(@pw) { + use POSIX qw(setuid); + setuid($pw[2]); + } +} + ################################################### # Start the program @@ -281,15 +290,6 @@ if($^O =~ m/Win/ && !$attr{global}{nofork}) { } -# If started as root, and there is a fhem user in the /etc/passwd, su to it -if($^O !~ m/Win/ && $< == 0) { - my @pw = getpwnam("fhem"); - if(@pw) { - use POSIX qw(setuid); - setuid($pw[2]); - } -} - # Go to background if the logfile is a real file (not stdout) if($attr{global}{logfile} ne "-" && !$attr{global}{nofork}) { defined(my $pid = fork) || die "Can't fork: $!";