1
|
diff --git a/backend/actions/lib/acls/editor.py b/backend/actions/lib/acls/editor.py
|
2
|
index eebb4d9..2cd1347 100644
|
3
|
--- a/backend/actions/lib/acls/editor.py
|
4
|
+++ b/backend/actions/lib/acls/editor.py
|
5
|
@@ -3,19 +3,65 @@
|
6
|
Module d'édition des acls
|
7
|
"""
|
8
|
from os.path import isdir
|
9
|
+import shlex
|
10
|
from pyeole.process import system_out
|
11
|
|
12
|
+SYSTEM_THRESHOLD = 1000
|
13
|
+
|
14
|
+def getent(db, sys_users=False):
|
15
|
+ """
|
16
|
+ Return getent for user related db
|
17
|
+ :param db: getent db passwd or group
|
18
|
+ :type db: 'passwd' | 'group'
|
19
|
+ :param sys_users: wether to gather system users
|
20
|
+ :type sys_users: boolean
|
21
|
+ """
|
22
|
+ db_list = []
|
23
|
+ if db in ['passwd', 'group']:
|
24
|
+ cmd = shlex.split('getent {0}'.format(db))
|
25
|
+ code, res, err = system_out(cmd)
|
26
|
+ if code == 0:
|
27
|
+ res = [r for r in res.split('\n') if r != '']
|
28
|
+ if sys_users is True:
|
29
|
+ db_list.extend([r.split(':')[0] for r in res])
|
30
|
+ else:
|
31
|
+ db_list.extend([r.split(':')[0] for r in res
|
32
|
+ if int(r.split(':')[2]) >= SYSTEM_THRESHOLD])
|
33
|
+ return db_list
|
34
|
+
|
35
|
+def getent_groups():
|
36
|
+ """
|
37
|
+ Return local groups list
|
38
|
+ """
|
39
|
+ return getent('group')
|
40
|
+
|
41
|
+def getent_users():
|
42
|
+ """
|
43
|
+ Return local users list
|
44
|
+ """
|
45
|
+ return getent('passwd')
|
46
|
+
|
47
|
try:
|
48
|
from horus.backend import get_groups as list_groups
|
49
|
from horus.backend import get_users
|
50
|
module = 'horus'
|
51
|
except ImportError:
|
52
|
- from scribe.eolegroup import Group
|
53
|
- list_groups = Group().get_groups
|
54
|
- from scribe.enseignants import Enseignant
|
55
|
- from scribe.eleves import Eleve
|
56
|
- from scribe.administratifs import Administratif
|
57
|
- module = 'scribe'
|
58
|
+ try:
|
59
|
+ from scribe.eolegroup import Group
|
60
|
+ list_groups = Group().get_groups
|
61
|
+ from scribe.enseignants import Enseignant
|
62
|
+ from scribe.eleves import Eleve
|
63
|
+ from scribe.administratifs import Administratif
|
64
|
+ module = 'scribe'
|
65
|
+ except ImportError:
|
66
|
+ try:
|
67
|
+ from esbl.backend import get_groups as list_groups
|
68
|
+ from esbl.backend import get_users
|
69
|
+ module = 'horus'
|
70
|
+ except ImportError:
|
71
|
+ list_groups = getent_groups
|
72
|
+ get_users = getent_users
|
73
|
+ module = 'horus'
|
74
|
|
75
|
from ead2.backend.actions.lib.widgets import main, form, ajax
|
76
|
from ead2.backend.actions.lib.acls.filesystem import deformat_path_from_html, \
|