예제 #1
0
파일: lib.php 프로젝트: lonelywoolf/hypervm
function doRealGetFromFileServ($cmd, $serv, $filepass, $copyto = null)
{
    $file = $filepass['file'];
    $pass = $filepass['pass'];
    $size = $filepass['size'];
    $base = basename($file);
    if ($serv === 'localhost') {
        $array = lfile_get_unserialize("__path_serverfile/{$base}");
        $realfile = $array['filename'];
        log_log("servfile", "getting local file {$realfile}");
        if (lxfile_exists($realfile) && lis_readable($realfile)) {
            lunlink("__path_serverfile/{$base}");
            if ($cmd === 'fileprint') {
                slow_print($realfile);
            } else {
                lxfile_mkdir(dirname($copyto));
                lxfile_cp($realfile, $copyto);
            }
            fileserv_unlink_if_tmp($realfile);
            return;
        }
        if (os_isSelfSystemUser()) {
            log_log("servfile", "is System User, but can't access {$realfile} returning");
            //return;
        } else {
            log_log("servfile", "is Not system user, can't access so will get {$realfile} through backend");
        }
    }
    $fd = null;
    if ($copyto) {
        lxfile_mkdir(dirname($copyto));
        $fd = lfopen($copyto, "wb");
        if (!$fd) {
            log_log("servfile", "Could not write to {$copyto}... Returning.");
            return;
        }
        lxfile_generic_chmod($copyto, "0700");
    }
    doGetOrPrintFromFileServ($serv, $filepass, $cmd, $fd);
    if ($fd) {
        fclose($fd);
    }
}
예제 #2
0
function do_socket($socklist, $processfunc)
{
    global $gbl, $sgbl, $login, $ghtml;
    $client = null;
    $i = 0;
    while (true) {
        $read = null;
        foreach ($socklist as $sock) {
            $read[] = $sock;
        }
        $writea = null;
        $excpta = null;
        // Set up a blocking call to stream_select()
        $ready = stream_select($read, $writea, $excpta, 30);
        // Server stuff must be executed not merely when it is timed out. But always.
        if (os_isSelfSystemUser()) {
            do_server_stuff();
        }
        if ($ready === 0) {
            myPcntl_reaper();
            continue;
        }
        myPcntl_reaper();
        // This means that sock - which is our main master socket - is ready for reading, which in turn signifies that a NEW connection has arrived. The other members of the read array
        foreach ($socklist as $sock) {
            if (in_array($sock, $read)) {
                //dprintr($sock);
                $pid = pcntl_fork();
                if ($pid === 0) {
                    $childsock = stream_socket_accept($sock);
                    if (!$childsock) {
                        exit;
                    }
                    stream_set_timeout($childsock, 30000000);
                    foreach ($socklist as $msock) {
                        fclose($msock);
                    }
                    process_single_command($childsock, $processfunc);
                    exit;
                } else {
                    usleep(100 * 1000);
                    //fclose($c);
                    // Parent...
                }
            }
        }
    }
    // end while
    // Close the master sockets
    fclose($sock);
}
예제 #3
0
<?php

include_once "htmllib/lib/include.php";
if (!os_isSelfSystemUser()) {
    print "Not enough privileges\n";
    exit;
}
//initProgram('admin');
$list = get_all_pserver();
foreach ($list as $l) {
    try {
        $res = rl_exec_get(null, $l, "exec_with_all_closed_output", $argv[1]);
        print "Got this from server {$l}\n";
        print_r($res);
        print "\n-----------------\n";
    } catch (Exception $e) {
        print "Got error from {$l} {$e->__full_message}\n";
    }
}