|
Lines 33-38
Link Here
|
| 33 |
|
33 |
|
| 34 |
import datetime |
34 |
import datetime |
| 35 |
import glob |
35 |
import glob |
|
|
36 |
import copy |
| 36 |
import os |
37 |
import os |
| 37 |
import stat |
38 |
import stat |
| 38 |
import subprocess |
39 |
import subprocess |
|
Lines 79-86
def init(self):
Link Here
|
| 79 |
|
80 |
|
| 80 |
def _get_path(self, username, printjob): |
81 |
def _get_path(self, username, printjob): |
| 81 |
printjob = printjob.replace('/', '') |
82 |
printjob = printjob.replace('/', '') |
| 82 |
username = username.replace('/', '').lower() |
83 |
username = username.replace('/', '') |
| 83 |
path = os.path.join(CUPSPDF_DIR, username, CUPSPDF_USERSUBDIR, printjob) |
84 |
for username in (username, username.lower()): |
|
|
85 |
path = os.path.join(CUPSPDF_DIR, username, CUPSPDF_USERSUBDIR, printjob) |
| 86 |
if os.path.exists(path): |
| 87 |
break |
| 84 |
if not os.path.realpath(path).startswith(os.path.realpath(CUPSPDF_DIR)): |
88 |
if not os.path.realpath(path).startswith(os.path.realpath(CUPSPDF_DIR)): |
| 85 |
raise UMC_OptionTypeError('Invalid file') |
89 |
raise UMC_OptionTypeError('Invalid file') |
| 86 |
return path |
90 |
return path |
|
Lines 130-137
def query(self, request, ldap_user_read=None, ldap_position=None, search_base=No
Link Here
|
| 130 |
printjoblist = [] |
134 |
printjoblist = [] |
| 131 |
|
135 |
|
| 132 |
for student in students: |
136 |
for student in students: |
| 133 |
user_path = self._get_path(student.info['username'], '*.pdf') |
137 |
student2 = copy.deepcopy(student) |
| 134 |
printjoblist.extend(Printjob(student, document).json() for document in glob.glob(user_path) if os.path.isfile(document)) |
138 |
student2.info['username'] = student2.info['username'].lower() |
|
|
139 |
for student in (student, student2): |
| 140 |
user_path = self._get_path(student.info['username'], '') |
| 141 |
printjoblist.extend(Printjob(student, document).json() for document in glob.glob(os.path.join(user_path, '*.pdf')) if os.path.isfile(document)) |
| 135 |
|
142 |
|
| 136 |
self.finished(request.id, printjoblist) |
143 |
self.finished(request.id, printjoblist) |
| 137 |
|
144 |
|