mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-10 09:16:53 +00:00
change to the fhem user before creating any logs
git-svn-id: https://svn.fhem.de/fhem/trunk@813 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
5a5c138828
commit
83fd5300bb
20
fhem/fhem.pl
20
fhem/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 <name> is either:\n" .
|
||||
"- a single device name\n" .
|
||||
@ -238,6 +238,15 @@ my $commonAttr = "eventMap";
|
||||
Hlp=>"<devspec> <state>,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: $!";
|
||||
|
Loading…
x
Reference in New Issue
Block a user