Bug 20975 - dnfdragora crashes when started as root
Summary: dnfdragora crashes when started as root
Status: RESOLVED INVALID
Alias: None
Product: Mageia
Classification: Unclassified
Component: RPM Packages (show other bugs)
Version: Cauldron
Hardware: All Linux
Priority: Normal normal
Target Milestone: ---
Assignee: Angelo Naselli
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-05-30 01:23 CEST by Morgan Leijström
Modified: 2017-06-01 14:38 CEST (History)
1 user (show)

See Also:
Source RPM: dnfdragora-1.0.1-2.mga6.src.rpm
CVE:
Status comment:


Attachments

Description Morgan Leijström 2017-05-30 01:23:09 CEST
It should either work, or reply that is should not be run as root.

Steps to Reproduce:

# dnfdragora
Traceback (most recent call last):
  File "/usr/bin/dnfdragora", line 47, in <module>
    import dnfdaemon.client
  File "/usr/lib/python3.5/site-packages/dnfdaemon/client/__init__.py", line 192, in <module>
    session = DBus(Gio.bus_get_sync(Gio.BusType.SESSION, None))
GLib.Error: g-io-error-quark: The connection is closed (18)
Morgan Leijström 2017-05-30 01:23:58 CEST

CC: (none) => ngompa13

Neal Gompa 2017-05-30 04:07:07 CEST

Assignee: bugsquad => anaselli

Comment 1 Angelo Naselli 2017-05-30 13:27:56 CEST
hmm have you run it using "su" or "su -"?
Comment 2 Morgan Leijström 2017-05-30 14:00:25 CEST
ah yes... works OK when started in konsole after issuing "su -"
but errs like above if hyphen not used.
"sudo dnfdragora" also works OK.
Comment 3 Angelo Naselli 2017-05-30 14:21:12 CEST
The problem is described here:
session = DBus(Gio.bus_get_sync(Gio.BusType.SESSION, None))

I'm not that expert there, but i think DBUS session is not available for root, that's why you need to run on a "login shell", dnfdragora is not the only one affected by that.

Resolution: (none) => INVALID
Status: NEW => RESOLVED

Comment 4 Neal Gompa 2017-05-30 15:15:43 CEST
Yes. You need to use a login shell that initializes a session, otherwise it doesn't work.
Comment 5 Morgan Leijström 2017-05-30 15:25:18 CEST
That is probably OK then, but could it be made to output some message that dudes like me understand?

I am used to starting mcc after having issued "su" without hyphen
Comment 6 Angelo Naselli 2017-05-30 17:04:16 CEST
I'll check if i can trap the exception properly, but i cannot promise anything
Comment 7 Morgan Leijström 2017-05-30 17:10:50 CEST
Yeah it is not important, but could be beautiful :)
Comment 8 Angelo Naselli 2017-05-30 23:17:18 CEST
Affected line in dnfdaemon.client:
https://github.com/manatools/dnfdaemon/blob/master/python/dnfdaemon/client/__init__.py#L192

i can get an exception when try importing the module, but don't know which so i can print out anything better, but the exception is however thrown, Neal any suggestion?
Comment 9 Angelo Naselli 2017-05-31 22:25:23 CEST
Well i tried to fix it as in
https://github.com/manatools/dnfdragora/commit/06e1806edd92331ebb752dec15cb94a3498ef247

try using this 
https://raw.githubusercontent.com/manatools/dnfdragora/master/bin/dnfdragora
instead of the official /usr/bin/dnfdragora to look if it could be ok for you
(download it from the above URL and run it as "python3 dnfdragora" for instance)
Comment 10 Morgan Leijström 2017-06-01 09:31:26 CEST
bash-4.3$ su
Lösenord: 
[root@svarten Ut]# python3 ./dnfdragora
dnfdaemon client failure [g-io-error-quark: The connection is closed (18)]
Try again using a login shell
[root@svarten Ut]#

So technically it works :)

But could you (to help less shell literate people) extend the message to:

" Try again using a login shell (login with "su -" or use sudo) "
Comment 11 Morgan Leijström 2017-06-01 09:44:26 CEST
It works if i log in using "su -"

But if i log in with "su" like in previous comment, and then try using "su -" it think dnf is blocked: dnfdragora immediately show a pop up message (same is output in shell) and when user click OK it exits: 

dnfdaemon client error occurred:
g-io-error-quark: GDBus.Error:org.baseurl.DnfSystem.LockedError: dnf is locked by another application (36)

So it somehow locks dnf too early? (before deciding if it is OK to run)
Comment 12 Angelo Naselli 2017-06-01 10:55:56 CEST
on comment #11 sorry it works here, are you sure you've done anything else?
Comment 13 Morgan Leijström 2017-06-01 12:10:45 CEST
Test fresh: Even when only started after issuing "su -" the new version locks dnf, but the old version do not::

0. rebooted, logged into plasma, opened Konsole.  In it:

1. log in using "su -"

2. issue "python3 /usr/bin/dnfdragora".  It works OK. close it.

3. again "python3 /usr/bin/dnfdragora".  It works OK. close it.

4. issue "python3 /path/to/new/dnfdragora".  It works OK. close it.

5. again "python3 /path/to/new/dnfdragora", result:

"dnfdaemon client error: g-io-error-quark: GDBus.Error:org.baseurl.DnfSystem.LockedError: dnf is locked by another application (36)"
Comment 14 Angelo Naselli 2017-06-01 12:25:37 CEST
ok, i definitely understood why, the git version is a bit ahead and check also if dnfdragora ui is running before unlocking, the installed one not, so script without other core code does not unlock db.
We wanted to have a better feed back and now we have it, so it works.
Regarding the output string, i'll see, I'm not sure that is the only one error so i can write su -, but I'm not sure it works if you are in a ssh remote session though... if you wanted to test it... you're welcome :)

BTW, to unlcok dbb you can use dnfdragora --exit (of course be aware that db is not really locked by another application)
Comment 15 Morgan Leijström 2017-06-01 12:36:43 CEST
OK thanks :)

Yes "dnfdragora --exit" worked to unlock.

I know it is hard to wite helpful hints that are exaxtly always working...

Someone using ssh have better understanding of shell and can probably help herself.

We casual home systems admins value a tip on "su -"

Note You need to log in before you can comment on or make changes to this bug.