LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-08-2021, 01:16 PM   #1
kamgas
LQ Newbie
 
Registered: Feb 2021
Posts: 1

Rep: Reputation: Disabled
run X11 application from Firefox (HTML/php) button and display to remote X11.


HI All
I would like to launch a X11 application from Firefox HTML page.
I have
<?php
if (isset($_GET['run']) && $_GET['run'] == 'true') {
//This code will run if ?run=true is set.
echo "begin<br>";
$olddir = getcwd();
putenv('DISPLAY=localhost:12.0');
putenv('XDG_SESSION_ID=6');
putenv('XDG_SESSION_TYPE=tty');
putenv('SSH_CONNECTION=192.168.132.1 65372 192.168.132.132 22');
putenv('XDG_RUNTIME_DIR=/run/user/1000');
putenv('LOGNAME=kamgas');
putenv('XDG_SESSION_CLASS=user');
putenv('USER=kamgas');
putenv('TERM=xterm');
chdir('/var/www/html');
exec(xclock, $output, $status);
chdir($olddir);
var_dump($status);
var_dump($output);
echo '<br>end';
}
?>

<!-- This link will add ?run=true to your URL, myfilename.php?run=true -->
<a href="?run=true">Click Me!</a>

Unfortunately I have the following error
[Mon Feb 08 18:48:18.817970 2021] [php7:warn] [pid 905] [client 127.0.0.1:39156] PHP Warning: Use of undefined constant xclock - assumed 'xclock' (this will throw an Error in a future version of PHP) in /var/www/html/mons.php on line 16, referer: http://localhost/mons.php?run=true
PuTTY X11 proxy: Unsupported authorisation protocol
Error: Can't open display: localhost:12.0

Your help is asked.
Thanks in advance.
 
Old 02-09-2021, 09:46 AM   #2
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Put xlock in quotes so that it is a string.

But it won't work properly or securely.

PHP only runs on the web server and the processes started on the server will be running as the web server.

Trying to start ssh with "192.168.132.1" will not work as this is a non-routable destination.

By default, linux X servers do not open a TCP port - they use domain sockets instead, and those are limited to the local system only - and clients running under a local web server will not have permission to access the correct keys to access the local X server (web servers tend not to run as the same user that is using X.

Thus connections to your local X server will not work.

ssh CAN forward X protocol connections - but that requires the ssh to be running on the workstation as the user also running the X server. At that point the remote system may then run an X application that will have a port provided by the sshd service for the user to use for that purpose. It isn't perfectly secure, but sshd creates unique security requirements before the X protocol is passed.
 
Old 02-10-2021, 01:02 PM   #3
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,342

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
Possibly using vcn (although hopefully only on a trusted LAN or via a vpn tunnel).

I use vcn to manage the desktop on my raspberry pi (ubuntu 20.10) from my fedora 33 daily driver just as if I were at its console.

I also have used zoom with share screen enabled to remotely view and manage a desktop.

In fact my zoom event was zoom from my fedora desktop to the client's windows laptop then via putty to the Ubuntu server. The client shared the putty window and allowed me control where I was able to manage the Ubuntu server.

I am not sure how this would work to do something locally and display it on the remote screen though.

I could see it in zoom with sharing the local screen to the remote screen where either could originate the meeting and one could display the results while retaining control, or could choose to share control. Zoom uses remote servers so security is non-existent in reality.

I am not sure about vcn because the local would have to be the server and the remote would be the viewer. With vcn everything is performed on the server and only displayed on the viewer. Control can be done from either location but cannot be restricted from the viewer. Vcn is reasonably secure if limited to local LAN or vpn tunnel.

Vcn is similar to hosting and managing a VM. Everything is done within the desktop window, except with vcn the managed machine is remote.

Last edited by computersavvy; 02-10-2021 at 01:54 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] /usr/bin/X11/X11/....... 10 X11 subsets & counting walter74 Linux - General 2 06-07-2015 12:36 AM
Embedded PHP in HTML- either PHP ignored or HTML broken vltreude Programming 1 12-10-2012 02:35 AM
swap button 2 and button 3 in xterm and terminal only? senjak Linux - Software 2 09-26-2009 11:34 PM
about xwindow. mouse left button and right button chuangsheng Programming 4 06-13-2009 12:34 AM
Firefox Application Button Ic38 Linux - Software 4 04-04-2004 04:35 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:27 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration