You are not logged in.

#1 2009-02-22 06:50:26

flynn
Member
Registered: 2009-02-22
Posts: 5

invalid magic cookie

I just installed arch and kde. Everything was fine until I noticed that after I run vim as root I get weird errors. More specifically the error is:

Invalid MIT-MAGIC-COOKIE-1 keyInvalid MIT-MAGIC-COOKIE-1 keyInvalid MIT-MAGIC-COOKIE-1 key

It's not preventing me from doing anything, but it's annoying nonetheless. Does anyone know how to fix this?

Offline

#2 2009-02-22 12:39:47

dschrute
Member
From: NJ, USA
Registered: 2007-04-09
Posts: 183

Re: invalid magic cookie

Do you have gvim installed ? If it is installed, and you don't use the Gui for vim, remove the gvim package and see if the messages still display.

Offline

#3 2009-02-22 14:25:22

flynn
Member
Registered: 2009-02-22
Posts: 5

Re: invalid magic cookie

No I did not have gvim installed. I installed it to see if it would have the same problem and this is the error it gave when I tried to start gvim as root:

Invalid MIT-MAGIC-COOKIE-1 keyE233: cannot open displayInvalid MIT-MAGIC-COOKIE-1 keyInvalid MIT-MAGIC-COOKIE-1 keyInvalid MIT-MAGIC-COOKIE-1 key                                                                           
Press ENTER or type command to continue

At which point I would get thrown into regular console vim. Gvim worked fine under a regular account. I uninstalled it and the original problem persists.

Offline

#4 2009-02-22 14:45:44

ghostHack
Member
From: Bristol UK
Registered: 2008-02-29
Posts: 261

Re: invalid magic cookie

whats the value of the $DISPLAY variable for root when you run vim? is it the same as for you regular user? (the one that's running the X session)

Offline

#5 2009-02-22 16:31:04

flynn
Member
Registered: 2009-02-22
Posts: 5

Re: invalid magic cookie

echoing $DISPLAY gave ":0.0" for both regular user and root.

Fooling around I noticed that if I overwrite /root/.Xauthority with my regular user's ~/.Xauthority the problem goes away, but comes back after reboot. I have an old laptop running arch and Xfce, the /root/.Xauthority file on there is blank and everything works fine with no warnings or errors. If I just have a blank /root/.Xauthority on this machine, instead of getting the magic cookie errors I instead get this:

No protocol specified
No protocol specified
No protocol specified

My guess is there is a security setting somewhere that I can change to not require a valid .Xauthority for root, but I don't know where that is.

Offline

#6 2009-06-22 13:53:55

onguarde
Member
Registered: 2008-09-14
Posts: 144

Re: invalid magic cookie

Having the exact same problem here... uninstalled gvim to no avail.

echoing $DISPLAY gave ":0.0" for both regular user and root.

doing a

xhost +

as per the suggestion on the website below as user makes the error dissappear.
http://forums.opensuse.org/install-boot … -help.html

Not entirely sure what it does though.

Last edited by onguarde (2009-06-22 14:00:00)

Offline

#7 2009-06-22 20:53:42

parintachin
Member
Registered: 2009-05-25
Posts: 72

Re: invalid magic cookie

you should ditch xhost (xhost is dangerous security-wise) and just use kdesu programm-of-choice if you need a programm with root-priviliges or gksu wich does the same

Offline

#8 2010-04-04 17:28:20

Mahara
Member
From: ::1
Registered: 2010-03-28
Posts: 6
Website

Re: invalid magic cookie

The method posted by @onguarde is NOT recommened as Access  is  granted  to  everyone,  even  if they aren't on the list to open windows on your machine.

As normal user, you should run:

xhost local:root

and then root will be able to open X programs. You can edit /root/.bashrc and add the following line:

export XAUTHORITY=/home/username/.Xauthority

Where "username" is the user account name that you use. After editing /root/.bashrc, you won't have to issue the command "xhost local:root" anymore after X starts.

OR even simpler, make a symbolic link to the current - correct - cookie (not tested this but I think it might work):

su -
cd /root (if not already there)
ln -sf /home/username/.Xauthority

But as @parintachin said is better to run GUI programs with root privileges using ALT+F2 and kdesu(if using KDE) or gksu(if using GNOME) + name of the application.

I know this thread is a little bit old, but I faced this problem today and wanted to help in some way or another.

Last edited by Mahara (2010-04-05 12:00:29)

Offline

#9 2011-06-04 20:18:53

ondoheer
Member
From: Lima
Registered: 2011-03-13
Posts: 16

Re: invalid magic cookie

Thank you Mahara, your solution did it for me, everything was running fine in my system until I decided to try KDE 4.6 and Gnome 3, I don't know which of the enviroments messed it for me but now everything is fine.

Thanks a lot!


Archlinux KDE user.

Offline

#10 2011-06-04 22:31:30

heleos
Member
From: Maine, USA
Registered: 2007-04-24
Posts: 678

Re: invalid magic cookie

Please mark your thread as solved wink

Offline

#11 2011-09-19 20:32:18

dbbolton
Member
Registered: 2008-10-08
Posts: 41

Re: invalid magic cookie

I had this problem in Debian because 'vim' was ultimately a symbolic link to 'vim.gtk' instead of 'vim.basic', and the solution was to run

update-alternatives --config vim 

I found this thread  while searching for the MIT cookie error, so I am posting this here in case other Debian users happen upon it like I did.

Offline

Board footer

Powered by FluxBB