LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-18-2017, 01:24 PM   #1
sdowney717
Member
 
Registered: Sep 2015
Posts: 447

Rep: Reputation: Disabled
Issue with running sudo synaptic


Got another issue with sudo, have to run this
xhost +si:localuser:root

OR I get errors like this.
Code:
scott@scott-MS-7596:~$ sudo synaptic
[sudo] password for scott: 
No protocol specified
Unable to init server: Could not connect: Connection refused

(synaptic:3193): Gtk-WARNING **: cannot open display: :0
scott@scott-MS-7596:~$ xhost +si:localuser:root
localuser:root being added to access control list
scott@scott-MS-7596:~$ sudo synaptic
I tried gksu synaptic but does nothing.
So how to fix this?
This problem only happened after upgrading to ubuntu 17.10
In the past I always would run sudo gedit, sudo synaptic, etc...
 
Old 10-18-2017, 07:59 PM   #2
sdowney717
Member
 
Registered: Sep 2015
Posts: 447

Original Poster
Rep: Reputation: Disabled
Trying method 2, will it work? I wont know until I reboot.

Code:
Method 2: Globally in /etc/profile
Add the following to /etc/profile

export XAUTHORITY=/home/non-root-usersname/.Xauthority
This will permanently allow root to connect to a non-root user's X server.

Or, merely specify a particular app:

export XAUTHORITY=/home/usersname/.Xauthority kwrite
(to allow root to access kwrite, for instance.)
https://wiki.archlinux.org/index.php...X_apps_as_root
 
Old 10-18-2017, 08:01 PM   #3
sdowney717
Member
 
Registered: Sep 2015
Posts: 447

Original Poster
Rep: Reputation: Disabled
Here is my profile file now, with the added line at bottom

Code:
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).

if [ "${PS1-}" ]; then
  if [ "${BASH-}" ] && [ "$BASH" != "/bin/sh" ]; then
    # The file bash.bashrc already sets the default PS1.
    # PS1='\h:\w\$ '
    if [ -f /etc/bash.bashrc ]; then
      . /etc/bash.bashrc
    fi
  else
    if [ "`id -u`" -eq 0 ]; then
      PS1='# '
    else
      PS1='$ '
    fi
  fi
fi

if [ -d /etc/profile.d ]; then
  for i in /etc/profile.d/*.sh; do
    if [ -r $i ]; then
      . $i
    fi
  done
  unset i
fi

export XAUTHORITY=/home/scott/.Xauthority
 
Old 10-18-2017, 09:24 PM   #4
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 15,873
Blog Entries: 27

Rep: Reputation: 4667Reputation: 4667Reputation: 4667Reputation: 4667Reputation: 4667Reputation: 4667Reputation: 4667Reputation: 4667Reputation: 4667Reputation: 4667Reputation: 4667
So did that fix it?
 
Old 10-19-2017, 07:00 AM   #5
sdowney717
Member
 
Registered: Sep 2015
Posts: 447

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by frankbell View Post
So did that fix it?
unfortunately no, not for method 2.
I rebooted and get the error, they do not want you using gedit with sudo
They deny sudo graphical privileges by design, but there must be a way to override it. This seems to be one of these philosophical things about linux.

Code:
scott@scott-MS-7596:~$ sudo gedit /etc/profile
[sudo] password for scott: 
No protocol specified
Unable to init server: Could not connect: Connection refused

(gedit:1976): Gtk-WARNING **: cannot open display: :0
scott@scott-MS-7596:~$
They also dont want you using synaptic.
Code:
scott@scott-MS-7596:~$ sudo synaptic
No protocol specified
Unable to init server: Could not connect: Connection refused

(synaptic:2675): Gtk-WARNING **: cannot open display: :0
scott@scott-MS-7596:~$
They want you to use graphical userinterfaces designed to work with super user priveleges, like the software center.

I need info on how to use xhost in ubuntu, like here supposed to be able to grant to root x privileges. I tried and does not work. I get same bad host name error.
https://superuser.com/questions/8581...ss-the-display

Last edited by sdowney717; 10-19-2017 at 07:19 AM.
 
Old 10-19-2017, 08:02 AM   #6
sdowney717
Member
 
Registered: Sep 2015
Posts: 447

Original Poster
Rep: Reputation: Disabled
My authorized x users list only shows me.
Which is why this talk of exporting authority to another user I suppose.
Code:
scott@scott-MS-7596:~$ xauth list
scott-P5QC/unix:0  MIT-MAGIC-COOKIE-1  444e63d0c6c28e45032fe7c1db34971e
scott@scott-MS-7596:~$


I have modifed and created files but to no avail.

This did not work, had to make file with nano, still did not work
https://serverfault.com/questions/51...-user-on-linux

Code:
cat <<EOF > /etc/profile.d/xauth.sh
#!/sbin/bash
export XAUTHORITY=~/.Xauthority
EOF
And this did not work

https://unix.stackexchange.com/quest...ocol-specified
Code:
Given that you're on Debian, the simple and supported solution is to arrange for sudo to copy your X11 authorization credentials.  pam_xauth is included in the libpam-modules package for exactly this purpose; to use it, you just need to add

session  optional  pam_xauth.so
to your /etc/pam.d/sudo file. You may also choose to add it to su, too. For full information, consult the pam_xauth man page, of course.

Last edited by sdowney717; 10-19-2017 at 08:04 AM.
 
Old 10-19-2017, 08:23 AM   #7
sdowney717
Member
 
Registered: Sep 2015
Posts: 447

Original Poster
Rep: Reputation: Disabled
I found something that may work, where can I put this script file to have it execute at bootup?

https://askubuntu.com/questions/8778...t-and-xhost-si


Code:

#!/bin/bash
xhost +local:
xhost +si:localuser:root
I put this in file called /etc/rc.local but does not work
Is there some place in ubuntu 17.10 I can put a file to execute at boot?
Maybe the etc/rc.local needs to be set executable?
Attached Thumbnails
Click image for larger version

Name:	xhost.png
Views:	204
Size:	35.2 KB
ID:	26128  

Last edited by sdowney717; 10-19-2017 at 08:32 AM.
 
Old 10-19-2017, 08:48 AM   #8
sdowney717
Member
 
Registered: Sep 2015
Posts: 447

Original Poster
Rep: Reputation: Disabled
I created this shell script.
Code:
#!/bin/bash
xhost +local:
xhost +si:localuser:root

I works when I run it.
How can I run this at boot time?
Code:
scott@scott-MS-7596:~$ ls
boatscrews  Desktop  Documents  Downloads  examples.desktop  Music  Pictures  Public  start_at_boot  Templates  TimeShift-20171016T115522.m2t  Videos
scott@scott-MS-7596:~$ cd start_at_boot
scott@scott-MS-7596:~/start_at_boot$ ls
root_authorize_x.sh
scott@scott-MS-7596:~/start_at_boot$ ./root_authorize_x.sh
non-network local connections being added to access control list
localuser:root being added to access control list
scott@scott-MS-7596:~/start_at_boot$ sudo gedit
scott@scott-MS-7596:~/start_at_boot$
 
Old 10-19-2017, 08:57 AM   #9
sdowney717
Member
 
Registered: Sep 2015
Posts: 447

Original Poster
Rep: Reputation: Disabled
https://stackoverflow.com/questions/...ipt-at-startup

I tried crontab but still no go.

What do you think?
This line is in crontab
Code:
# daemon's notion of time and timezones.
# 
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
# 
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
# 
# For more information see the manual pages of crontab(5) and cron(8)
# 
# m h  dom mon dow   command
@reboot /home/scott/start_at_boot/root_authorize_x.sh
 
Old 10-19-2017, 09:04 AM   #10
sdowney717
Member
 
Registered: Sep 2015
Posts: 447

Original Poster
Rep: Reputation: Disabled
I solved it!
Works on boot.
Ubuntu has under system, a startup programs gui.
I added my shell script to the start list.
 
Old 10-20-2017, 03:36 PM   #11
DVOM
Member
 
Registered: Nov 2010
Posts: 223

Rep: Reputation: 48
Holy cow, I've tried to solve this problem a few times. You are a genius. TYVM
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
install sudo apt-get install synaptic problem help me dear :( zeeshanayub Linux - Newbie 49 10-23-2014 03:55 AM
help :(install sudo apt-get install synaptic problem help me dear :( help me help me zeeshanayub Linux - Newbie 3 10-21-2014 08:02 PM
/etc/hosts modification crapped out sudo, synaptic, anything requiring admin hexter Ubuntu 1 11-30-2005 12:58 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:35 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration