summaryrefslogtreecommitdiff
blob: 101d0c77450539196ba92717ffd1e59ea42355aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
diff --git a/pynslcd/Makefile.am b/pynslcd/Makefile.am
index 383dd3c..39a3bfb 100644
--- a/pynslcd/Makefile.am
+++ b/pynslcd/Makefile.am
@@ -19,7 +19,7 @@
 
 pynslcddir = $(datadir)/pynslcd
 
-pynslcd_PYTHON = pynslcd.py attmap.py cache.py cfg.py common.py expr.py \
+pynslcd_PYTHON = main.py attmap.py cache.py cfg.py common.py expr.py \
                  mypidfile.py invalidator.py search.py tio.py \
                  config.py alias.py ether.py group.py host.py netgroup.py \
                  network.py passwd.py protocol.py rpc.py service.py \
@@ -38,6 +38,6 @@ constants.py: constants.py.in $(top_srcdir)/nslcd.h
 # create a symbolic link for the pynslcd daemon and fix permissions
 install-data-hook:
 	$(MKDIR_P) $(DESTDIR)$(sbindir)
-	[ -L $(DESTDIR)$(sbindir)/pynslcd ] || $(LN_S) $(pynslcddir)/pynslcd.py $(DESTDIR)$(sbindir)/pynslcd
-	chmod a+rx $(DESTDIR)$(pynslcddir)/pynslcd.py
-	sed -i -e '1 s|^#!.*|#! $(PYTHON)|;1 s|^#! \([^/].*\)|#! /usr/bin/env \1|' $(DESTDIR)$(pynslcddir)/pynslcd.py
+	[ -L $(DESTDIR)$(sbindir)/pynslcd ] || $(LN_S) $(pynslcddir)/main.py $(DESTDIR)$(sbindir)/pynslcd
+	chmod a+rx $(DESTDIR)$(pynslcddir)/main.py
+	sed -i -e '1 s|^#!.*|#! $(PYTHON)|;1 s|^#! \([^/].*\)|#! /usr/bin/env \1|' $(DESTDIR)$(pynslcddir)/main.py
diff --git a/pynslcd/alias.py b/pynslcd/alias.py
index 8096309..614dd53 100644
--- a/pynslcd/alias.py
+++ b/pynslcd/alias.py
@@ -18,10 +18,10 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 # 02110-1301 USA
 
-import cache
-import common
-import constants
-import search
+from pynslcd import cache
+from pynslcd import common
+from pynslcd import constants
+from pynslcd import search
 
 
 attmap = common.Attributes(
diff --git a/pynslcd/attmap.py b/pynslcd/attmap.py
index 61862df..4d450f6 100644
--- a/pynslcd/attmap.py
+++ b/pynslcd/attmap.py
@@ -45,7 +45,7 @@ import re
 import ldap.dn
 from ldap.filter import escape_filter_chars
 
-from expr import Expression
+from pynslcd.expr import Expression
 
 
 # exported names
diff --git a/pynslcd/cfg.py b/pynslcd/cfg.py
index 877d442..14ae850 100644
--- a/pynslcd/cfg.py
+++ b/pynslcd/cfg.py
@@ -133,8 +133,8 @@ _tls_reqcert_options = {'never': ldap.OPT_X_TLS_NEVER,
 
 def _get_maps():
     # separate function as not to pollute the namespace and avoid import loops
-    import alias, ether, group, host, netgroup, network, passwd  # noqa: E401
-    import protocol, rpc, service, shadow  # noqa: E401
+    from pynslcd import alias, ether, group, host, netgroup, network, passwd  # noqa: E401
+    from pynslcd import protocol, rpc, service, shadow  # noqa: E401
     import sys
     return dict(
         alias=alias, aliases=alias,
@@ -293,7 +293,7 @@ def read(filename):  # noqa: C901 (many simple branches)
         # pam_authz_search <FILTER>
         m = re.match(r'pam_authz_search\s+(?P<value>\S.*)', line, re.IGNORECASE)
         if m:
-            from expr import Expression
+            from pynslcd.expr import Expression
             pam_authz_searches.append(Expression(m.group('value')))
             # TODO: check pam_authz_search expression to only contain
             # username, service, ruser, rhost, tty, hostname, fqdn, dn or
diff --git a/pynslcd/common.py b/pynslcd/common.py
index a5b168d..568ac2f 100644
--- a/pynslcd/common.py
+++ b/pynslcd/common.py
@@ -23,9 +23,9 @@ import sys
 
 import ldap
 
-from attmap import Attributes  # noqa: F401 (used by other modules)
-import cfg
-import constants
+from pynslcd.attmap import Attributes  # noqa: F401 (used by other modules)
+from pynslcd import cfg
+from pynslcd import constants
 
 
 def is_valid_name(name):
diff --git a/pynslcd/config.py b/pynslcd/config.py
index ee57db3..ba8badb 100644
--- a/pynslcd/config.py
+++ b/pynslcd/config.py
@@ -18,9 +18,9 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 # 02110-1301 USA
 
-import cfg
-import common
-import constants
+from pynslcd import cfg
+from pynslcd import common
+from pynslcd import constants
 
 
 class ConfigGetRequest(common.Request):
diff --git a/pynslcd/ether.py b/pynslcd/ether.py
index 9462ef0..2edc5de 100644
--- a/pynslcd/ether.py
+++ b/pynslcd/ether.py
@@ -20,10 +20,10 @@
 
 import struct
 
-import cache
-import common
-import constants
-import search
+from pynslcd import cache
+from pynslcd import common
+from pynslcd import constants
+from pynslcd import search
 
 
 def ether_aton(ether):
diff --git a/pynslcd/group.py b/pynslcd/group.py
index 263e40c..422ee9e 100644
--- a/pynslcd/group.py
+++ b/pynslcd/group.py
@@ -23,12 +23,12 @@ import logging
 import ldap
 from ldap.filter import escape_filter_chars
 
-import cache
-import cfg
-import common
-import constants
-import passwd
-import search
+from pynslcd import cache
+from pynslcd import cfg
+from pynslcd import common
+from pynslcd import constants
+from pynslcd import passwd
+from pynslcd import search
 
 
 def clean(lst):
diff --git a/pynslcd/host.py b/pynslcd/host.py
index c6639df..30259d6 100644
--- a/pynslcd/host.py
+++ b/pynslcd/host.py
@@ -18,10 +18,10 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 # 02110-1301 USA
 
-import cache
-import common
-import constants
-import search
+from pynslcd import cache
+from pynslcd import common
+from pynslcd import constants
+from pynslcd import search
 
 
 attmap = common.Attributes(
diff --git a/pynslcd/invalidator.py b/pynslcd/invalidator.py
index 6d2eefe..b54946e 100644
--- a/pynslcd/invalidator.py
+++ b/pynslcd/invalidator.py
@@ -23,7 +23,7 @@ import logging
 import os
 import subprocess
 
-import cfg
+from pynslcd import cfg
 
 
 # the file descriptor used for sending messages to the child process
diff --git a/pynslcd/mypidfile.py b/pynslcd/mypidfile.py
index 42935e2..dd7d59a 100644
--- a/pynslcd/mypidfile.py
+++ b/pynslcd/mypidfile.py
@@ -22,7 +22,7 @@ import errno
 import fcntl
 import os
 
-import cfg
+from pynslcd import cfg
 
 
 class MyPIDLockFile(object):
diff --git a/pynslcd/netgroup.py b/pynslcd/netgroup.py
index 47a4c6e..8d0fbb2 100644
--- a/pynslcd/netgroup.py
+++ b/pynslcd/netgroup.py
@@ -20,10 +20,10 @@
 
 import re
 
-import cache
-import common
-import constants
-import search
+from pynslcd import cache
+from pynslcd import common
+from pynslcd import constants
+from pynslcd import search
 
 
 _netgroup_triple_re = re.compile(
diff --git a/pynslcd/network.py b/pynslcd/network.py
index da587b9..3b94d06 100644
--- a/pynslcd/network.py
+++ b/pynslcd/network.py
@@ -18,10 +18,10 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 # 02110-1301 USA
 
-import cache
-import common
-import constants
-import search
+from pynslcd import cache
+from pynslcd import common
+from pynslcd import constants
+from pynslcd import search
 
 
 attmap = common.Attributes(
diff --git a/pynslcd/pam.py b/pynslcd/pam.py
index b372cdd..bb7add8 100644
--- a/pynslcd/pam.py
+++ b/pynslcd/pam.py
@@ -27,12 +27,12 @@ import ldap
 from ldap.controls.ppolicy import PasswordPolicyControl, PasswordPolicyError
 from ldap.filter import escape_filter_chars
 
-import cfg
-import common
-import constants
-import passwd
-import search
-import shadow
+from pynslcd import cfg
+from pynslcd import common
+from pynslcd import constants
+from pynslcd import passwd
+from pynslcd import search
+from pynslcd import shadow
 
 
 random = random.SystemRandom()
diff --git a/pynslcd/passwd.py b/pynslcd/passwd.py
index 1274f21..51ae57e 100644
--- a/pynslcd/passwd.py
+++ b/pynslcd/passwd.py
@@ -20,11 +20,11 @@
 
 import logging
 
-import cache
-import cfg
-import common
-import constants
-import search
+from pynslcd import cache
+from pynslcd import cfg
+from pynslcd import common
+from pynslcd import constants
+from pynslcd import search
 
 
 attmap = common.Attributes(
diff --git a/pynslcd/protocol.py b/pynslcd/protocol.py
index dc41c4b..396f337 100644
--- a/pynslcd/protocol.py
+++ b/pynslcd/protocol.py
@@ -18,10 +18,10 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 # 02110-1301 USA
 
-import cache
-import common
-import constants
-import search
+from pynslcd import cache
+from pynslcd import common
+from pynslcd import constants
+from pynslcd import search
 
 
 attmap = common.Attributes(
diff --git a/pynslcd/pynslcd.py b/pynslcd/pynslcd.py
index 0691b61..973ecd9 100755
--- a/pynslcd/pynslcd.py
+++ b/pynslcd/pynslcd.py
@@ -30,13 +30,13 @@ import threading
 import daemon
 import ldap
 
-import cfg
-import common
-import constants
-import invalidator
-import mypidfile
-import search
-from tio import TIOStream
+import pynslcd.cfg as cfg
+import pynslcd.common as common
+import pynslcd.constants as constants
+import pynslcd.invalidator as invalidator
+import pynslcd.mypidfile as mypidfile
+import pynslcd.search as search
+from pynslcd.tio import TIOStream
 
 
 # the name of the program
@@ -188,20 +188,20 @@ def getpeercred(fd):
 
 
 handlers = {}
-handlers.update(common.get_handlers('config'))
-handlers.update(common.get_handlers('alias'))
-handlers.update(common.get_handlers('ether'))
-handlers.update(common.get_handlers('group'))
-handlers.update(common.get_handlers('host'))
-handlers.update(common.get_handlers('netgroup'))
-handlers.update(common.get_handlers('network'))
-handlers.update(common.get_handlers('passwd'))
-handlers.update(common.get_handlers('protocol'))
-handlers.update(common.get_handlers('rpc'))
-handlers.update(common.get_handlers('service'))
-handlers.update(common.get_handlers('shadow'))
-handlers.update(common.get_handlers('pam'))
-handlers.update(common.get_handlers('usermod'))
+handlers.update(common.get_handlers('pynslcd.config'))
+handlers.update(common.get_handlers('pynslcd.alias'))
+handlers.update(common.get_handlers('pynslcd.ether'))
+handlers.update(common.get_handlers('pynslcd.group'))
+handlers.update(common.get_handlers('pynslcd.host'))
+handlers.update(common.get_handlers('pynslcd.netgroup'))
+handlers.update(common.get_handlers('pynslcd.network'))
+handlers.update(common.get_handlers('pynslcd.passwd'))
+handlers.update(common.get_handlers('pynslcd.protocol'))
+handlers.update(common.get_handlers('pynslcd.rpc'))
+handlers.update(common.get_handlers('pynslcd.service'))
+handlers.update(common.get_handlers('pynslcd.shadow'))
+handlers.update(common.get_handlers('pynslcd.pam'))
+handlers.update(common.get_handlers('pynslcd.usermod'))
 
 
 def acceptconnection(nslcd_serversocket, session):
diff --git a/pynslcd/rpc.py b/pynslcd/rpc.py
index 49d9c7c..e1ea4f5 100644
--- a/pynslcd/rpc.py
+++ b/pynslcd/rpc.py
@@ -18,10 +18,10 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 # 02110-1301 USA
 
-import cache
-import common
-import constants
-import search
+from pynslcd import cache
+from pynslcd import common
+from pynslcd import constants
+from pynslcd import search
 
 
 attmap = common.Attributes(
diff --git a/pynslcd/search.py b/pynslcd/search.py
index 39850d2..f017451 100644
--- a/pynslcd/search.py
+++ b/pynslcd/search.py
@@ -24,7 +24,7 @@ import sys
 import ldap
 import ldap.ldapobject
 
-import cfg
+from pynslcd import cfg
 
 
 # global indicator that there was some error connection to an LDAP server
diff --git a/pynslcd/service.py b/pynslcd/service.py
index b0c53e3..96c2aaf 100644
--- a/pynslcd/service.py
+++ b/pynslcd/service.py
@@ -20,10 +20,10 @@
 
 import datetime
 
-import cache
-import common
-import constants
-import search
+from pynslcd import cache
+from pynslcd import common
+from pynslcd import constants
+from pynslcd import search
 
 
 attmap = common.Attributes(
diff --git a/pynslcd/shadow.py b/pynslcd/shadow.py
index 59e1af6..3ed695b 100644
--- a/pynslcd/shadow.py
+++ b/pynslcd/shadow.py
@@ -20,11 +20,11 @@
 
 import logging
 
-import cache
-import cfg
-import common
-import constants
-import search
+from pynslcd import cache
+from pynslcd import cfg
+from pynslcd import common
+from pynslcd import constants
+from pynslcd import search
 
 
 attmap = common.Attributes(
diff --git a/pynslcd/usermod.py b/pynslcd/usermod.py
index 4e37ded..ffd651b 100644
--- a/pynslcd/usermod.py
+++ b/pynslcd/usermod.py
@@ -26,10 +26,10 @@ import os.path
 
 import ldap
 
-import cfg
-import constants
-import pam
-import passwd
+from pynslcd import cfg
+from pynslcd import constants
+from pynslcd import pam
+from pynslcd import passwd
 
 
 def list_shells():