noderdp.php3 2.7 KB
Newer Older
1
2
3
<?php
#
# EMULAB-COPYRIGHT
4
# Copyright (c) 2000-2004, 2006, 2007 University of Utah and the Flux Group.
5
6
7
# All rights reserved.
#
include("defs.php3");
8
include_once("node_defs.php");
9
10
11
12
13
14
15
16
17

#
# This script generates an "tbc" file, to be passed to ./rdp-mime.pl
# on the remote node, when set up as a proper mime type.
#

#
# Only known and logged in users.
#
18
19
$this_user = CheckLoginOrDie();
$uid       = $this_user->uid();
20

21
22
23
24
25
26
27
28
#
# Verify form arguments.
#
$reqargs = RequiredPageArguments("node", PAGEARG_NODE);

# Need these below
$node_id = $node->node_id();

29
30
31
if ($this_user->w_pswd() != "") {
    $pswd = $this_user->w_pswd();
}
32
33
34
else {
    # The initial random default for the Windows Password is based on the Unix
    # encrypted password, in particular the random salt if it's an MD5 crypt,
35
36
37
    # consisting of the 8 characters after an initial "$1$" and followed by a
    # "$". 
    $unixpwd = explode('$', $this_user->pswd());
38
39
40
41
42
43
44
    if (strlen($unixpwd[0]) > 0)
	# When there's no $ at the beginning, it's not an MD5 hash.
	$pswd = substr($unixpwd[0],0,8);
    else
	$pswd = substr($unixpwd[2],0,8); # The MD5 salt string.
}

45
$query_result =
Robert Ricci's avatar
Robert Ricci committed
46
    DBQueryFatal("select n.jailflag,n.jailip,n.sshdport, ".
47
48
49
50
51
52
53
54
55
56
57
58
		 "       r.vname,r.pid,r.eid, ".
		 "       t.isvirtnode,t.isremotenode,t.isplabdslice ".
		 " from nodes as n ".
		 "left join reserved as r on n.node_id=r.node_id ".
		 "left join node_types as t on t.type=n.type ".
		 "where n.node_id='$node_id'");

if (mysql_num_rows($query_result) == 0) {
    USERERROR("The node $node_id does not exist!", 1);
}

$row = mysql_fetch_array($query_result);
59
60
$jailflag = $row["jailflag"];
$jailip   = $row["jailip"];
Robert Ricci's avatar
Robert Ricci committed
61
$sshdport = $row["sshdport"];
62
63
64
65
66
67
$vname    = $row["vname"];
$pid      = $row["pid"];
$eid      = $row["eid"];
$isvirt   = $row["isvirtnode"];
$isremote = $row["isremotenode"];
$isplab   = $row["isplabdslice"];
68
69
70
71
72
73
74
75
76
77
78
79

if (!isset($pid)) {
    USERERROR("$node_id is not allocated to an experiment!", 1);
}

$filename = $node_id . ".tbrdp"; 
header("Content-Type: text/x-testbed-rdp");
header("Content-Disposition: inline; filename=$filename;");
header("Content-Description: RDP description file for a testbed node");

echo "hostname: $vname.$eid.$pid.$OURDOMAIN\n";
echo "login:    $uid\n";
80
echo "password: $pswd\n";
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106

if ($isvirt) {
    if ($isremote) {
	#
	# Remote nodes run sshd on another port since they so not
	# have per-jail IPs. Of course, might not even be jailed!
	#
	if ($jailflag || $isplab) {
	    echo "port: $sshdport\n";
	}
    }
    else {
	#
	# Local virt nodes are on the private network, so have to
	# bounce through ops node to get there. They run sshd on
	# on the standard port, but on a private IP.
	#
	echo "gateway: $USERNODE\n";
    }
}
elseif ($ELABINELAB) {
    echo "gateway: $USERNODE\n";
}

?>