Refactored defines and core includes, added root permissions check on InputDeviceServices and fixed the weird one character space in the log that occurs after the requires.

This commit is contained in:
ShadowEO
2016-05-31 16:57:43 -04:00
parent 93fb6f9358
commit d30f5ce5b4
3 changed files with 34 additions and 17 deletions

View File

@@ -1,7 +1,7 @@
<?php
/**
* InputDeviceServices.API.php
*
* Provides Input Device Mirroring for Devices, entirely in Userspace.
* @package default
*/
@@ -28,7 +28,9 @@ class InputDeviceServices {
if ($inst === null) {
$inst = new self;
}
return $inst;
return $inst;
}
@@ -37,7 +39,20 @@ class InputDeviceServices {
* @return unknown
*/
function module_loaded() {
self::API_Register();
static $attempted = null;
$processUser = posix_getpwuid(posix_geteuid());
if($attempted == true)
{
return true;
}
if($processUser['name'] == "root")
{
self::API_Register();
$attempted = true;
} else {
LogEcho("InputDeviceServices requires Overwatchd to be running as root.", "InputDeviceServices");
$attempted = true;
}
return true;
}