Univention Bugzilla – Attachment 8300 Details for
Bug 37955
Problematic leftover "home directory"
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
patch
37955.patch (text/plain), 3.47 KB, created by
Florian Best
on 2016-12-09 16:37 CET
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Florian Best
Created:
2016-12-09 16:37 CET
Size:
3.47 KB
patch
obsolete
>diff --git a/ucs-school-umc-exam/umc/python/schoolexam/__init__.py b/ucs-school-umc-exam/umc/python/schoolexam/__init__.py >index 125ad27..057796d 100644 >--- a/ucs-school-umc-exam/umc/python/schoolexam/__init__.py >+++ b/ucs-school-umc-exam/umc/python/schoolexam/__init__.py >@@ -51,13 +51,14 @@ > from univention.management.console.modules.sanitizers import StringSanitizer, DictSanitizer, ListSanitizer, DNSanitizer > from univention.management.console.modules.schoolexam import util > >+from univention.admin.uexceptions import noObject > from univention.lib.i18n import Translation > from univention.lib.umc_connection import UMCConnection > > from ucsschool.lib.schoolldap import LDAP_Connection, SchoolBaseModule, SchoolSearchBase, SchoolSanitizer > from ucsschool.lib import internetrules > from ucsschool.lib.schoollessons import SchoolLessons >-from ucsschool.lib.models import ComputerRoom, ExamStudent, Student, User >+from ucsschool.lib.models import ComputerRoom, ExamStudent, User > > _ = Translation('ucs-school-umc-exam').translate > >@@ -252,32 +253,22 @@ def _thread(): > percentPerUser = 25.0 / (1 + len(users)) > examUsers = set() > usersReplicated = set() >+ home_directories_to_remove = set() > for iuser in users: > progress.info('%s, %s (%s)' % (iuser.lastname, iuser.firstname, iuser.username)) >- if iuser.dn.endswith(Student.get_container(request.options['school'])): >- # its a student. check if home directory from previous >- # user with same username exists and remove it >- exam_dn = 'uid={}{},{}'.format( >- user_prefix_exam, >- iuser.username, >- ExamStudent.get_container(request.options['school'])) >- try: >- ldap_user_read.get(exam_dn, required=True) >- except ldap.NO_SUCH_OBJECT: >- _tmp_split_path = iuser.homedir.rsplit(os.path.sep, 1) >- if len(_tmp_split_path) != 2: >- MODULE.error("Failed parsing homeDirectory of original user: %s" % (iuser.homedir,)) >- else: >- exam_user_homedir = os.path.join(_tmp_split_path[0], iuser.username) >- if os.path.exists(exam_user_homedir): >- MODULE.warn('Removing stale home directory %r.' % exam_user_homedir) >- shutil.rmtree(exam_user_homedir, ignore_errors=True) >+ remove_home_directory_prior = False >+ try: >+ ExamStudent.from_student_dn(ldap_user_read, request.options['school'], iuser.dn) >+ except noObject: >+ remove_home_directory_prior = True > try: > ires = connection.request('schoolexam-master/create-exam-user', dict( > school=request.options['school'], > userdn=iuser.dn > )) > examUsers.add(ires.get('examuserdn')) >+ if remove_home_directory_prior: >+ home_directories_to_remove.add(ires.get('examuserdn')) > MODULE.info('Exam user has been created: %s' % ires.get('examuserdn')) > except (HTTPException, SocketError) as exc: > MODULE.warn('Could not create exam user account for %r: %s' % (iuser.dn, exc)) >@@ -325,6 +316,14 @@ def _thread(): > MODULE.error('replication timeout - %s user objects missing: %r ' % ((len(examUsers) - len(usersReplicated)), (examUsers - usersReplicated))) > raise UMC_Error(_('Replication timeout: could not create all exam users')) > >+ for userdn in usersReplicated: >+ if userdn in home_directories_to_remove: >+ try: >+ user = ExamStudent.from_dn(userdn, None, ldap_user_read) >+ except noObject: >+ continue >+ shutil.rmtree(user.homedir, ignore_errors=True) >+ > # update the final list of recipients > my.project.recipients = recipients > my.project.save()
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Actions:
View
|
Diff
Attachments on
bug 37955
: 8300