trying to launch kate from the browser....

trying to launch kate from the browser....

am 08.01.2010 13:41:06 von Rene Veerman

--0015175cd8be53e379047ca680c5
Content-Type: text/plain; charset=ISO-8859-1

I'm working on a better var_dump (http://mediabeez.ws/htmlMicroscope/,
LGPL), and want to launch my kate editor when i click in the browser on a
line in my trace-log.

I'm trying to exec() this line, but it returns 1 (which is i believe a
general error)

echo "eeeehhh" | sudo -u rene -S /bin/sh -c "export HOME=/home/rene/ && kate
-l 21 -u
/media/500gb/data2/www/htdocs/naaah/maintenance/maintenanceL ogic.php"

if i open a terminal, do

sudo su www-data

and then execute the line above,
then kate actually jumps to the right file, or opens it, etc.

but from the browser, it won't work. exec($str,$o,$r); $r===1.
i could use some help here..

--0015175cd8be53e379047ca680c5--

Re: trying to launch kate from the browser....

am 08.01.2010 13:43:04 von Ashley Sheridan

--=-e6M0uJXksEC6IyD+ytIx
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

On Fri, 2010-01-08 at 13:41 +0100, Rene Veerman wrote:

> I'm working on a better var_dump (http://mediabeez.ws/htmlMicroscope/,
> LGPL), and want to launch my kate editor when i click in the browser on a
> line in my trace-log.
>
> I'm trying to exec() this line, but it returns 1 (which is i believe a
> general error)
>
> echo "eeeehhh" | sudo -u rene -S /bin/sh -c "export HOME=/home/rene/ && kate
> -l 21 -u
> /media/500gb/data2/www/htdocs/naaah/maintenance/maintenanceL ogic.php"
>
> if i open a terminal, do
>
> sudo su www-data
>
> and then execute the line above,
> then kate actually jumps to the right file, or opens it, etc.
>
> but from the browser, it won't work. exec($str,$o,$r); $r===1.
> i could use some help here..


If you click a link in the browser, you can't get it to open up programs
for you on your local machine. The work is done under the user of the
web server, so you won't see Kate open up at all. Kate supports all the
kio slaves, so there may be a protocal you can stream the content down
to kate, and have the link point to the file via this protocol.

Thanks,
Ash
http://www.ashleysheridan.co.uk



--=-e6M0uJXksEC6IyD+ytIx--

Re: trying to launch kate from the browser....

am 08.01.2010 13:43:17 von Rene Veerman

--0015174bec602ec520047ca68897
Content-Type: text/plain; charset=ISO-8859-1

rene@ekster:~$ uname -a
Linux ekster 2.6.31-17-generic #54-Ubuntu SMP Thu Dec 10 16:20:31 UTC 2009
i686 GNU/Linux

rene@ekster:~$ apache2 -v
Server version: Apache/2.2.12 (Ubuntu)
Server built: Nov 12 2009 22:49:46

rene@ekster:~$ php -v
PHP 5.2.10-2ubuntu6.3 with Suhosin-Patch 0.9.7 (cli) (built: Nov 26 2009
14:42:49)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies

rene@ekster:~$ kate -v
Qt: 4.5.2
KDE: 4.3.2 (KDE 4.3.2)
Kate: 3.3.2

--0015174bec602ec520047ca68897--

Re: trying to launch kate from the browser....

am 08.01.2010 13:48:17 von Rene Veerman

--0003255549aa100fc6047ca69a46
Content-Type: text/plain; charset=ISO-8859-1

Thanks for the reply..

I only need this to work locally on the web-server for now..

So i'm calling a script through ajax routines, which would do the exec().
Since it's on the local webserver, that should work, right?

--0003255549aa100fc6047ca69a46--

Re: trying to launch kate from the browser....

am 08.01.2010 13:49:58 von Ashley Sheridan

--=-G6kGQR4kXewd/Zphvpz+
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

On Fri, 2010-01-08 at 13:48 +0100, Rene Veerman wrote:

> Thanks for the reply..
>
> I only need this to work locally on the web-server for now..
>
> So i'm calling a script through ajax routines, which would do the
> exec().
> Since it's on the local webserver, that should work, right?


No, the server is very different from the client, even if they are on
the same machine. I know of no way you can have an HTML link open up
software on your machine. If it were possible, that would open up a
whole world of security issues.

What about making the link something like ftp://localhost/somefile and
have an FTP server set up on the same machine. You could set up your
local machine to respond as you wish to the ftp:// link (might be easier
to configure in Konqueror)

Thanks,
Ash
http://www.ashleysheridan.co.uk



--=-G6kGQR4kXewd/Zphvpz+--

Re: trying to launch kate from the browser....

am 08.01.2010 13:57:14 von Stut

On 8 Jan 2010, at 12:48, Rene Veerman wrote:

> Thanks for the reply..
>=20
> I only need this to work locally on the web-server for now..
>=20
> So i'm calling a script through ajax routines, which would do the =
exec().
> Since it's on the local webserver, that should work, right?

No. When the web server runs a PHP script it has no access to the =
terminal of the logged in user. What you are trying to do is certainly =
possible but won't be easy. An easier way to do it would be to write an =
app and register a URL scheme to open with that app =
(whatever://localhost/filename). That app can then do whatever you need =
it to with the URL which it will get passed as an argument.

-Stuart

--=20
http://stut.net/=

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Fwd: trying to launch kate from the browser....

am 08.01.2010 13:58:48 von Rene Veerman

--000325559a7eacc0d0047ca6bf61
Content-Type: text/plain; charset=ISO-8859-1

---------- Forwarded message ----------
From: Rene Veerman
Date: Fri, Jan 8, 2010 at 1:58 PM
Subject: Re: [PHP] trying to launch kate from the browser....
To: ash@ashleysheridan.co.uk


Yep, i also just thought of using ssh/ftp to remotely edit files.
I can probably configure any web-browser to open certain links with any
local program.

But for now, i'd just like to consider the case where the browser is on the
same machine as the webserver.
In that case, you should (imo) be able to use exec() called with ajax from
the browser to startup apps on that machine.


On Fri, Jan 8, 2010 at 1:49 PM, Ashley Sheridan wrote:

>
> No, the server is very different from the client, even if they are on the
> same machine. I know of no way you can have an HTML link open up software on
> your machine. If it were possible, that would open up a whole world of
> security issues.
>
> What about making the link something like ftp://localhost/somefile and
> have an FTP server set up on the same machine. You could set up your local
> machine to respond as you wish to the ftp:// link (might be easier to
> configure in Konqueror)
>
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>

--000325559a7eacc0d0047ca6bf61--

Re: trying to launch kate from the browser....

am 08.01.2010 14:22:23 von Rene Veerman

--00032555e3eafad0c5047ca7138d
Content-Type: text/plain; charset=ISO-8859-1

oh,

echo "blah" | sudo -u rene -S /bin/sh -c "export HOME=/home/rene/"

exec($str,$o,$r);

$r === 0.

so that works.

therefore, it must be kate itself that refuses to start up from apache's
context.
too bad $o === empty array.

any ideas are most welcome.

--00032555e3eafad0c5047ca7138d--

RE: trying to launch kate from the browser....

am 08.01.2010 14:23:34 von Bob McConnell

From: Rene Veerman
> From: Rene Veerman
>=20
> Yep, i also just thought of using ssh/ftp to remotely edit files.
> I can probably configure any web-browser to open certain links with
any
> local program.
>=20
> But for now, i'd just like to consider the case where the browser is
on the
> same machine as the webserver.
> In that case, you should (imo) be able to use exec() called with ajax
from
> the browser to startup apps on that machine.

> On Fri, Jan 8, 2010 at 1:49 PM, Ashley Sheridan
wrote:
>>
>> No, the server is very different from the client, even if they are on
the
>> same machine. I know of no way you can have an HTML link open up
software on
>> your machine. If it were possible, that would open up a whole world
of
>> security issues.
>>
>> What about making the link something like ftp://localhost/somefile
and
>> have an FTP server set up on the same machine. You could set up your
local
>> machine to respond as you wish to the ftp:// link (might be easier to
>> configure in Konqueror)

You might be able to set kate as a helper app in the browser, but you
still have two problems.

A. How do you map the file path from the web server's docroot to the
real path? i.e. can you translate the URL into a real file path?
B. Does the browser user have access rights to that file/directory?

It's probably easier to set up NetBeans with the debugger. That
combination is designed to do what you are asking for.

Bob McConnell

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: trying to launch kate from the browser....

am 08.01.2010 14:25:53 von Rene Veerman

--00032555acde8082ca047ca7208c
Content-Type: text/plain; charset=ISO-8859-1

$str = ''echo "blah" | sudo -u rene -S /bin/sh -c "export HOME=/home/rene/
&& export"'';
exec($str,$o,$r);

$r === 0.

$o =


array
0 => 'export HOME='/home/rene/''
......more.....


--00032555acde8082ca047ca7208c--

Fwd: trying to launch kate from the browser....

am 08.01.2010 14:34:14 von Rene Veerman

--0015175d0a4c59bb3e047ca73ebd
Content-Type: text/plain; charset=ISO-8859-1

---------- Forwarded message ----------
From: Rene Veerman
Date: Fri, Jan 8, 2010 at 2:29 PM
Subject: Re: [PHP] trying to launch kate from the browser....
To: Bob McConnell


A: str_replace() ;) maybe a preg_replace() but i dont think thats even
necessary.

B: the sudo (see my last mails) is successfull, and i can update the
environment too. so it executes as user rene on the webserver.
the webbrowser just tells the server which of it's own files to kick to the
kate editor.


On Fri, Jan 8, 2010 at 2:23 PM, Bob McConnell wrote:

> You might be able to set kate as a helper app in the browser, but you
> still have two problems.
>
> A. How do you map the file path from the web server's docroot to the
> real path? i.e. can you translate the URL into a real file path?
> B. Does the browser user have access rights to that file/directory?
>
> It's probably easier to set up NetBeans with the debugger. That
> combination is designed to do what you are asking for.
>
>

--0015175d0a4c59bb3e047ca73ebd--

Re: trying to launch kate from the browser....

am 08.01.2010 15:22:56 von Rene Veerman

--00032555929a822a8c047ca7eccf
Content-Type: text/plain; charset=ISO-8859-1

hmm. after a nap i'm gonna try to start the editor directly from the browser
instead, with ssh:// hopefully to get/write the file on the server.

--00032555929a822a8c047ca7eccf--

Re: trying to launch kate from the browser....

am 08.01.2010 17:23:22 von Jochem Maas

Op 1/8/10 1:41 PM, Rene Veerman schreef:
> I'm working on a better var_dump (http://mediabeez.ws/htmlMicroscope/,
> LGPL), and want to launch my kate editor when i click in the browser on a
> line in my trace-log.
>
> I'm trying to exec() this line, but it returns 1 (which is i believe a
> general error)
>
> echo "eeeehhh" | sudo -u rene -S /bin/sh -c "export HOME=/home/rene/ && kate
> -l 21 -u
> /media/500gb/data2/www/htdocs/naaah/maintenance/maintenanceL ogic.php"
>
> if i open a terminal, do
>
> sudo su www-data
>
> and then execute the line above,
> then kate actually jumps to the right file, or opens it, etc.
>
> but from the browser, it won't work. exec($str,$o,$r); $r===1.
> i could use some help here..
>

seems everyone has the wrong idea about what your trying to do. it is possible,
given that your webserver and your browser are running on the machine - if the webserver
manages to start Kate up then you'll see the editor on your screen.

the only problem you *seem* to have is the fact that your webserver doesn't have the
ness. permissions to run the exec command (I'd guess it's specifically related to the fact
that the user apache runs as doesn't have the perms to run sudo, at least not in the context
of your user account) ... try fudging your sudoers file to give the user your apache instance
runs as the perms to run 'sudo kate' as you ... then restart apache (just in case) and see what
happens.



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php