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   
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 19:53:09 UTC 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 14:55:37 UTC
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):

How reproducible:

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
  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
  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 15:13:39 UTC
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 15:17:02 UTC
(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 15:27:51 UTC
weird, I explicitly rejected a patch using XDG_RUNTIME_DIR.

will take a look (low prio now).

Comment 4 Ales Kozumplik 2013-12-17 09:44:16 UTC

Comment 5 Ales Kozumplik 2013-12-17 13:39:50 UTC
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 14:37:43 UTC
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 10:09:46 UTC
dnf-0.4.10-1.fc20 has been submitted as an update for Fedora 20.

Comment 8 Fedora Update System 2014-01-03 08:41:30 UTC
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:
then log in and leave karma (feedback).

Comment 9 Fedora Update System 2014-01-04 19:53:09 UTC
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.