diff --git a/_service b/_service index f0856b7..aa59ca1 100644 --- a/_service +++ b/_service @@ -1,4 +1,4 @@ - - \ No newline at end of file + + diff --git a/get_login_trytond-46.patch b/get_login_trytond-46.patch new file mode 100644 index 0000000..a8eb29a --- /dev/null +++ b/get_login_trytond-46.patch @@ -0,0 +1,48 @@ +diff -ruN a/trytond/res/user.py b/trytond/res/user.py +- --- a/trytond/res/user.py 2018-11-22 09:21:59.077931014 +0000 ++++ b/trytond/res/user.py 2018-11-22 09:21:04.423129737 +0000 +@@ -20,6 +20,7 @@ + from sql.conditionals import Coalesce + from sql.aggregate import Count + from sql.operators import Concat ++from random import randint + + try: + import bcrypt +@@ -542,12 +543,15 @@ + ''' + Return user id if password matches + ''' +- - LoginAttempt = Pool().get('res.user.login.attempt') +- - count = LoginAttempt.count(login) +- - if count > config.getint('session', 'max_attempt', default=5): +- - LoginAttempt.add(login) +- - raise RateLimitException() +- - Transaction().atexit(time.sleep, 2 ** count - 1) ++ login_max_delay = config.getint('session', 'login_max_delay') ++ ++ #Use a random delay (default between 1 and login_max_delay) ++ #If the param is not set, it defaults to 3 ++ ++ if (not login_max_delay) or (login_max_delay < 1): ++ login_max_delay = 3 ++ delay = randint(1,login_max_delay) ++ + for method in config.get( + 'session', 'authentications', default='password').split(','): + try: +@@ -557,10 +561,11 @@ + continue + user_id = func(login, parameters) + if user_id: +- - LoginAttempt.remove(login) + return user_id +- - LoginAttempt.add(login) +- - ++ else: ++ logger.warning('Invalid login from : %s', login) ++ time.sleep(delay) ++ + @classmethod + def _login_password(cls, login, parameters): + if 'password' not in parameters: diff --git a/tryton-server.README.SUSE b/tryton-server.README.SUSE index 9876673..edbf72e 100644 --- a/tryton-server.README.SUSE +++ b/tryton-server.README.SUSE @@ -55,9 +55,16 @@ Preparing the database Tryton uses a Relational Database Management System (RDBMS) to store data. The preferred RDBMS for Tryton is PostgreSQL. -The following steps guide you through the setup: +You have to setup this database manually. Here is a short explanation how to +achieve this. - * Make sure PostgreSQL is running: +We can distinguish two scenarios, to which the following description will reference: + + 1) the database is created manually (recommended for productive environments) + + 2) the database shall be created from the Tryton client (recommended for test) + + * In both cases, make sure PostgreSQL is running: > systemctl status postgresql @@ -131,7 +138,7 @@ Now you are ready to connect with a client, e.g. tryton-client. Creating the database for Tryton -------------------------------- -For manual creation of the database, the following steps are to be performed: +For manual creation of the database, the folowing steps are to be performed: * Creating the database: @@ -149,9 +156,7 @@ For manual creation of the database, the following steps are to be performed: > /usr/bin/trytond-admin -c /etc/tryton/trytond.conf --all -d mydb Note: Use the database name you chose in the previous step (here as default: - mydb). You will be asked for the admin password for this database. - For the first time, log in to the newly initialized database with user 'admin' - and password as set during initialization. + mydb). You will be asked for the admin password for this database. For the first time, log in to the newly initialized database with user admin and password as set during initialization. As result you will have a bare Tryton database with the base modules installed. @@ -180,7 +185,7 @@ sao bases on nodejs, and it comes as separate package. Download and extract tryton-sao into a directory, say /srv/tryton-sao Make sure you have nodejs and git installed: - > zypper install nodejs git phantomjs + > zypper install nodejs git Now change into to installation directory and install sao: > cd /srv/tryton-sao/package @@ -251,4 +256,4 @@ Now, you're finished with the system setup. Please be aware of the following thi This file is based on tryton-server.README.Debian Copyright: 2009-2012 Daniel Baumann - 2011-2014 Mathias Behrle \ No newline at end of file + 2011-2014 Mathias Behrle diff --git a/trytond-4.2.17.tar.gz b/trytond-4.2.17.tar.gz deleted file mode 100644 index bc3e68b..0000000 --- a/trytond-4.2.17.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:5b557a397dcf52e5ff3556f583e3c2fe85fb1e7164a4dc9df6826ad425b0d510 -size 587423 diff --git a/trytond-4.6.11.tar.gz b/trytond-4.6.11.tar.gz new file mode 100644 index 0000000..614f36a --- /dev/null +++ b/trytond-4.6.11.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4f0f0862b001019c06fb3a2ed844dc5640958ffbab30526bb0868b3b73f1f196 +size 610174 diff --git a/trytond.changes b/trytond.changes index bb4cf0e..3060edc 100644 --- a/trytond.changes +++ b/trytond.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Mon Jan 7 16:19:58 UTC 2019 - Axel Braun + +- Version 4.6.11 - cummulated changes: + * trytond_get_login.patch removed (series 4.2) + * get_login_trytond-46.patch added for 4.6 series + * trytond42_psql10.diff removed (not needed for 4.6) + ------------------------------------------------------------------- Mon Dec 10 19:09:03 UTC 2018 - Axel Braun diff --git a/trytond.conf b/trytond.conf index 6b5a505..4613009 100644 --- a/trytond.conf +++ b/trytond.conf @@ -20,14 +20,14 @@ uri = postgresql:/// +# # # PostgreSQL via TCP/IP # (e.g. connecting to a PostgreSQL database running on a remote machine or # by means of md5 authentication. Needs PostgreSQL to be configured to accept # those connections (pg_hba.conf).) -# #uri = postgresql://tryton:tryton@localhost:5432/ -# + # The path to the directory where the Tryton Server stores files. # The server must have write permissions to this directory. # (Internal default: /var/lib/trytond) @@ -84,7 +84,7 @@ listen = [::]:8000 # Settings for the WebDAV network interface # The IP/host and port number of the interface -listen = localhost:8080 +#listen = localhost:8080 [session] # Session settings @@ -92,16 +92,6 @@ listen = localhost:8080 # The time (in seconds) until an inactive session expires #timeout = 3600 -# The server administration password used by the client for -# the execution of database management tasks. It is encrypted -# using using the Unix crypt(3) routine. A password can be -# generated using the following command line (on one line): -# $ python -c 'import getpass,crypt,random,string; \ -# print crypt.crypt(getpass.getpass(), \ -# "".join(random.sample(string.ascii_letters + string.digits, 8)))' -# Example password with 'admin' -#super_pwd = jkUbZGvFNeugk - [email] # Mail settings @@ -135,4 +125,4 @@ listen = localhost:8080 [web] # Path for the web-frontend -#root = /usr/lib/node_modules/tryton-sao +#root = /usr/lib/node-modules/tryton-sao diff --git a/trytond.conf.example b/trytond.conf.example index 5b9dcf5..a1bcb7a 100644 --- a/trytond.conf.example +++ b/trytond.conf.example @@ -15,13 +15,17 @@ # PostgreSQL via Unix domain sockets # (e.g. PostgreSQL database running on the same machine (localhost)) #uri = postgresql://tryton:tryton@/ +# +#Default setting for a local postgres database + +uri = postgresql:/// + # # PostgreSQL via TCP/IP # (e.g. connecting to a PostgreSQL database running on a remote machine or # by means of md5 authentication. Needs PostgreSQL to be configured to accept # those connections (pg_hba.conf).) - -uri = postgresql://tryton:tryton@localhost:5432/ +#uri = postgresql://tryton:tryton@localhost:5432/ # The path to the directory where the Tryton Server stores files. # The server must have write permissions to this directory. @@ -132,4 +136,4 @@ super_pwd = jkUbZGvFNeugk [web] # Path for the web-frontend -#root = /usr/lib/node_modules/tryton-sao +#root = /usr/lib/node-modules/tryton-sao diff --git a/trytond.spec b/trytond.spec index 28f1ab6..94fcf7d 100644 --- a/trytond.spec +++ b/trytond.spec @@ -1,8 +1,8 @@ # # spec file for package trytond # -# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. -# Copyright (c) 2015 - 2018 Dr. Axel Braun +# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2015-2018 Dr. Axel Braun # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,10 +17,10 @@ # -%define majorver 4.2 +%define majorver 4.6 %define base_name tryton Name: trytond -Version: %{majorver}.17 +Version: %{majorver}.11 Release: 0 Summary: An Enterprise Resource Planning (ERP) system @@ -28,28 +28,26 @@ License: GPL-3.0-or-later Group: Productivity/Office/Management Url: http://www.tryton.org/ Source0: http://downloads.tryton.org/%{majorver}/%{name}-%{version}.tar.gz -#Patch0: trytond340.patch Source1: tryton-server.README.SUSE Source2: trytond.conf.example Source3: %{name}.conf Source4: %{name}_log.conf -# GNU Health patch for user login -Patch0: trytond_get_login.patch -Patch1: trytond42_psql10.diff Source20: %{name}.service + +Patch0: get_login_trytond-46.patch + # List of additional build dependencies BuildRequires: fdupes -BuildRequires: postgresql -BuildRequires: postgresql-server BuildRequires: python3-Werkzeug BuildRequires: python3-bcrypt -BuildRequires: python3-lxml +BuildRequires: python3-lxml >= 2.0 BuildRequires: python3-psycopg2 BuildRequires: python3-pydot3 BuildRequires: python3-python-sql BuildRequires: python3-setuptools BuildRequires: python3-wrapt BuildRequires: systemd-rpm-macros +Requires: html2text Requires: libreoffice-pyuno Requires: postgresql-server Requires: python3-Genshi @@ -61,20 +59,16 @@ Requires: python3-dateutil Requires: python3-lxml Requires: python3-mock Requires: python3-polib -Requires: python3-psycopg2 -Requires: python3-python-sql -Requires: python3-relatorio +Requires: python3-psycopg2 >= 2.5.4 +Requires: python3-python-sql >= 0.4 +Requires: python3-relatorio >= 0.7.0 Requires: python3-simpleeval Requires: python3-wrapt Requires: unoconv Requires(pre): /usr/sbin/groupadd Requires(pre): /usr/sbin/useradd -# Post requires update-alternatives to install tool update-alternatives. -#Requires(post): update-alternatives - BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildArch: noarch - %{?systemd_requires} %description @@ -88,8 +82,7 @@ security. %setup -q cp %{S:1} . cp %{S:2} . -%patch0 -p0 -%patch1 -p1 -F2 +%patch0 -p1 %build python3 setup.py build @@ -105,19 +98,24 @@ mkdir -p $RPM_BUILD_ROOT%{_unitdir} install -p -m 644 %{SOURCE20} $RPM_BUILD_ROOT%{_unitdir}/%{name}.service mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/{lib,log}/%{base_name} -%fdupes -s %{buildroot} + +%python_expand %fdupes %{buildroot}%{$python_sitelib} %pre -getent group tryton > /dev/null || %{_sbindir}/groupadd -r tryton + +#Write GH Variable /etc/tryton/gnuhealthrc +cat > /etc/tryton/gnuhealthrc << "EOF" +TRYTON_VERSION=%{version} +EOF + +getent group tryton > /dev/null || %{_sbindir}/groupadd -r tryton || : getent passwd tryton > /dev/null || %{_sbindir}/useradd -r -g tryton \ -d %{_localstatedir}/lib/%{name} -s /sbin/nologin \ - -c 'Tryton ERP' tryton + -c 'Tryton ERP' tryton || : %service_add_pre trytond.service %post %service_add_post trytond.service -# Postgresql 96 is required for tryton series 4.2.x! -#update-alternatives --set postgresql /usr/lib/postgresql96 %preun %service_del_preun trytond.service diff --git a/trytond42_psql10.diff b/trytond42_psql10.diff deleted file mode 100644 index 493a4c5..0000000 --- a/trytond42_psql10.diff +++ /dev/null @@ -1,504 +0,0 @@ -# Copyright (c) 2018 Mathias Behrle -diff --git a/trytond/backend/database.py b/trytond/backend/database.py -index 22567cd61c7683ee88cb0e38c732a3a5ffb6b887..bff64d62fb45d0dbb45de5972375cb76414f1be4 100644 ---- a/trytond/backend/database.py -+++ b/trytond/backend/database.py -@@ -172,3 +172,46 @@ class DatabaseInterface(object): - def has_multirow_insert(self): - 'Return True if database supports multirow insert' - return False -+ -+ @classmethod -+ def has_sequence(cls): -+ "Return if database supports sequence querying and assignation" -+ return False -+ -+ def sequence_exist(self, connection, name): -+ "Return if a sequence exists" -+ if not self.has_sequence(): -+ return -+ raise NotImplementedError -+ -+ def sequence_create( -+ self, connection, name, number_increment=1, start_value=1): -+ "Creates a sequence" -+ if not self.has_sequence(): -+ return -+ raise NotImplementedError -+ -+ def sequence_update( -+ self, connection, name, number_increment=1, start_value=1): -+ "Modifies a sequence" -+ if not self.has_sequence(): -+ return -+ raise NotImplementedError -+ -+ def sequence_rename(self, connection, old_name, new_name): -+ "Renames a sequence" -+ if not self.has_sequence(): -+ return -+ raise NotImplementedError -+ -+ def sequence_delete(self, connection, name): -+ "Removes a sequence" -+ if not self.has_sequence(): -+ return -+ raise NotImplementedError -+ -+ def sequence_next_number(self, connection, name): -+ "Gets the next number of a sequence" -+ if not self.has_sequence(): -+ return -+ raise NotImplementedError -diff --git a/trytond/backend/mysql/table.py b/trytond/backend/mysql/table.py -index bfe6031250787a0ed0d593dd4822ec25bb596b55..c09065f37ccf2c242007e69a44bf111e4e1e8632 100644 ---- a/trytond/backend/mysql/table.py -+++ b/trytond/backend/mysql/table.py -@@ -75,14 +75,6 @@ class TableHandler(TableHandlerInterface): - cursor.execute('ALTER TABLE `%s` RENAME TO `%s`' - % (old_history, new_history)) - -- @staticmethod -- def sequence_exist(sequence_name): -- return True -- -- @staticmethod -- def sequence_rename(old_name, new_name): -- pass -- - def column_exist(self, column_name): - return column_name in self._columns - -diff --git a/trytond/backend/postgresql/database.py b/trytond/backend/postgresql/database.py -index 505973a8785ca5c11889aa757222a9242acb182a..6967b7d28c73d1968b216d57814a604f5af10199 100644 ---- a/trytond/backend/postgresql/database.py -+++ b/trytond/backend/postgresql/database.py -@@ -2,7 +2,6 @@ - # this repository contains the full copyright notices and license terms. - import time - import logging --import re - import os - import urllib - from decimal import Decimal -@@ -34,8 +33,6 @@ __all__ = ['Database', 'DatabaseIntegrityError', 'DatabaseOperationalError'] - - logger = logging.getLogger(__name__) - --RE_VERSION = re.compile(r'\S+ (\d+)\.(\d+)') -- - os.environ['PGTZ'] = os.environ.get('TZ', '') - - -@@ -131,10 +128,11 @@ class Database(DatabaseInterface): - def get_version(self, connection): - if self.name not in self._version_cache: - cursor = connection.cursor() -- cursor.execute('SELECT version()') -+ cursor.execute('SHOW server_version_num') - version, = cursor.fetchone() -- self._version_cache[self.name] = tuple(map(int, -- RE_VERSION.search(version).groups())) -+ major, rest = divmod(int(version), 10000) -+ minor, patch = divmod(rest, 100) -+ self._version_cache[self.name] = (major, minor, patch) - return self._version_cache[self.name] - - @staticmethod -@@ -353,6 +351,80 @@ class Database(DatabaseInterface): - self.put_connection(connection) - return self._search_path - -+ @classmethod -+ def has_sequence(cls): -+ return True -+ -+ def sequence_exist(self, connection, name): -+ cursor = connection.cursor() -+ for schema in self.search_path: -+ cursor.execute('SELECT 1 ' -+ 'FROM information_schema.sequences ' -+ 'WHERE sequence_name = %s AND sequence_schema = %s', -+ (name, schema)) -+ if cursor.rowcount: -+ return True -+ return False -+ -+ def sequence_create( -+ self, connection, name, number_increment=1, start_value=1): -+ cursor = connection.cursor() -+ -+ param = self.flavor.param -+ cursor.execute( -+ 'CREATE SEQUENCE "%s" ' -+ 'INCREMENT BY %s ' -+ 'START WITH %s' -+ % (name, param, param), -+ (number_increment, start_value)) -+ -+ def sequence_update( -+ self, connection, name, number_increment=1, start_value=1): -+ cursor = connection.cursor() -+ param = self.flavor.param -+ cursor.execute( -+ 'ALTER SEQUENCE "%s" ' -+ 'INCREMENT BY %s ' -+ 'RESTART WITH %s' -+ % (name, param, param), -+ (number_increment, start_value)) -+ -+ def sequence_rename(self, connection, old_name, new_name): -+ cursor = connection.cursor() -+ if (self.sequence_exist(connection, old_name) -+ and not self.sequence_exist(connection, new_name)): -+ cursor.execute('ALTER TABLE "%s" RENAME TO "%s"' -+ % (old_name, new_name)) -+ -+ def sequence_delete(self, connection, name): -+ cursor = connection.cursor() -+ cursor.execute('DROP SEQUENCE "%s"' % name) -+ -+ def sequence_next_number(self, connection, name): -+ cursor = connection.cursor() -+ version = self.get_version(connection) -+ if version >= (10, 0): -+ cursor.execute( -+ 'SELECT increment_by ' -+ 'FROM pg_sequences ' -+ 'WHERE sequencename=%s ' -+ % self.flavor.param, -+ (name,)) -+ increment, = cursor.fetchone() -+ cursor.execute( -+ 'SELECT CASE WHEN NOT is_called THEN last_value ' -+ 'ELSE last_value + %s ' -+ 'END ' -+ 'FROM "%s"' % (self.flavor.param, name), -+ (increment,)) -+ else: -+ cursor.execute( -+ 'SELECT CASE WHEN NOT is_called THEN last_value ' -+ 'ELSE last_value + increment_by ' -+ 'END ' -+ 'FROM "%s"' % name) -+ return cursor.fetchone()[0] -+ - register_type(UNICODE) - if PYDATE: - register_type(PYDATE) -diff --git a/trytond/backend/postgresql/table.py b/trytond/backend/postgresql/table.py -index a3323041c98be880cf9053b98589dc78e16265b5..8cae6ca12fcacf5a5cdd924416f26ef0ca7ca7bf 100644 ---- a/trytond/backend/postgresql/table.py -+++ b/trytond/backend/postgresql/table.py -@@ -22,8 +22,10 @@ class TableHandler(TableHandlerInterface): - transaction = Transaction() - cursor = transaction.connection.cursor() - # Create sequence if necessary -- if not self.sequence_exist(self.sequence_name): -- cursor.execute('CREATE SEQUENCE "%s"' % self.sequence_name) -+ if not transaction.database.sequence_exist( -+ transaction.connection, self.sequence_name): -+ transaction.database.sequence_create( -+ transaction.connection, self.sequence_name) - - # Create new table if necessary - if not self.table_exist(self.table_name): -@@ -81,7 +83,8 @@ class TableHandler(TableHandlerInterface): - - @staticmethod - def table_rename(old_name, new_name): -- cursor = Transaction().connection.cursor() -+ transaction = Transaction() -+ cursor = transaction.connection.cursor() - # Rename table - if (TableHandler.table_exist(old_name) - and not TableHandler.table_exist(new_name)): -@@ -90,7 +93,8 @@ class TableHandler(TableHandlerInterface): - # Rename sequence - old_sequence = old_name + '_id_seq' - new_sequence = new_name + '_id_seq' -- TableHandler.sequence_rename(old_sequence, new_sequence) -+ transaction.database.sequence_rename( -+ transaction.connection, old_sequence, new_sequence) - # Rename history table - old_history = old_name + "__history" - new_history = new_name + "__history" -@@ -99,30 +103,6 @@ class TableHandler(TableHandlerInterface): - cursor.execute('ALTER TABLE "%s" RENAME TO "%s"' - % (old_history, new_history)) - -- @classmethod -- def sequence_schema(cls, sequence_name): -- transaction = Transaction() -- cursor = transaction.connection.cursor() -- for schema in transaction.database.search_path: -- cursor.execute('SELECT 1 ' -- 'FROM information_schema.sequences ' -- 'WHERE sequence_name = %s AND sequence_schema = %s', -- (sequence_name, schema)) -- if cursor.rowcount: -- return schema -- -- @classmethod -- def sequence_exist(cls, sequence_name): -- return bool(cls.sequence_schema(sequence_name)) -- -- @staticmethod -- def sequence_rename(old_name, new_name): -- cursor = Transaction().connection.cursor() -- if (TableHandler.sequence_exist(old_name) -- and not TableHandler.sequence_exist(new_name)): -- cursor.execute('ALTER TABLE "%s" RENAME TO "%s"' -- % (old_name, new_name)) -- - def column_exist(self, column_name): - return column_name in self._columns - -diff --git a/trytond/backend/table.py b/trytond/backend/table.py -index 887d415af80a3f69061808797b70621f73c0108d..853c51918e0b918f0aa9ad392eac7d22697990dd 100644 ---- a/trytond/backend/table.py -+++ b/trytond/backend/table.py -@@ -46,26 +46,6 @@ class TableHandlerInterface(object): - ''' - raise NotImplementedError - -- @staticmethod -- def sequence_exist(sequence_name): -- ''' -- Sequence exist -- -- :param sequence_name: the sequence name -- :return: a boolean -- ''' -- raise NotImplementedError -- -- @staticmethod -- def sequence_rename(old_name, new_name): -- ''' -- Rename sequence -- -- :param old_name: the old sequence name -- :param new_name: the new sequence name -- ''' -- raise NotImplementedError -- - def column_exist(self, column_name): - ''' - Column exist -diff --git a/trytond/ir/sequence.py b/trytond/ir/sequence.py -index 21bc3c12ee62990ce91fe675520582e3db8c41a8..f6791cf692fb6f9161d7a8607c01f638a576309d 100644 ---- a/trytond/ir/sequence.py -+++ b/trytond/ir/sequence.py -@@ -3,7 +3,7 @@ - from string import Template - import time - from itertools import izip --from sql import Flavor -+from sql import Literal, For - - from ..model import ModelView, ModelSQL, fields, Check - from ..tools import datetime_strftime -@@ -16,7 +16,7 @@ __all__ = [ - 'SequenceType', 'Sequence', 'SequenceStrict', - ] - --sql_sequence = backend.name() == 'postgresql' -+sql_sequence = backend.get('Database').has_sequence() - - - class SequenceType(ModelSQL, ModelView): -@@ -104,6 +104,7 @@ class Sequence(ModelSQL, ModelView): - def __register__(cls, module_name): - TableHandler = backend.get('TableHandler') - table = TableHandler(cls, module_name) -+ transaction = Transaction() - - # Migration from 2.0 rename number_next into number_next_internal - table.column_rename('number_next', 'number_next_internal') -@@ -116,8 +117,8 @@ class Sequence(ModelSQL, ModelView): - for sequence in sequences: - if sequence.type != 'incremental': - continue -- if not TableHandler.sequence_exist( -- sequence._sql_sequence_name): -+ if not transaction.database.sequence_exist( -+ transaction.connection, sequence._sql_sequence_name): - sequence.create_sql_sequence(sequence.number_next_internal) - - @staticmethod -@@ -159,14 +160,11 @@ class Sequence(ModelSQL, ModelView): - def get_number_next(self, name): - if self.type != 'incremental': - return -- cursor = Transaction().connection.cursor() -- sql_name = self._sql_sequence_name -+ -+ transaction = Transaction() - if sql_sequence and not self._strict: -- cursor.execute('SELECT ' -- 'CASE WHEN NOT is_called THEN last_value ' -- 'ELSE last_value + increment_by ' -- 'END FROM "%s"' % sql_name) -- return cursor.fetchone()[0] -+ return transaction.database.sequence_next_number( -+ transaction.connection, self._sql_sequence_name) - else: - return self.number_next_internal - -@@ -260,22 +258,22 @@ class Sequence(ModelSQL, ModelView): - - def create_sql_sequence(self, number_next=None): - 'Create the SQL sequence' -- cursor = Transaction().connection.cursor() -- param = Flavor.get().param -+ transaction = Transaction() -+ - if self.type != 'incremental': - return - if number_next is None: - number_next = self.number_next -- cursor.execute('CREATE SEQUENCE "' + self._sql_sequence_name -- + '" INCREMENT BY ' + param + ' START WITH ' + param, -- (self.number_increment, number_next)) -+ if sql_sequence: -+ transaction.database.sequence_create(transaction.connection, -+ self._sql_sequence_name, self.number_increment, number_next) - - def update_sql_sequence(self, number_next=None): - 'Update the SQL sequence' -- TableHandler = backend.get('TableHandler') -- cursor = Transaction().connection.cursor() -- param = Flavor.get().param -- exist = TableHandler.sequence_exist(self._sql_sequence_name) -+ transaction = Transaction() -+ -+ exist = transaction.database.sequence_exist( -+ transaction.connection, self._sql_sequence_name) - if self.type != 'incremental': - if exist: - self.delete_sql_sequence() -@@ -285,17 +283,16 @@ class Sequence(ModelSQL, ModelView): - return - if number_next is None: - number_next = self.number_next -- cursor.execute('ALTER SEQUENCE "' + self._sql_sequence_name -- + '" INCREMENT BY ' + param + ' RESTART WITH ' + param, -- (self.number_increment, number_next)) -+ transaction.database.sequence_update(transaction.connection, -+ self._sql_sequence_name, self.number_increment, number_next) - - def delete_sql_sequence(self): - 'Delete the SQL sequence' -- cursor = Transaction().connection.cursor() -+ transaction = Transaction() - if self.type != 'incremental': - return -- cursor.execute('DROP SEQUENCE "%s"' -- % self._sql_sequence_name) -+ transaction.database.sequence_delete( -+ transaction.connection, self._sql_sequence_name) - - @staticmethod - def _process(string, date=None): -diff --git a/trytond/res/ir.py b/trytond/res/ir.py -index 754a6226a6b5e1d7aca4b5575ed8232f9525eb2a..0265c46e4e6857753613a27d6a44575d003c4718 100644 ---- a/trytond/res/ir.py -+++ b/trytond/res/ir.py -@@ -3,6 +3,7 @@ - from ..model import ModelSQL, fields - from .. import backend - from ..pool import Pool, PoolMeta -+from ..transaction import Transaction - - __all__ = [ - 'UIMenuGroup', 'ActionGroup', 'ModelFieldGroup', 'ModelButtonGroup', -@@ -23,10 +24,11 @@ class UIMenuGroup(ModelSQL): - @classmethod - def __register__(cls, module_name): - TableHandler = backend.get('TableHandler') -+ transaction = Transaction() - # Migration from 1.0 table name change - TableHandler.table_rename('ir_ui_menu_group_rel', cls._table) -- TableHandler.sequence_rename('ir_ui_menu_group_rel_id_seq', -- cls._table + '_id_seq') -+ transaction.database.sequence_rename(transaction.connection, -+ 'ir_ui_menu_group_rel_id_seq', cls._table + '_id_seq') - # Migration from 2.0 menu_id and gid renamed into menu group - table = TableHandler(cls, module_name) - table.column_rename('menu_id', 'menu') -@@ -64,10 +66,11 @@ class ActionGroup(ModelSQL): - @classmethod - def __register__(cls, module_name): - TableHandler = backend.get('TableHandler') -+ transaction = Transaction() - # Migration from 1.0 table name change - TableHandler.table_rename('ir_action_group_rel', cls._table) -- TableHandler.sequence_rename('ir_action_group_rel_id_seq', -- cls._table + '_id_seq') -+ transaction.database.sequence_rename(transaction.connection, -+ 'ir_action_group_rel_id_seq', cls._table + '_id_seq') - # Migration from 2.0 action_id and gid renamed into action and group - table = TableHandler(cls, module_name) - table.column_rename('action_id', 'action') -@@ -118,10 +121,12 @@ class ModelFieldGroup(ModelSQL): - @classmethod - def __register__(cls, module_name): - TableHandler = backend.get('TableHandler') -+ database = Transaction().database -+ transaction = Transaction() - # Migration from 1.0 table name change - TableHandler.table_rename('ir_model_field_group_rel', cls._table) -- TableHandler.sequence_rename('ir_model_field_group_rel_id_seq', -- cls._table + '_id_seq') -+ transaction.database.sequence_rename(transaction.connection, -+ 'ir_model_field_group_rel_id_seq', cls._table + '_id_seq') - table = TableHandler(cls, module_name) - # Migration from 2.6: field_id and group_id renamed to field and group - table.column_rename('field_id', 'field') -@@ -176,10 +181,11 @@ class RuleGroupGroup(ModelSQL): - @classmethod - def __register__(cls, module_name): - TableHandler = backend.get('TableHandler') -+ transaction = Transaction() - # Migration from 1.0 table name change - TableHandler.table_rename('group_rule_group_rel', cls._table) -- TableHandler.sequence_rename('group_rule_group_rel_id_seq', -- cls._table + '_id_seq') -+ transaction.database.sequence_rename(transaction.connection, -+ 'group_rule_group_rel_id_seq', cls._table + '_id_seq') - # Migration from 2.0 rule_group_id and group_id renamed into rule_group - # and group - table = TableHandler(cls, module_name) -@@ -199,10 +205,11 @@ class RuleGroupUser(ModelSQL): - @classmethod - def __register__(cls, module_name): - TableHandler = backend.get('TableHandler') -+ transaction = Transaction() - # Migration from 1.0 table name change - TableHandler.table_rename('user_rule_group_rel', cls._table) -- TableHandler.sequence_rename('user_rule_group_rel_id_seq', -- cls._table + '_id_seq') -+ transaction.database.sequence_rename(transaction.connection, -+ 'user_rule_group_rel_id_seq', cls._table + '_id_seq') - # Migration from 2.0 rule_group_id and user_id renamed into rule_group - # and user - table = TableHandler(cls, module_name) -diff --git a/trytond/res/user.py b/trytond/res/user.py -index ac539065b01127b77540c4f3dbdca9b3383d8978..dd13df43b05f9f243d9e1e29573252c0640b7122 100644 ---- a/trytond/res/user.py -+++ b/trytond/res/user.py -@@ -645,10 +645,12 @@ class UserGroup(ModelSQL): - @classmethod - def __register__(cls, module_name): - TableHandler = backend.get('TableHandler') -+ transaction = Transaction() -+ - # Migration from 1.0 table name change - TableHandler.table_rename('res_group_user_rel', cls._table) -- TableHandler.sequence_rename('res_group_user_rel_id_seq', -- cls._table + '_id_seq') -+ transaction.database.sequence_rename(transaction.connection, -+ 'res_group_user_rel_id_seq', cls._table + '_id_seq') - # Migration from 2.0 uid and gid rename into user and group - table = TableHandler(cls, module_name) - table.column_rename('uid', 'user') diff --git a/trytond_get_login.patch b/trytond_get_login.patch deleted file mode 100644 index 0fc9ddc..0000000 --- a/trytond_get_login.patch +++ /dev/null @@ -1,40 +0,0 @@ ---- trytond/res/user.py 2018-02-15 13:09:37.735716404 +0000 -+++ trytond/res/user.py 2018-02-15 22:08:51.966998130 +0000 -@@ -18,6 +18,7 @@ - from sql.conditionals import Coalesce - from sql.aggregate import Count - from sql.operators import Concat -+from random import randint - - try: - import bcrypt -@@ -495,7 +496,16 @@ - Return user id if password matches - ''' - LoginAttempt = Pool().get('res.user.login.attempt') -- time.sleep(2 ** LoginAttempt.count(login) - 1) -+ -+ login_max_delay = config.getint('session', 'login_max_delay') -+ -+ if (not login_max_delay) or (login_max_delay < 1): -+ login_max_delay = 3 -+ -+ #Use a random delay (default between 1 and login_max_delay) in login -+ #if the param is not set, it defaults to 3 -+ delay = randint(1,login_max_delay) -+ time.sleep(delay) - for method in config.get( - 'session', 'authentications', default='password').split(','): - try: -@@ -505,9 +515,9 @@ - continue - user_id = func(login, parameters) - if user_id: -- LoginAttempt.remove(login) - return user_id -- LoginAttempt.add(login) -+ else: -+ logger.info('Invalid login from : %s', login) - - @classmethod - def _login_password(cls, login, parameters): diff --git a/trytond_log.conf b/trytond_log.conf index 54a6fa0..5fabb68 100644 --- a/trytond_log.conf +++ b/trytond_log.conf @@ -7,23 +7,23 @@ [database] [formatters] -keys: simple +keys=simple [handlers] -keys: rotate +keys=rotate [loggers] -keys: root +keys=root [formatter_simple] -format: %(asctime)s] %(levelname)s:%(name)s:%(message)s -datefmt: %a %b %d %H:%M:%S %Y +format=%(asctime)s] %(levelname)s:%(name)s:%(message)s +datefmt=%a %b %d %H:%M:%S %Y [handler_rotate] -class: handlers.TimedRotatingFileHandler -args: ('/var/log/tryton/trytond.log', 'D', 1, 30) -formatter: simple +class=handlers.TimedRotatingFileHandler +args=('/var/log/tryton/trytond.log', 'D', 1, 30) +formatter=simple [logger_root] -level: INFO -handlers: rotate +level=INFO +handlers=rotate