1
0

use ncc_upload

This commit is contained in:
Mike Schwörer 2018-12-22 21:20:12 +01:00
parent 0d118d5168
commit 48f82bccae
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF

View File

@ -6,28 +6,26 @@ require_once (__DIR__ . '/../internals/base.php');
require_once (__DIR__ . '/../internals/database.php'); require_once (__DIR__ . '/../internals/database.php');
$folder = $OPTIONS['folder']; $folder = $OPTIONS['folder'];
$filename = $OPTIONS['filename']; $filename = $OPTIONS['filename'];
$secret = $OPTIONS['secret']; $secret = $OPTIONS['secret'];
$uri = $OPTIONS['uri']; $uri = $OPTIONS['uri'];
$reltarget = "/Mikescher/files/Backup/$folder"; $reltarget = "Backup/$folder/$filename";
$target = "/media/filecloud/data/Mikescher/files/Backup/$folder/$filename";
if ($secret !== $CONFIG['upload_secret']) die('Unauthorized.'); if ($secret !== $CONFIG['upload_secret']) die('Unauthorized.');
$putdata = fopen("php://input", "r"); $putdata = fopen("php://input", "r");
$fp = fopen($target, "x"); $fp = tmpfile();
$tmppath = stream_get_meta_data($fp)['uri'];
while ($data = fread($putdata, 1024)) fwrite($fp, $data); while ($data = fread($putdata, 1024)) fwrite($fp, $data);
fclose($fp); fclose($fp);
fclose($putdata); fclose($putdata);
$std = shell_exec("sudo ncc_upload " . '"' . $tmppath . '" "' . $reltarget . '"'); // ncc_upload is allowed for all in /etc/sudoers
$std = shell_exec("sudo scan-cloud " . '"' . $reltarget . '"'); // scan-cloud is allowed for all in /etc/sudoers $content = "REQUEST: " . $uri . "\r\n\r\n" .
$content = "REQUEST: " . $uri . "\r\n\r\n" .
"IP: " . get_client_ip() . "\r\n\r\n" . "IP: " . get_client_ip() . "\r\n\r\n" .
"TARGET: " . $target . "\r\n\r\n" . "TARGET: " . $reltarget . "\r\n\r\n" .
"OUTPUT: " . $std . "\r\n\r\n"; "OUTPUT: " . $std . "\r\n\r\n";
sendMail("Fileupload to '$folder' triggered", $content, 'virtualadmin@mikescher.de', 'webserver-error@mikescher.com'); sendMail("Fileupload to '$folder' triggered", $content, 'virtualadmin@mikescher.de', 'webserver-error@mikescher.com');