vnc-problem with idle running as sudo on raspberry pi

J

Jean Dubois

I found the following solution to use idle on the raspberry pi
as sudoer (which is necessary or at least comfortable when programming the
GPIO)
1. Open a terminal
2. type cd ~/Desktop
3. type touch idle_as_root
4. type nano idle_as_root
5. type in sudo idle
6. exit nano
7. type in sudo chmod +x idle_as_root
8. Close terminal
9. Double click on the idle_as_root program on your desktop

This all works fine as long as I use X, however
I also want to use it via vnc
For vnc I did the following:
Installed script "tightvncserver" on the RPiwith the following contents:
#!/bin/bash
# /etc/init.d/tightvncserver
VNCUSER='pi'
case "$1" in
start)
# su $VNCUSER -c '/usr/bin/tightvncserver :1'
su -l $VNCUSER -c '/usr/bin/tightvncserver :1'
echo "Starting TightVNC server for $VNCUSER "
;;
stop)
pkill Xtightvnc
echo "Tightvncserver stopped"
;;
*)
echo "Usage: /etc/init.d/tightvncserver {start|stop}"
exit 1
;;
esac
exit 0

sudo chmod 755 /etc/init.d/tightvncserver
sudo update-rc.d tightvncserver defaults

when starting the script manually like this
sudo /etc/init.d/tightvncserver start
everything works as expected i.e. I can click on the idle_as_root-icon and
it works as expected.
If however I reboot the system, the service does start and I do see the
rpi-desktop but clicking the idle_as_root-icon doesn't work. Manually
trying to start it as follows show an error:
pi@raspberrypi ~ $ sudo idle
Client is not authorized to connect to ServerTraceback (most recent call
last):
File "/usr/bin/idle", line 5, in <module>
main()
File "/usr/lib/python2.7/idlelib/PyShell.py", line 1427, in main
root = Tk(className="Idle")
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1712, in __init__
self.tk = _tkinter.create(screenName, baseName, className,
interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: couldn't connect to display ":1.0"


Does someone here have a solution for this problem?
thanks in advance
jean
 
J

Jean Dubois

Op zondag 22 december 2013 14:02:47 UTC+1 schreef Jean Dubois:
I found the following solution to use idle on the raspberry pi
as sudoer (which is necessary or at least comfortable when programming the
GPIO)
1. Open a terminal
2. type cd ~/Desktop
3. type touch idle_as_root
4. type nano idle_as_root
5. type in sudo idle
6. exit nano
7. type in sudo chmod +x idle_as_root
8. Close terminal
9. Double click on the idle_as_root program on your desktop
This all works fine as long as I use X, however
I also want to use it via vnc
For vnc I did the following:
Installed script "tightvncserver" on the RPiwith the following contents:
#!/bin/bash
# /etc/init.d/tightvncserver
VNCUSER='pi'
case "$1" in
start)
# su $VNCUSER -c '/usr/bin/tightvncserver :1'
su -l $VNCUSER -c '/usr/bin/tightvncserver :1'
echo "Starting TightVNC server for $VNCUSER "
;;
stop)
pkill Xtightvnc
echo "Tightvncserver stopped"
;;
*)
echo "Usage: /etc/init.d/tightvncserver {start|stop}"
exit 1
;;
esac
exit 0
sudo chmod 755 /etc/init.d/tightvncserver
sudo update-rc.d tightvncserver defaults
when starting the script manually like this
sudo /etc/init.d/tightvncserver start
everything works as expected i.e. I can click on the idle_as_root-icon and
it works as expected.
I was wrong writing idle_as_root worked this way. As a matter of fact,
this method also does not work as expected, as can be seen from this
message:

X11 connection rejected because of wrong authentication.

New 'X' desktop is raspberrypi:1

Starting applications specified in /home/pi/.vnc/xstartup
Log file is /home/pi/.vnc/raspberrypi:1.log

Starting TightVNC server for pi
 
M

Michael Torrie

I was wrong writing idle_as_root worked this way. As a matter of fact,
this method also does not work as expected, as can be seen from this
message:

X11 connection rejected because of wrong authentication.

New 'X' desktop is raspberrypi:1

Starting applications specified in /home/pi/.vnc/xstartup
Log file is /home/pi/.vnc/raspberrypi:1.log

Starting TightVNC server for pi

In future, I suspect you'll need to take questions like this that don't
really have anything to do with Python to a Raspberry Pi forum or e-mail
list. Or a general Linux list.

Short answer:

Edit /etc/sudoers and add this line somewhere in it (probably near other
lines that look similar):

Defaults env_keep += "DISPLAY XAUTHORITY"

If that doesn't work, then you'll have to talk to folks running the
Rasbian on their Pi. Sometimes XAUTHORITY isn't set.
 
J

Jean Dubois

Op zondag 22 december 2013 18:06:39 UTC+1 schreef Michael Torrie:
In future, I suspect you'll need to take questions like this that don't
really have anything to do with Python to a Raspberry Pi forum or e-mail
list. Or a general Linux list.
Short answer:
Edit /etc/sudoers and add this line somewhere in it (probably near other
lines that look similar):
Defaults env_keep += "DISPLAY XAUTHORITY"
If that doesn't work, then you'll have to talk to folks running the
Rasbian on their Pi. Sometimes XAUTHORITY isn't set.

I thought this would be something python-people are familiar with, after
all idle is a Python IDE and running it as a root sometimes is necessary.
Anyway,
I tried out your suggestion but it didn't work, however googling the line
you suggested brought me close to a solution:
the following command does the trick:
xhost +local:root

unfortunately putting it in ~/.bash_profile doesn't make it work
automatically
after booting, neither does putting it in ~/.xsession, in ~/.xinitrc nor
in an autostart-file in ~/.config/openbox/
putting it in .bashrc does work _after_ opening a terminal which isn't
very nice.

thanks and kind regards,
jean
 
M

Michael Torrie

I thought this would be something python-people are familiar with, after
all idle is a Python IDE and running it as a root sometimes is necessary.

On most desktop distros like Fedora, sudo idle would indeed work.

The fact that it's not working on your pi, means it must be specific to
the distro that your pi is running. And by the way you never mentioned
what distro this is.
Anyway,
I tried out your suggestion but it didn't work, however googling the line
you suggested brought me close to a solution:

The solution likely lies in understanding how MIT-Cookie's work with X11
and how to use xauth.
 
J

Jean Dubois

Op maandag 23 december 2013 16:29:09 UTC+1 schreef Michael Torrie:
On most desktop distros like Fedora, sudo idle would indeed work.

The fact that it's not working on your pi, means it must be specific to
the distro that your pi is running. And by the way you never mentioned
what distro this is.


The solution likely lies in understanding how MIT-Cookie's work with X11
and how to use xauth.
In fact no need for that, changing sudo /usr/bin/idle to gksu /usr/bin/idle
is all is needed to make this work.

kind regards,
jean
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top