Bugzilla will be upgraded to version 5.0 on a still to be determined date in the near future. The original upgrade date has been delayed.

Bug 1036147

Summary: [locking] Traceback for dnf search if running under su - USER
Product: [Fedora] Fedora Reporter: Jaroslav ┼ákarvada <jskarvad>
Component: dnfAssignee: Ales Kozumplik <akozumpl>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: low    
Version: 20CC: akozumpl, jskarvad, jzeleny, packaging-team-maint, pnemade, rholy
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: dnf-0.4.10-1.fc20 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-01-04 14:53:09 EST Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Description Jaroslav Škarvada 2013-11-29 09:55:37 EST
Description of problem:
Dnf search can cause traceback while running under su - USER. This is probably related to the systemd-logind bug, but dnf shouldn't behave this way. In case it is not possible to workaround this problem, dnf should exit with proper error message.

Version-Release number of selected component (if applicable):
dnf-0.4.8-1.fc20.noarch

How reproducible:
Always

Steps to Reproduce:
1. ssh to the box as root
2. su - USER (regular user)
3. dnf search '*dsd*'

Actual results:
Traceback (most recent call last):
  File "/bin/dnf", line 35, in <module>
    main.user_main(sys.argv[1:], exit_code=True)
  File "/usr/lib/python2.7/site-packages/dnf/cli/main.py", line 279, in user_main
    errcode = main(args)
  File "/usr/lib/python2.7/site-packages/dnf/cli/main.py", line 64, in main
    return _main(base, args)
  File "/usr/lib/python2.7/site-packages/dnf/cli/main.py", line 135, in _main
    result, resultmsgs = cli.run()
  File "/usr/lib/python2.7/site-packages/dnf/cli/cli.py", line 1404, in run
    load_available_repos=lar)
  File "/usr/lib/python2.7/site-packages/dnf/base.py", line 207, in fill_sack
    with dnf.lock.metadata_cache_lock:
  File "/usr/lib/python2.7/site-packages/dnf/lock.py", line 71, in __enter__
    pid = self._read_lock()
  File "/usr/lib/python2.7/site-packages/dnf/lock.py", line 40, in _read_lock
    with open(self._target, 'r') as f:
  File "/usr/lib/python2.7/site-packages/dnf/util.py", line 110, in cached_getter
    val = fn(obj)
  File "/usr/lib/python2.7/site-packages/dnf/lock.py", line 50, in _target
    dnf.util.ensure_dir(user_run_dir)
  File "/usr/lib/python2.7/site-packages/dnf/util.py", line 49, in ensure_dir
    os.makedirs(dname, mode=0o755)
  File "/usr/lib/python2.7/os.py", line 150, in makedirs
    makedirs(head, mode)
  File "/usr/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/run/user/1001'

Expected results:
No traceback, dnf search results or appropriate error message.

Additional info:
Comment 1 Ales Kozumplik 2013-11-29 10:13:39 EST
Jaroslav, what is the fedora release the box is running and can you please link the systemd-logind bug?

Thank you!
Comment 2 Jaroslav Škarvada 2013-11-29 10:17:02 EST
(In reply to Ales Kozumplik from comment #1)
> Jaroslav, what is the fedora release the box is running and can you please
> link the systemd-logind bug?
> 
It is F20 i686, the systemd-logind bug 753882.
Comment 3 Ales Kozumplik 2013-11-29 10:27:51 EST
weird, I explicitly rejected a patch using XDG_RUNTIME_DIR.

will take a look (low prio now).
Comment 4 Ales Kozumplik 2013-12-17 04:44:16 EST
reproduced.
Comment 5 Ales Kozumplik 2013-12-17 08:39:50 EST
Jaroslav, a workaround is to log in with the regular user at least once, systemd then creates the directory through some mechanism. It's probably a flaw in the filesystem hierarchy design that /run/user is not writable by the regular user.
Comment 6 Ales Kozumplik 2013-12-17 09:37:43 EST
dnf handles the traceback gracefully starting with 73d2d46. I got no reply when asking the Plumbers Team how to create the directory manually under scenarios like this.
Comment 7 Fedora Update System 2014-01-02 05:09:46 EST
dnf-0.4.10-1.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/dnf-0.4.10-1.fc20
Comment 8 Fedora Update System 2014-01-03 03:41:30 EST
Package dnf-0.4.10-1.fc20:
* should fix your issue,
* was pushed to the Fedora 20 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing dnf-0.4.10-1.fc20'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2014-0089/dnf-0.4.10-1.fc20
then log in and leave karma (feedback).
Comment 9 Fedora Update System 2014-01-04 14:53:09 EST
dnf-0.4.10-1.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.