From cc6e1729dcd8989346e8ec1a76e049ae9283bb46 Mon Sep 17 00:00:00 2001 From: Hugo Levy-Falk Date: Sun, 8 Sep 2019 13:41:00 +0200 Subject: [PATCH 1/4] Use django-ldapdb 1.3.0 --- apt_requirements.txt | 1 + pip_requirements.txt | 1 - users/migrations/0022_ldapuser_sambasid.py | 19 ++++++--- users/migrations/0028_auto_20160726_0227.py | 37 ++++++++++------- users/migrations/0034_auto_20161018_0037.py | 15 +++++-- .../migrations/0052_ldapuser_shadowexpire.py | 15 +++++-- users/migrations/0082_auto_20190908_1338.py | 40 +++++++++++++++++++ 7 files changed, 99 insertions(+), 29 deletions(-) create mode 100644 users/migrations/0082_auto_20190908_1338.py diff --git a/apt_requirements.txt b/apt_requirements.txt index ac967131..1087e1fe 100644 --- a/apt_requirements.txt +++ b/apt_requirements.txt @@ -19,3 +19,4 @@ fonts-font-awesome graphviz git gettext +python3-django-ldapdb diff --git a/pip_requirements.txt b/pip_requirements.txt index 0960c796..b187b42b 100644 --- a/pip_requirements.txt +++ b/pip_requirements.txt @@ -1,3 +1,2 @@ django-bootstrap3 -django-ldapdb==0.9.0 django-macaddress diff --git a/users/migrations/0022_ldapuser_sambasid.py b/users/migrations/0022_ldapuser_sambasid.py index 4bee551f..d22a805d 100644 --- a/users/migrations/0022_ldapuser_sambasid.py +++ b/users/migrations/0022_ldapuser_sambasid.py @@ -34,10 +34,17 @@ class Migration(migrations.Migration): ] operations = [ - migrations.AddField( - model_name='ldapuser', - name='sambaSID', - field=ldapdb.models.fields.IntegerField(db_column='sambaSID', unique=True, null=True), - preserve_default=False, - ), + migrations.SeparateDatabaseAndState( + state_operations=[ + migrations.AddField( + model_name='ldapuser', + name='sambaSID', + field=ldapdb.models.fields.IntegerField(db_column='sambaSID', unique=True, null=True), + preserve_default=False, + ), + ], + database_operations=[ + migrations.RunSQL('ALTER TABLE `users_ldapuser` ADD COLUMN `sambaSID` integer NULL UNIQUE;'), + ], + ) ] diff --git a/users/migrations/0028_auto_20160726_0227.py b/users/migrations/0028_auto_20160726_0227.py index b0ae36f0..91c9ae07 100644 --- a/users/migrations/0028_auto_20160726_0227.py +++ b/users/migrations/0028_auto_20160726_0227.py @@ -35,26 +35,35 @@ class Migration(migrations.Migration): ] operations = [ - migrations.AddField( - model_name='ldapuser', - name='display_name', - field=ldapdb.models.fields.CharField(null=True, blank=True, max_length=200, db_column='displayName'), + migrations.SeparateDatabaseAndState( + state_operations=[ + migrations.AddField( + model_name='ldapuser', + name='display_name', + field=ldapdb.models.fields.CharField(null=True, blank=True, max_length=200, db_column='displayName'), + ), + migrations.AddField( + model_name='ldapuser', + name='sambat_nt_password', + field=ldapdb.models.fields.CharField(null=True, blank=True, max_length=200, db_column='sambaNTPassword'), + ), + migrations.AddField( + model_name='ldapuser', + name='user_password', + field=ldapdb.models.fields.CharField(null=True, blank=True, max_length=200, db_column='userPassword'), + ), + ], + database_operations=[ + migrations.RunSQL('ALTER TABLE `users_ldapuser` ADD COLUMN `displayName` varchar(200) NULL;'), + migrations.RunSQL('ALTER TABLE `users_ldapuser` ADD COLUMN `sambaNTPassword` varchar(200) NULL;'), + migrations.RunSQL('ALTER TABLE `users_ldapuser` ADD COLUMN `userPassword` varchar(200) NULL;'), + ] ), migrations.AddField( model_name='ldapuser', name='macs', field=ldapdb.models.fields.ListField(null=True, blank=True, max_length=200, db_column='radiusCallingStationId'), ), - migrations.AddField( - model_name='ldapuser', - name='sambat_nt_password', - field=ldapdb.models.fields.CharField(null=True, blank=True, max_length=200, db_column='sambaNTPassword'), - ), - migrations.AddField( - model_name='ldapuser', - name='user_password', - field=ldapdb.models.fields.CharField(null=True, blank=True, max_length=200, db_column='userPassword'), - ), migrations.AddField( model_name='listright', name='gid', diff --git a/users/migrations/0034_auto_20161018_0037.py b/users/migrations/0034_auto_20161018_0037.py index 2275843b..ee66ec4a 100644 --- a/users/migrations/0034_auto_20161018_0037.py +++ b/users/migrations/0034_auto_20161018_0037.py @@ -36,10 +36,17 @@ class Migration(migrations.Migration): ] operations = [ - migrations.AddField( - model_name='ldapuser', - name='login_shell', - field=ldapdb.models.fields.CharField(blank=True, db_column='loginShell', max_length=200, null=True), + migrations.SeparateDatabaseAndState( + state_operations=[ + migrations.AddField( + model_name='ldapuser', + name='login_shell', + field=ldapdb.models.fields.CharField(blank=True, db_column='loginShell', max_length=200, null=True), + ), + ], + database_operations=[ + migrations.RunSQL('ALTER TABLE `users_ldapuser` ADD COLUMN `loginShell` varchar(200) NULL;') + ], ), migrations.AddField( model_name='user', diff --git a/users/migrations/0052_ldapuser_shadowexpire.py b/users/migrations/0052_ldapuser_shadowexpire.py index fa818004..4d3bc43e 100644 --- a/users/migrations/0052_ldapuser_shadowexpire.py +++ b/users/migrations/0052_ldapuser_shadowexpire.py @@ -13,9 +13,16 @@ class Migration(migrations.Migration): ] operations = [ - migrations.AddField( - model_name='ldapuser', - name='shadowexpire', - field=ldapdb.models.fields.CharField(blank=True, db_column='shadowExpire', max_length=200, null=True), + migrations.SeparateDatabaseAndState( + state_operations=[ + migrations.AddField( + model_name='ldapuser', + name='shadowexpire', + field=ldapdb.models.fields.CharField(blank=True, db_column='shadowExpire', max_length=200, null=True), + ), + ], + database_operations=[ + migrations.RunSQL('ALTER TABLE `users_ldapuser` ADD COLUMN `shadowExpire` varchar(200) NULL;'), + ] ), ] diff --git a/users/migrations/0082_auto_20190908_1338.py b/users/migrations/0082_auto_20190908_1338.py new file mode 100644 index 00000000..fbc85d60 --- /dev/null +++ b/users/migrations/0082_auto_20190908_1338.py @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.23 on 2019-09-08 11:38 +from __future__ import unicode_literals + +from django.db import migrations +import ldapdb.models.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0081_auto_20190317_0302'), + ] + + operations = [ + migrations.SeparateDatabaseAndState( + state_operations=[ + migrations.AlterField( + model_name='ldapserviceuser', + name='dn', + field=ldapdb.models.fields.CharField(max_length=200, primary_key=True, serialize=False), + ), + migrations.AlterField( + model_name='ldapserviceusergroup', + name='dn', + field=ldapdb.models.fields.CharField(max_length=200, primary_key=True, serialize=False), + ), + migrations.AlterField( + model_name='ldapuser', + name='dn', + field=ldapdb.models.fields.CharField(max_length=200, primary_key=True, serialize=False), + ), + migrations.AlterField( + model_name='ldapusergroup', + name='dn', + field=ldapdb.models.fields.CharField(max_length=200, primary_key=True, serialize=False), + ), + ] + ) + ] From 61ac9c558c634209f5355f97d5e946061629a8fb Mon Sep 17 00:00:00 2001 From: Hugo Levy-Falk Date: Sun, 8 Sep 2019 14:37:05 +0200 Subject: [PATCH 2/4] Fix SQL commands for Postgres --- users/migrations/0022_ldapuser_sambasid.py | 2 +- users/migrations/0028_auto_20160726_0227.py | 6 +++--- users/migrations/0034_auto_20161018_0037.py | 2 +- users/migrations/0052_ldapuser_shadowexpire.py | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/users/migrations/0022_ldapuser_sambasid.py b/users/migrations/0022_ldapuser_sambasid.py index d22a805d..9f9d6521 100644 --- a/users/migrations/0022_ldapuser_sambasid.py +++ b/users/migrations/0022_ldapuser_sambasid.py @@ -44,7 +44,7 @@ class Migration(migrations.Migration): ), ], database_operations=[ - migrations.RunSQL('ALTER TABLE `users_ldapuser` ADD COLUMN `sambaSID` integer NULL UNIQUE;'), + migrations.RunSQL('ALTER TABLE "users_ldapuser" ADD COLUMN "sambaSID" integer NULL UNIQUE;'), ], ) ] diff --git a/users/migrations/0028_auto_20160726_0227.py b/users/migrations/0028_auto_20160726_0227.py index 91c9ae07..8ff41d49 100644 --- a/users/migrations/0028_auto_20160726_0227.py +++ b/users/migrations/0028_auto_20160726_0227.py @@ -54,9 +54,9 @@ class Migration(migrations.Migration): ), ], database_operations=[ - migrations.RunSQL('ALTER TABLE `users_ldapuser` ADD COLUMN `displayName` varchar(200) NULL;'), - migrations.RunSQL('ALTER TABLE `users_ldapuser` ADD COLUMN `sambaNTPassword` varchar(200) NULL;'), - migrations.RunSQL('ALTER TABLE `users_ldapuser` ADD COLUMN `userPassword` varchar(200) NULL;'), + migrations.RunSQL('ALTER TABLE "users_ldapuser" ADD COLUMN "displayName" varchar(200) NULL;'), + migrations.RunSQL('ALTER TABLE "users_ldapuser" ADD COLUMN "sambaNTPassword" varchar(200) NULL;'), + migrations.RunSQL('ALTER TABLE "users_ldapuser" ADD COLUMN "userPassword" varchar(200) NULL;'), ] ), migrations.AddField( diff --git a/users/migrations/0034_auto_20161018_0037.py b/users/migrations/0034_auto_20161018_0037.py index ee66ec4a..0e3519c1 100644 --- a/users/migrations/0034_auto_20161018_0037.py +++ b/users/migrations/0034_auto_20161018_0037.py @@ -45,7 +45,7 @@ class Migration(migrations.Migration): ), ], database_operations=[ - migrations.RunSQL('ALTER TABLE `users_ldapuser` ADD COLUMN `loginShell` varchar(200) NULL;') + migrations.RunSQL('ALTER TABLE "users_ldapuser" ADD COLUMN "loginShell" varchar(200) NULL;') ], ), migrations.AddField( diff --git a/users/migrations/0052_ldapuser_shadowexpire.py b/users/migrations/0052_ldapuser_shadowexpire.py index 4d3bc43e..cbc24781 100644 --- a/users/migrations/0052_ldapuser_shadowexpire.py +++ b/users/migrations/0052_ldapuser_shadowexpire.py @@ -22,7 +22,7 @@ class Migration(migrations.Migration): ), ], database_operations=[ - migrations.RunSQL('ALTER TABLE `users_ldapuser` ADD COLUMN `shadowExpire` varchar(200) NULL;'), + migrations.RunSQL('ALTER TABLE "users_ldapuser" ADD COLUMN "shadowExpire" varchar(200) NULL;'), ] ), ] From 8ceb9ccc0cbb31ba06226fec229ffe70f48913df Mon Sep 17 00:00:00 2001 From: Hugo Levy-Falk Date: Sun, 8 Sep 2019 14:59:00 +0200 Subject: [PATCH 3/4] Fix migrations for MySQL --- CHANGELOG.md | 8 ++++++++ install_re2o.sh | 2 +- users/migrations/0028_auto_20160726_0227.py | 6 +++--- users/migrations/0034_auto_20161018_0037.py | 2 +- users/migrations/0052_ldapuser_shadowexpire.py | 2 +- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b3fb3951..4ec2e366 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -187,3 +187,11 @@ OPTIONNAL_APPS = OPTIONNAL_APPS_RE2O + (...,...,) ``` Don't forget to run migrations afterwards. + +## MR 433 : upgrade django-ldapdb to 1.3.0 + +If you use MySQL, please run + +``` +SET GLOBAL SQL_MODE=ANSI_QUOTES; +``` diff --git a/install_re2o.sh b/install_re2o.sh index 49c34dc9..b8a8c87d 100755 --- a/install_re2o.sh +++ b/install_re2o.sh @@ -109,7 +109,7 @@ install_database() { mysql_command="CREATE DATABASE $db_name collate='utf8_general_ci'; CREATE USER '$username'@'localhost' IDENTIFIED BY '$password'; GRANT ALL PRIVILEGES ON $db_name.* TO '$username'@'localhost'; - FLUSH PRIVILEGES;" + FLUSH PRIVILEGES;SET GLOBAL SQL_MODE=ANSI_QUOTES;" if [ "$local_setup" == 1 ]; then echo "Setting up local MySQL server ..." diff --git a/users/migrations/0028_auto_20160726_0227.py b/users/migrations/0028_auto_20160726_0227.py index 8ff41d49..9593434d 100644 --- a/users/migrations/0028_auto_20160726_0227.py +++ b/users/migrations/0028_auto_20160726_0227.py @@ -54,9 +54,9 @@ class Migration(migrations.Migration): ), ], database_operations=[ - migrations.RunSQL('ALTER TABLE "users_ldapuser" ADD COLUMN "displayName" varchar(200) NULL;'), - migrations.RunSQL('ALTER TABLE "users_ldapuser" ADD COLUMN "sambaNTPassword" varchar(200) NULL;'), - migrations.RunSQL('ALTER TABLE "users_ldapuser" ADD COLUMN "userPassword" varchar(200) NULL;'), + migrations.RunSQL('ALTER TABLE users_ldapuser ADD COLUMN "displayName" varchar(200) NULL;'), + migrations.RunSQL('ALTER TABLE users_ldapuser ADD COLUMN "sambaNTPassword" varchar(200) NULL;'), + migrations.RunSQL('ALTER TABLE users_ldapuser ADD COLUMN "userPassword" varchar(200) NULL;'), ] ), migrations.AddField( diff --git a/users/migrations/0034_auto_20161018_0037.py b/users/migrations/0034_auto_20161018_0037.py index 0e3519c1..e26e2373 100644 --- a/users/migrations/0034_auto_20161018_0037.py +++ b/users/migrations/0034_auto_20161018_0037.py @@ -45,7 +45,7 @@ class Migration(migrations.Migration): ), ], database_operations=[ - migrations.RunSQL('ALTER TABLE "users_ldapuser" ADD COLUMN "loginShell" varchar(200) NULL;') + migrations.RunSQL('ALTER TABLE users_ldapuser ADD COLUMN "loginShell" varchar(200) NULL;') ], ), migrations.AddField( diff --git a/users/migrations/0052_ldapuser_shadowexpire.py b/users/migrations/0052_ldapuser_shadowexpire.py index cbc24781..3948d2c9 100644 --- a/users/migrations/0052_ldapuser_shadowexpire.py +++ b/users/migrations/0052_ldapuser_shadowexpire.py @@ -22,7 +22,7 @@ class Migration(migrations.Migration): ), ], database_operations=[ - migrations.RunSQL('ALTER TABLE "users_ldapuser" ADD COLUMN "shadowExpire" varchar(200) NULL;'), + migrations.RunSQL('ALTER TABLE users_ldapuser ADD COLUMN "shadowExpire" varchar(200) NULL;'), ] ), ] From 5ce0dec5c423b62bf45c9ff616c97feee4eb5206 Mon Sep 17 00:00:00 2001 From: klafyvel Date: Sun, 8 Sep 2019 15:07:28 +0200 Subject: [PATCH 4/4] Update CHANGELOG.md --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ec2e366..ed81b2c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -190,6 +190,14 @@ Don't forget to run migrations afterwards. ## MR 433 : upgrade django-ldapdb to 1.3.0 +Uninstall the existing django-ldapdb installation + + pip3 uninstall django-ldapdb + +Install debian(buster) supported version + + apt install python3-django-ldapdb + If you use MySQL, please run ```