Community: Framework mailing list archives

expert-framework@mail.odoo.com

Re: OpenERP v7.0 Database Dump PermissionDenied (BUG?)

by
Pedro M. Baeza
- 12/16/2014 21:09:49
Password for these operations is set In your server conf file. Please check it to see what it is.

Regards.

2014-12-16 23:12 GMT+01:00 Boender, Ferry <f.boender@flusso.nl>:
Hey Elton,

The 'admin' password was one of the first things I tried. It didn't work. After that I checked the configuration for the correct password and used that. I can succesfully create new databases, drop them and perform most other admin tasks. The things that don't work are those actions that call external commands that pass through the _set_pg_password_in_environment() method.

Regards,

Ferry


On Tue, Dec 16, 2014 at 5:09 PM, Elton Myftiu <elton.myftiu@gmail.com> wrote:
Hi,

try (from the gui) to put 'admin' as password. maybe that helps.

br
elton

2014-12-16 16:10 GMT+01:00 Boender, Ferry <f.boender@flusso.nl>:
Hey all,

(First off, I'm no OpenERP/Odoo expert; though I know quite a bit of Python).

I ran into an issue on our OpenERP v7.0 (Ubuntu package v7.0-20130312-002112-1 from http://nightly.openerp.com/7.0/nightly/deb/).

Creating database dumps through the web interface using the database administrator interface has started giving AccessDenied errors. I'm certain we're using the correct password because I create new databases, delete them and change the password through the interface. I'm using the password from the 'admin_passwd' setting from the configuration file.

I've dived into the Python source, and I think I've traced the problem to the following:

  web_services.py
    def exp_dump(self, db_name):
      with self._set_pg_password_in_environment():

The _set_pg_password_in_environment() is defined as (again, stripping some irrelevant stuff):

  def _set_pg_password_in_environment(self):
    """ On Win32, pg_dump (and pg_restore) require that
    :envvar:`PGPASSWORD` be set
    
   This context management method handles setting
    :envvar:`PGPASSWORD` iif win32 and the envvar is not already
    set, and removing it afterwards.
    """
    if os.name != 'nt' or os.environ.get('PGPASSWORD'):
      yield
    else:
       os.environ['PGPASSWORD'] = tools.config['db_password']
       try:
          yield
       finally:
          del os.environ['PGPASSWORD']

The docstring says "if win32 and the envvar is not already set". Yet the code tests whether the OS is not 'nt' OR the environment is not set. Since I'm running on Ubuntu, this never sets the password in the environment. The exp_dump method also doesn't include it in the command it issues (['pg_dump', '--format=c', '--no-owner', '--username=openerp', '--host=localhost', '--port=5432', u'somedbname']) . Looking at another machine that *does* work properly, the line with the "os.name" check doesn't exist and is instead:

  if os.environ.get('PGPASSWORD') or not tools.config['db_password']:

Is my assumption correct that this is a bug in OpenERP, or is there some critical thing I'm not understanding about OpenERP configuration? For now I've "fixed" the issue by creating a .pgpass file in the openerp user's home dir, but that seems like a crude fix.

I'd be grateful if anybody can shine a light on this!

With kind regards,

Ferry

--
Ferry Boender
Consultant
M:06-23292583

Flusso B.V.
Hamersveldseweg 126
3833 GV Leusden
T: 033-4347680 

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-framework-62
Post to: mailto:expert-framework@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-framework-62
Post to: mailto:expert-framework@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe



--
Ferry Boender
Consultant
M:06-23292583

Flusso B.V.
Hamersveldseweg 126
3833 GV Leusden
T: 033-4347680 

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-framework-62
Post to: mailto:expert-framework@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe