2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 18:59:33 +00:00

PRESENCE: fixing user detection on FritzBox! , replacing tabulator with white spaces

git-svn-id: https://svn.fhem.de/fhem/trunk@4614 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
markusbloch 2014-01-10 21:26:50 +00:00
parent f07220c30c
commit b71aa02461
2 changed files with 545 additions and 553 deletions

View File

@ -1,6 +1,7 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
# Do not insert empty lines here, update check depends on it.
- SVN
- bugfix: PRESENCE: fixing user detection on FritzBox!
- feature: new module 38_CO20.pm added (justme1968)
- feature: new module 98_GEOFANCY.pm added (loredo)
- feature: new module 70_XBMC.pm added (dbokermann)

View File

@ -62,6 +62,7 @@ PRESENCE_Define($$)
my ($hash, $def) = @_;
my @a = split("[ \t]+", $def);
my $dev;
my $username = (getpwuid($<))[0];
if(defined($a[2]) and defined($a[3]))
{
@ -90,12 +91,13 @@ PRESENCE_Define($$)
return $msg;
}
unless($< == 0)
unless($username == "root")
{
my $msg = "FHEM is not running under root (currently ".(getpwuid($<))[0].") This check can only performed with root access to the FritzBox";
my $msg = "FHEM is not running under root (currently $username) This check can only performed with root access to the FritzBox";
Log 2, "PRESENCE: ".$msg;
return $msg;
}
$hash->{MODE} = "fritzbox";
$hash->{ADDRESS} = $a[3];
$hash->{TIMEOUT_NORMAL} = (defined($a[4]) ? $a[4] : 30);
@ -104,9 +106,9 @@ PRESENCE_Define($$)
}
elsif($a[2] eq "lan-ping")
{
if(-X "/usr/bin/ctrlmgr_ctl" and not $< == 0)
if(-X "/usr/bin/ctrlmgr_ctl" and not $username == "root")
{
my $msg = "FHEM is not running under root (currently ".(getpwuid($<))[0].") This check can only performed with root access to the FritzBox";
my $msg = "FHEM is not running under root (currently $username) This check can only performed with root access to the FritzBox";
Log 2, "PRESENCE: ".$msg;
return $msg;
}
@ -172,7 +174,6 @@ PRESENCE_Define($$)
Log 2, $msg;
return $msg
}
}
else
{
@ -191,7 +192,6 @@ PRESENCE_Define($$)
return $msg;
}
if(defined($timeout) and not $timeout > 0)
{
my $msg = "check-interval must be greater than zero";
@ -215,18 +215,14 @@ PRESENCE_Define($$)
return $msg;
}
delete $hash->{helper}{cachednr} if(defined($hash->{helper}{cachednr}));
if($hash->{MODE} =~ /(lan-ping|local-bluetooth|fritzbox|shellscript|function)/)
{
RemoveInternalTimer($hash);
InternalTimer(gettimeofday()+2, "PRESENCE_StartLocalScan", $hash, 0) unless($hash->{helper}{DISABLED});
return;
}
elsif($hash->{MODE} eq "lan-bluetooth")
{
@ -287,11 +283,6 @@ PRESENCE_Set($@)
{
return $usage;
}
}