Neutron daemon Pidfile class does not need to not use root_helper

Bug #1218142 reported by Brian Haley
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Fix Released
Medium
Brian Haley

Bug Description

I noticed while writing a daemon that used the daemon Pidfile class that it defaults to using sudo, so not passing rootwrap will generate errors like this:

2013-07-19 17:53:44.512 3111 DEBUG quantum.agent.linux.utils [-] Running command: ['sudo', 'cat', '/proc/23384/cmdline'] execute /usr/lib/python2.7/dist-packages/quantum/agent/linux/utils.py:42
2013-07-19 17:53:44.533 3111 DEBUG quantum.agent.linux.utils [-]
Command: ['sudo', 'cat', '/proc/23384/cmdline']
Exit code: 1
Stdout: ''
Stderr: 'sudo: no tty present and no askpass program specified\nSorry, try again.\nsudo: no tty present and no askpass program specified\nSorry, try again.\nsudo: no tty present and no askpass program specified\nSorry, try again.\nsudo: 3 incorrect password attempts\n' execute /usr/lib/python2.7/dist-packages/quantum/agent/linux/utils.py:59

We actually don't need root priveleges to read /proc/$pid/cmdline, so root_helper can be removed along with the rootwrap filters for it.

Tags: neutron-core
Changed in neutron:
assignee: nobody → Brian Haley (brian-haley)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (master)

Fix proposed to branch: master
Review: https://review.openstack.org/44198

Changed in neutron:
status: New → In Progress
Revision history for this message
Armando Migliaccio (armando-migliaccio) wrote :

If I understand this correctly you get the error because you don't have a nopasswd sudo user, so you'd get the same error with the rootwrapper if it wasn't configured correctly (i.e. you don't have the file /etc/sudoers.d/neutron-rootwrap).

Revision history for this message
Brian Haley (brian-haley) wrote :

Right, I saw the error because I didn't have a nopasswd sudo user creating a daemon.

I found this because I used the metadata-proxy code as a starting point for something else, and it has this code:

class ProxyDaemon(daemon.Daemon):
    def __init__(self, pidfile, port, network_id=None, router_id=None):
        uuid = network_id or router_id
        super(ProxyDaemon, self).__init__(pidfile, uuid=uuid)
        self.network_id = network_id
        self.router_id = router_id
        self.port = port

That super() call actually should have a root_helper= in it, since otherwise when the Daemon class initializes self.pidfile, it will try and use sudo.

I felt removing the use of sudo/root_helper altogther was a better fix since it wasn't needed.

Changed in neutron:
importance: Undecided → Medium
milestone: none → havana-3
tags: added: neutron-core
Changed in neutron:
milestone: havana-3 → havana-rc1
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (master)

Reviewed: https://review.openstack.org/44198
Committed: http://github.com/openstack/neutron/commit/89e38929d2bc626b639df9912a98d24b25a7e964
Submitter: Jenkins
Branch: master

commit 89e38929d2bc626b639df9912a98d24b25a7e964
Author: Brian Haley <email address hidden>
Date: Tue Aug 27 17:36:43 2013 -0400

    Change daemon Pidfile class to not use root_helper

    Some users of the Pidfile class don't specify root_helper,
    which then defaults to 'sudo', which will generate an error.
    Remove root_helper altogether since we actually don't need
    root priveleges to read /proc/$pid/cmdline.

    Changed code to use open.readline() instead of a shell, and
    tweaked tests accordingly.

    Also cleaned-up the rootwrap filters that allow it as they
    are not used anymore.

    Fixes bug 1218142

    Change-Id: I6691feb1c9f7bfa261a7ec464fd8f3f92168c302

Changed in neutron:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in neutron:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in neutron:
milestone: havana-rc1 → 2013.2
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.