Failed to open the X11 Display

Posted:
Mar 29th, '15, 02:46
by linuxdad
Does anyone know why the sudo su - process does not set the Display?
- Code: Select all
[aewhale@localhost ~]$ sudo su -
[root@localhost ~]# VirtualBox
Failed to open the X11 display!
Re: Failed to open the X11 Display

Posted:
Mar 29th, '15, 11:17
by doktor5000
Yes, because since quite some time it strips off some env variables, including DISPLAY.
Either use sudo -E to prevent that or adjust the relevant part of the sudoers:
- Code: Select all
Defaults env_reset
Defaults env_keep = "COLORS DISPLAY HOSTNAME HISTSIZE INPUTRC KDEDIR LS_COLORS"
Defaults env_keep += "MAIL PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE"
Defaults env_keep += "LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES"
Defaults env_keep += "LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE"
Defaults env_keep += "LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET XAUTHORITY"
Re: [Solved] - Failed to open the X11 Display

Posted:
Mar 29th, '15, 17:52
by linuxdad
Maybe I was a bit premature?
- Code: Select all
[aewhale@localhost ~]$ sudo -E su -
[root@localhost ~]# VirtualBox
Failed to open the X11 display!
I have not edited the sudoers file, but it has the following anyway.
- Code: Select all
Defaults requiretty
Defaults env_reset
Defaults env_keep = "COLORS DISPLAY HOSTNAME HISTSIZE INPUTRC KDEDIR LS_COLORS"
Defaults env_keep += "MAIL PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE"
Defaults env_keep += "LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES"
Defaults env_keep += "LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE"
Defaults env_keep += "LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET XAUTHORITY"
Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin
Re: Failed to open the X11 Display

Posted:
Mar 29th, '15, 18:32
by doktor5000
You should probably use
- Code: Select all
sudo -E VirtualBox
- as doing su - and using sudo -E at the sime time goes for two things at the same time ...
Apart from that, what are you actually trying to achieve by running VirtualBox as root?
Re: Failed to open the X11 Display

Posted:
Mar 29th, '15, 19:07
by linuxdad
So, that is a good question. Normally I am used to restricting access to everything, unlees you have root. Permitting a generic user to run VirtualBox is an interesting concept, and also begs the question, why?
So any unsuspecting user can get access tot he server, login and now create VMs with the intent of .... Do you see my point?
So I like the added benefit of security.
BTW, if the environment variables are already within the /etc/sudoers file, why dont the Environment parameters follow when you perform a sudo su -? (I have not had this issue on other flavors of *nix).
Re: Failed to open the X11 Display

Posted:
Mar 29th, '15, 21:12
by doktor5000
Hmmm, just tried either way, with sudo -E, without -E and with only su - and DISPLAY was always set and VirtualBox always launched.
So not sure what differs in your setup so that it doesn't work for you.