File: //usr/local/sbin/hp-esrpc
#!/usr/bin/env php
<?php
require_once("/usr/local/share/hostingplatform/esrpc.php");
require_once("/usr/local/share/hostingplatform/API.class.php");
$user = posix_getpwnam("hostingplatform-api")
or die ("Cannot get uid for user 'hostingplatform-api'!");
posix_setegid($user['gid'])
or die ("Cannot set gid for this process to '{$user['gid']}'!");
posix_seteuid($user['uid'])
or die ("Cannot set uid for this process to '{$user['uid']}'!");
if (posix_geteuid() !== $user['uid'])
die ("Failed to set uid for this process to '{$user['uid']}'!");
if (posix_getegid() !== $user['gid'])
die ("Failed to set gid for this process to '{$user['gid']}'!");
$server = new ESRPCConnection();
$server->setTarget(new HostingPlatformConnection());
$server->connect();
$server->serve();