LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Issue with running sudo synaptic (https://www.linuxquestions.org/questions/linux-software-2/issue-with-running-sudo-synaptic-4175615919/)

sdowney717 10-18-2017 12:24 PM

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...

sdowney717 10-18-2017 06:59 PM

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

sdowney717 10-18-2017 07:01 PM

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


frankbell 10-18-2017 08:24 PM

So did that fix it?

sdowney717 10-19-2017 06:00 AM

Quote:

Originally Posted by frankbell (Post 5771487)
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

sdowney717 10-19-2017 07:02 AM

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.


sdowney717 10-19-2017 07:23 AM

1 Attachment(s)
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?

sdowney717 10-19-2017 07:48 AM

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$


sdowney717 10-19-2017 07:57 AM

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


sdowney717 10-19-2017 08:04 AM

I solved it!
Works on boot.
Ubuntu has under system, a startup programs gui.
I added my shell script to the start list.

DVOM 10-20-2017 02:36 PM

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


All times are GMT -5. The time now is 05:35 AM.