8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-22 11:23:10 +00:00

Corrige l'assignation des UID

This commit is contained in:
Gabriel Detraz 2016-10-12 12:24:01 +02:00 committed by root
parent 87c9b21711
commit f6a287c4b8
4 changed files with 49 additions and 6 deletions

View file

@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('machines', '0021_auto_20161006_1943'),
]
operations = [
migrations.AlterField(
model_name='interface',
name='dns',
field=models.CharField(help_text="Obligatoire et unique, doit se terminer par exemple en .rez et ne pas comporter d'autres points", unique=True, max_length=255),
),
]

View file

@ -12,7 +12,7 @@ https://docs.djangoproject.com/en/1.8/ref/settings/
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
from .settings_local import SECRET_KEY, DATABASES, DEBUG, ALLOWED_HOSTS, ASSO_NAME, ASSO_ADDRESS_LINE1, ASSO_ADDRESS_LINE2, ASSO_SIRET, ASSO_EMAIL, ASSO_PHONE, LOGO_PATH, services_urls, REQ_EXPIRE_HRS, REQ_EXPIRE_STR, EMAIL_FROM, SITE_NAME, LDAP, MAIN_EXTENSION, UID_RANGES
from .settings_local import SECRET_KEY, DATABASES, DEBUG, ALLOWED_HOSTS, ASSO_NAME, ASSO_ADDRESS_LINE1, ASSO_ADDRESS_LINE2, ASSO_SIRET, ASSO_EMAIL, ASSO_PHONE, LOGO_PATH, services_urls, REQ_EXPIRE_HRS, REQ_EXPIRE_STR, EMAIL_FROM, SITE_NAME, LDAP, MAIN_EXTENSION, GID_RANGES, UID_RANGES
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

View file

@ -0,0 +1,15 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('users', '0038_user_rezo_rez_uid'),
('users', '0038_auto_20161006_1952'),
]
operations = [
]

View file

@ -8,7 +8,7 @@ from django.dispatch import receiver
import ldapdb.models
import ldapdb.models.fields
from re2o.settings import RIGHTS_LINK, REQ_EXPIRE_HRS, LDAP, UID_RANGES
from re2o.settings import RIGHTS_LINK, REQ_EXPIRE_HRS, LDAP, GID_RANGES,UID_RANGES
import re, uuid
import datetime
@ -42,12 +42,24 @@ def linux_user_validator(login):
params={'label': login},
)
def get_fresh_user_uid():
uids = list(range(int(min(UID_RANGES['users'])),int(max(UID_RANGES['users']))))
used_uids = [ user.uid_number for user in User.objects.all()]
free_uids = [ id for id in uids if id not in used_uids]
return min(free_uids)
def get_fresh_gid():
gids = list(range(int(min(GID_RANGES['posix'])),int(max(GID_RANGES['posix']))))
used_gids = [ right.gid for right in ListRight.objects.all()]
free_gids = [ id for id in gids if id not in used_gids]
return min(free_gids)
def get_admin_right():
try:
admin_right = ListRight.objects.get(listright="admin")
except ListRight.DoesNotExist:
admin_right = ListRight(listright="admin")
admin_right.gid = get_fresh_gid()
admin_right.save()
return admin_right
@ -99,10 +111,7 @@ class User(AbstractBaseUser):
)
def auto_uid():
uids = list(range(int(min(UID_RANGES['users'])),int(max(UID_RANGES['users']))))
used_uids = [ user.id for user in User.objects.all()]
free_uids = [ id for id in uids if id not in used_uids]
return min(free_uids)
return get_fresh_user_uid()
name = models.CharField(max_length=255)
surname = models.CharField(max_length=255)