From e9e7a56b0e2483aab8c485d0f6709afd87a69ed8 Mon Sep 17 00:00:00 2001 From: tpoitzsch Date: Tue, 2 Dec 2014 21:21:28 +0000 Subject: [PATCH] FRITZBOX: Msg if user is not root git-svn-id: https://svn.fhem.de/fhem/trunk@7119 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/72_FRITZBOX.pm | 41 ++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/fhem/FHEM/72_FRITZBOX.pm b/fhem/FHEM/72_FRITZBOX.pm index 74aca746d..19adef57a 100644 --- a/fhem/FHEM/72_FRITZBOX.pm +++ b/fhem/FHEM/72_FRITZBOX.pm @@ -152,23 +152,32 @@ FRITZBOX_Define($$) $hash->{NAME} = $name; - if ( FRITZBOX_Exec( $hash, "[ -f /usr/bin/ctlmgr_ctl ] && echo 1 || echo 0" ) ) + my $msg; + + unless ( -X "/usr/bin/ctlmgr_ctl" ) { - $hash->{STATE} = "Initializing"; - $hash->{fhem}{modulVersion} = '$Date$'; - $hash->{INTERVAL} = 300; - $hash->{fhem}{lastHour} = 0; - $hash->{fhem}{LOCAL} = 0; - + $msg = "Error - FHEM needs to run on a Fritz!Box to use the FRITZBOX module"; + FRITZBOX_Log $hash, 1, $msg; + return $msg; + } + elsif ( $< != 0 ) + { + $msg = "Error - FHEM is not running under root (currently " . + ( getpwuid( $< ) )[ 0 ] . + ") but we need to be root"; + FRITZBOX_Log $hash, 1, $msg; + return $msg; + } + + $hash->{STATE} = "Initializing"; + $hash->{fhem}{modulVersion} = '$Date$'; + $hash->{INTERVAL} = 300; + $hash->{fhem}{lastHour} = 0; + $hash->{fhem}{LOCAL} = 0; - RemoveInternalTimer($hash); - # Get first data after 6 seconds - InternalTimer(gettimeofday() + 6, "FRITZBOX_Readout_Start", $hash, 0); - } - else - { - $hash->{STATE} = "Error: FHEM not running on a Fritz!Box"; - } + RemoveInternalTimer($hash); + # Get first data after 6 seconds + InternalTimer(gettimeofday() + 6, "FRITZBOX_Readout_Start", $hash, 0); return undef; } #end FRITZBOX_Define @@ -1091,7 +1100,7 @@ FRITZBOX_Exec($$)