LinuxMint – Why package manager failed to start

I haven’t used my Linux Mint maya for about half year.  Today I logged in,  did a system update with the following command:

sudo apt-get update
sudo apt-get dist-upgrade
sudo reboot

Then when I logged in again and tried to remove the old kernels with the Package Manager, it just died after prompting me for the password, without saying a word. That’s quite rude. I tried other application that may require root privilege like Login Window and Update Manager, they won’t start too!

So, what’s the problem? Why they all didn’t work? I need to get more diagnostic message.

First, find out what command will be executed when we click the  Package Manager menu

Package Manager

Click the menu, when it prompt me for the password, I just press Ctrl+Alt+F1 to switch to another tty, run

ps -ejfH | grep [s]ynaptic
curu      6285  4070  4055  4055  2 23:01 ?        00:00:00     gksu /usr/sbin/synaptic
root      6286  6285  6286  6286  0 23:01 ?        00:00:00       /usr/bin/sudo -H -S -p GNOME_SUDO_PASS -u root -- /usr/sbin/synaptic

Now that we got the final command, run it with debug on:

gksu -d /usr/sbin/synaptic
xauth: /tmp/libgksu-paLvKO/.Xauthority
STARTUP_ID: gksu/|usr|sbin|synaptic/23259-0-linuxplayer_TIME13218554
cmd[0]: /usr/bin/sudo
cmd[1]: -H
cmd[2]: -S
cmd[3]: -p
cmd[4]: GNOME_SUDO_PASS
cmd[5]: -u
cmd[6]: root
cmd[7]: --
cmd[8]: /usr/sbin/synaptic
buffer: -GNOME_SUDO_PASS-
brute force GNOME_SUDO_PASS ended...
Yeah, we're in...
xauth: /tmp/libgksu-paLvKO/.Xauthority
xauth_env: /home/curu/.Xauthority
dir: /tmp/libgksu-paLvKO

From the output, we know that gksu setup xauth thing, then start synaptic with sudo. I am sure that the sudo privilege is OK, so why couldn’t gksu start synaptic?  Forget it! Why not just start a very very simple X application to test?

We can show a simple dialog box with this command

zenity --info --text test

test_dialog

Create the script /tmp/t.sh:

#!/bin/bash
set > /tmp/test.log
zenity --info --text test

Run with gksu

gksu -d /tmp/t.sh 
No ask_pass set, using default!
xauth: /tmp/libgksu-ownhJm/.Xauthority
STARTUP_ID: gksu/|tmp|t.sh/23501-0-linuxplayer_TIME14345711
cmd[0]: /usr/bin/sudo
cmd[1]: -H
cmd[2]: -S
cmd[3]: -p
cmd[4]: GNOME_SUDO_PASS
cmd[5]: -u
cmd[6]: root
cmd[7]: --
cmd[8]: /tmp/t.sh
buffer: -GNOME_SUDO_PASS-
brute force GNOME_SUDO_PASS ended...
Yeah, we're in...
xauth: /tmp/libgksu-ownhJm/.Xauthority
xauth_env: /home/curu/.Xauthority
dir: /tmp/libgksu-ownhJm

What’s the shit! that simple dialog box didn’t show too! check the log file /tmp/test.log where I put the environment variables. To my suprise, the DISPLAY variable was not set! For any X graphic application, if there’s no DISPLAY(DISPLAY environment variable not set), there will be no display.

So, where has the $DISPLAY variable gone? The X terminal must have set it, we can verify that:

curu@linuxplayer ~ $ echo $DISPLAY 
:0
curu@linuxplayer ~ $

I know that sudo may clear some environment variable, take a look at the sudoers file:

Defaults        env_reset
Defaults env_keep = "http_proxy https_proxy ftp_proxy"

Well, seems the $DISPLAY variable was not kept after sudo, let me add it

Defaults env_keep = "http_proxy https_proxy ftp_proxy DISPLAY"

Run gksu again, the dialog appears like a magic! And all other broken graphic application that require root privilege worked too!

PS:
gksu can run in two different Authentication mode, su and sudo, we can change the behavior with the gksu-properties command. If the mode is set to “sudo“, whenever you call gksu to run a command, it will run it with sudo by default, and you need to edit sudoers file to keep the $DISPLAY environment variable.

Update:
There are two ways to run application as another user in gnome desktop environment, gksu vs  pkexec . In fact, there are two menu to run  Package Manager  on maya mate, the one in the System category use gksu  whereas the one in the Administration category use pkexec, so you may find that the latter if OK when the former is broken. pkexec use polkit and the default configuration works well.two package manager

This entry was posted in Linux Desktop and tagged , , , , , . Bookmark the permalink.

2 Responses to LinuxMint – Why package manager failed to start

  1. Violet says:

    Hi there,
    I’ve got the same problem. Software manager won’t run. Package Manager won’t run. Parts of Control Center won’t run. But I don’t have the same level of skills you have…

    My terminal does not recognize the command “Default”. It suggests that I install the package gnustep-base-runtime, but “the package lists or status file could not be parsed or opened.”

    Thanks in advance for any assistance you can provide!

    Violet

  2. Violet says:

    Sorry, I made a typo. The program not recognized is “Defaults”.

Leave a Reply