mirror of
https://github.com/webmin/webmin.git
synced 2026-03-20 08:40:24 +00:00
Add config options for width and height
This commit is contained in:
@@ -1 +1,3 @@
|
||||
base_port=555
|
||||
cols=80
|
||||
rows=24
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
base_port=Base port number for Websockets connections,0
|
||||
base_port=Base port number for Websockets connections,0,5
|
||||
cols=Terminal width in characters,0,5
|
||||
rows=Terminal height in characters,0,5
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
#!/usr/local/bin/perl
|
||||
# Show a terminal that is connected to a Websockets server via Webmin proxying
|
||||
# XXX clean up old proxy ports
|
||||
# XXX permissions page
|
||||
# XXX don't grant to new users
|
||||
# XXX ACL to run as remote user
|
||||
# XXX Virtualmin integration?
|
||||
|
||||
BEGIN { push(@INC, ".."); };
|
||||
use WebminCore;
|
||||
&init_config();
|
||||
my %access = &get_module_acl();
|
||||
require './xterm-lib.pl';
|
||||
|
||||
&ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1, 0, undef,
|
||||
"<link rel=stylesheet href=xterm.css>\n".
|
||||
@@ -48,14 +49,23 @@ my $user = $access{'user'};
|
||||
my $tmpdir = &tempname_dir();
|
||||
$ENV{'SESSION_ID'} = $main::session_id;
|
||||
&system_logged("$shellserver_cmd $port $user >$tmpdir/ws-$port.out 2>&1 </dev/null &");
|
||||
sleep(2);
|
||||
sleep(1);
|
||||
|
||||
# Open the terminal
|
||||
print "<center>\n";
|
||||
print &ui_table_start(undef, undef, 2);
|
||||
print &ui_table_row(undef, "<div id=terminal></div>", 2);
|
||||
print &ui_table_end();
|
||||
print "</center>\n";
|
||||
my $url = "wss://".$ENV{'HTTP_HOST'}.$wspath;
|
||||
my $rows = $config{'rows'} || 24;
|
||||
my $cols = $config{'cols'} || 80;
|
||||
print <<EOF;
|
||||
<div id="terminal"></div>
|
||||
<script>
|
||||
var term = new Terminal();
|
||||
var term = new Terminal({
|
||||
rows: $rows,
|
||||
cols: $cols,
|
||||
});
|
||||
term.open(document.getElementById('terminal'));
|
||||
var socket = new WebSocket('$url', 'binary');
|
||||
var attachAddon = new AttachAddon.AttachAddon(socket);
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
index_title=Websockets Shell
|
||||
index_title=Interactive Shell
|
||||
index_cpan=The Perl module <tt>$1</tt> needed to accept Websockets connections is not available, but you can install it automatically using Webmin's <a href='$2'>Perl Modules</a> module.
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
desc=Websockets Shell
|
||||
desc=Interactive Shell
|
||||
name=xterm
|
||||
longdesc=Access the shell on your system without the need for a separate SSH client, using XTerm over Websockets
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
#!/usr/local/bin/perl
|
||||
# Start a websocket server connected to a shell
|
||||
|
||||
BEGIN { push(@INC, ".."); };
|
||||
use WebminCore;
|
||||
require './xterm-lib.pl';
|
||||
|
||||
use Net::WebSocket::Server;
|
||||
&init_config();
|
||||
my ($port, $user) = @ARGV;
|
||||
|
||||
# Switch to the user we're running as
|
||||
@@ -16,6 +15,7 @@ if ($user ne "root" && $<) {
|
||||
|
||||
# Run the user's shell in a sub-process
|
||||
&foreign_require("proc");
|
||||
$ENV{'TERM'} = 'vt100';
|
||||
our ($shellfh, $pid) = &proc::pty_process_exec($uinfo[8]);
|
||||
$pid || die "Failed to run shell $uinfo[8]";
|
||||
print STDERR "shell process is $pid\n";
|
||||
|
||||
7
xterm/xterm-lib.pl
Normal file
7
xterm/xterm-lib.pl
Normal file
@@ -0,0 +1,7 @@
|
||||
# Common functions for the xterm module
|
||||
|
||||
BEGIN { push(@INC, ".."); };
|
||||
use WebminCore;
|
||||
&init_config();
|
||||
our %access = &get_module_acl();
|
||||
|
||||
Reference in New Issue
Block a user