All new accounts created on Gitlab now require administrator approval. If you invite any collaborators, please let Flux staff know so they can approve the accounts.

spewlogfile.php3 1.35 KB
Newer Older
1
<?php
Leigh B. Stoller's avatar
Leigh B. Stoller committed
2 3
#
# EMULAB-COPYRIGHT
4
# Copyright (c) 2000-2007 University of Utah and the Flux Group.
Leigh B. Stoller's avatar
Leigh B. Stoller committed
5 6
# All rights reserved.
#
7 8 9
include("defs.php3");

#
10
# Only known and logged in users.
11
#
12 13
$this_user = CheckLoginOrDie();
$uid       = $this_user->uid();
14 15 16 17

#
# Verify page arguments.
#
18
$reqargs = RequiredPageArguments("logfile", PAGEARG_LOGFILE);
19

20 21
if (! isset($logfile)) {
    PAGEARGERROR("Must provide either a logfile ID");
22 23
}

24 25 26
# Check permission in the backend. The user is logged in, so its safe enough
# to pass it through.
$logfileid = $logfile->logid();
27

28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
#
# A cleanup function to keep the child from becoming a zombie, since
# the script is terminated, but the children are left to roam.
#
$fp = 0;

function SPEWCLEANUP()
{
    global $fp;

    if (!$fp || !connection_aborted()) {
	exit();
    }
    pclose($fp);
    exit();
}
44
ignore_user_abort(1);
45 46
register_shutdown_function("SPEWCLEANUP");

47 48
if ($fp = popen("$TBSUEXEC_PATH $uid nobody ".
		"spewlogfile -w -i " . escapeshellarg($logfileid), "r")) {
49 50 51 52 53 54 55 56
    header("Content-Type: text/plain");
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
    header("Cache-Control: no-cache, must-revalidate");
    header("Pragma: no-cache");
    flush();

    while (!feof($fp)) {
	$string = fgets($fp, 1024);
57 58 59 60 61 62 63
	echo "$string";
	flush();
    }
    pclose($fp);
    $fp = 0;
}
else {
64
    USERERROR("Logfile $logfileid is no longer valid!", 1);
65 66 67
}

?>