Line
Link Here
|
0 |
-- a/WebappConfig/config.py |
0 |
++ b/WebappConfig/config.py |
Lines 288-293
class Config:
Link Here
|
288 |
'my_serverconfigdir': '%(my_appdir)s/conf', |
288 |
'my_serverconfigdir': '%(my_appdir)s/conf', |
289 |
'wa_configlist' : '%(my_appdir)s/config-files', |
289 |
'wa_configlist' : '%(my_appdir)s/config-files', |
290 |
'wa_solist' : '%(my_appdir)s/server-owned-files', |
290 |
'wa_solist' : '%(my_appdir)s/server-owned-files', |
|
|
291 |
'wa_sodlist' : '%(my_appdir)s/server-owned-dirs', |
291 |
'wa_virtuallist' : '%(my_appdir)s/virtuals', |
292 |
'wa_virtuallist' : '%(my_appdir)s/virtuals', |
292 |
'wa_installs' : '%(my_persistdir)s/%(wa_installsbase)s', |
293 |
'wa_installs' : '%(my_persistdir)s/%(wa_installsbase)s', |
293 |
'wa_postinstallinfo': |
294 |
'wa_postinstallinfo': |
294 |
-- a/WebappConfig/content.py |
295 |
++ b/WebappConfig/content.py |
Lines 230-235
class Contents:
Link Here
|
230 |
|
230 |
|
231 |
if ok and not line_split[2] in ['virtual', |
231 |
if ok and not line_split[2] in ['virtual', |
232 |
'server-owned', |
232 |
'server-owned', |
|
|
233 |
'server-owned-dir', |
233 |
'config-owned', |
234 |
'config-owned', |
234 |
'default-owned', |
235 |
'default-owned', |
235 |
'config-server-owned', |
236 |
'config-server-owned', |
236 |
-- a/WebappConfig/db.py |
237 |
++ b/WebappConfig/db.py |
Lines 512-521
class WebappSource(AppHierarchy):
Link Here
|
512 |
self.ignore = [] |
512 |
self.ignore = [] |
513 |
|
513 |
|
514 |
def read(self, |
514 |
def read(self, |
515 |
config_owned = 'config-files', |
515 |
config_owned = 'config-files', |
516 |
server_owned = 'server-owned-files', |
516 |
server_owned = 'server-owned-files', |
517 |
virtual_files = 'virtual', |
517 |
server_owned_r = 'server-owned-dirs', |
518 |
default_dirs = 'default-owned'): |
518 |
virtual_files = 'virtual', |
|
|
519 |
default_dirs = 'default-owned'): |
519 |
''' |
520 |
''' |
520 |
Initialize the type cache. |
521 |
Initialize the type cache. |
521 |
|
522 |
|
Lines 535-540
class WebappSource(AppHierarchy):
Link Here
|
535 |
import WebappConfig.filetype |
536 |
import WebappConfig.filetype |
536 |
|
537 |
|
537 |
server_files = [] |
538 |
server_files = [] |
|
|
539 |
server_dirs = [] |
538 |
config_files = [] |
540 |
config_files = [] |
539 |
|
541 |
|
540 |
if os.access(self.appdir() + '/' + config_owned, os.R_OK): |
542 |
if os.access(self.appdir() + '/' + config_owned, os.R_OK): |
Lines 553-578
class WebappSource(AppHierarchy):
Link Here
|
553 |
|
555 |
|
554 |
flist.close() |
556 |
flist.close() |
555 |
|
557 |
|
|
|
558 |
if os.access(self.appdir() + '/' + server_owned_r, os.R_OK): |
559 |
flist = open(self.appdir() + '/' + server_owned_r) |
560 |
server_dirs = flist.readlines() |
561 |
|
562 |
OUT.debug('Identified server-owned directories.', 7) |
563 |
|
564 |
flist.close() |
565 |
|
556 |
self.__types = WebappConfig.filetype.FileType(config_files, |
566 |
self.__types = WebappConfig.filetype.FileType(config_files, |
557 |
server_files, |
567 |
server_files, |
|
|
568 |
server_dirs, |
558 |
virtual_files, |
569 |
virtual_files, |
559 |
default_dirs) |
570 |
default_dirs) |
560 |
|
571 |
|
561 |
def filetype(self, filename): |
572 |
def filetype(self, filename, parent_type = ''): |
562 |
''' Determine filetype for the given file.''' |
573 |
''' Determine filetype for the given file.''' |
563 |
if self.__types: |
574 |
if self.__types: |
564 |
|
575 |
|
565 |
OUT.debug('Returning file type', 7) |
576 |
OUT.debug('Returning file type', 7) |
566 |
|
577 |
|
567 |
return self.__types.filetype(filename) |
578 |
return self.__types.filetype(filename, parent_type) |
568 |
|
579 |
|
569 |
def dirtype(self, directory): |
580 |
def dirtype(self, directory, parent_type = ''): |
570 |
''' Determine filetype for the given directory.''' |
581 |
''' Determine filetype for the given directory.''' |
571 |
if self.__types: |
582 |
if self.__types: |
572 |
|
583 |
|
573 |
OUT.debug('Returning directory type', 7) |
584 |
OUT.debug('Returning directory type', 7) |
574 |
|
585 |
|
575 |
return self.__types.dirtype(directory) |
586 |
return self.__types.dirtype(directory, parent_type) |
576 |
|
587 |
|
577 |
def source_exists(self, directory): |
588 |
def source_exists(self, directory): |
578 |
''' |
589 |
''' |
579 |
-- a/WebappConfig/filetype.py |
590 |
++ b/WebappConfig/filetype.py |
Lines 115-120
class FileType:
Link Here
|
115 |
def __init__(self, |
115 |
def __init__(self, |
116 |
config_owned, |
116 |
config_owned, |
117 |
server_owned, |
117 |
server_owned, |
|
|
118 |
server_owned_r, |
118 |
virtual_files = 'virtual', |
119 |
virtual_files = 'virtual', |
119 |
default_dirs = 'default-owned'): |
120 |
default_dirs = 'default-owned'): |
120 |
''' |
121 |
''' |
Lines 149-161
class FileType:
Link Here
|
149 |
|
150 |
|
150 |
self.__cache[self.__fix(i)] = 'server-owned' |
151 |
self.__cache[self.__fix(i)] = 'server-owned' |
151 |
|
152 |
|
|
|
153 |
for i in server_owned_r: |
152 |
|
154 |
|
153 |
def filetype(self, filename): |
155 |
if self.__fix(i) in self.__cache.keys(): |
|
|
156 |
|
157 |
OUT.die('{} is a the same time recursively server-owned and {}: This case is not supported.'.format(self.__fix(i), self.__cache[self.__fix(i)])) |
158 |
|
159 |
else : |
160 |
|
161 |
OUT.debug('Adding recursively server-owned file', 8) |
162 |
|
163 |
self.__cache[self.__fix(i)] = 'server-owned-dir' |
164 |
|
165 |
|
166 |
def filetype(self, filename, parent_type = ''): |
154 |
''' |
167 |
''' |
155 |
Inputs: |
168 |
Inputs: |
156 |
|
169 |
|
157 |
filename - the file that we need a decision about |
170 |
filename - the file that we need a decision about |
158 |
|
171 |
|
|
|
172 |
parent_type - the type of the parent directory |
173 |
|
159 |
returns one of these: |
174 |
returns one of these: |
160 |
|
175 |
|
161 |
server-owned - file needs to be owned by the webserver user |
176 |
server-owned - file needs to be owned by the webserver user |
Lines 176-199
class FileType:
Link Here
|
176 |
# remove any whitespace and trailing / |
191 |
# remove any whitespace and trailing / |
177 |
filename = self.__fix(filename) |
192 |
filename = self.__fix(filename) |
178 |
|
193 |
|
179 |
# look for config-protected files in the cache |
194 |
# check the cache |
180 |
if filename in self.__cache.keys(): |
195 |
if filename in self.__cache.keys(): |
|
|
196 |
# Check if parent type is recursive |
197 |
if parent_type == 'server-owned-dir': |
198 |
new_type = self.__cache[filename] |
199 |
if new_type == 'config-owned': |
200 |
return 'config-server-owned' |
201 |
if new_type == 'server-owned': |
202 |
OUT.warn('Configuration error: {} is marked server-owned twice'.format(filename)) |
203 |
return 'server-owned' |
181 |
return self.__cache[filename] |
204 |
return self.__cache[filename] |
182 |
|
205 |
|
|
|
206 |
# Check if parent type is recursive |
207 |
if parent_type == 'server-owned-dir': |
208 |
return 'server-owned' |
183 |
# unspecified file (and thus virtual) |
209 |
# unspecified file (and thus virtual) |
184 |
return self.__virtual_files |
210 |
return self.__virtual_files |
185 |
|
211 |
|
186 |
def dirtype(self, directory): |
212 |
def dirtype(self, directory, parent_type = ''): |
187 |
''' |
213 |
''' |
188 |
Inputs: |
214 |
Inputs: |
189 |
|
215 |
|
190 |
directory - the directory that we need a decision about |
216 |
directory - the directory that we need a decision about |
191 |
|
217 |
|
|
|
218 |
parent_type - the type of the parent directory |
219 |
|
192 |
returns one of these: |
220 |
returns one of these: |
193 |
|
221 |
|
194 |
server-owned - dir needs to be owned by the webserver user |
222 |
server-owned - dir needs to be owned by the webserver user |
195 |
config-owned - dir needs to be owned by the config user |
223 |
config-owned - dir needs to be owned by the config user |
196 |
config-server-owned - Both the previous cases at the same time |
224 |
config-server-owned - Both the previous cases at the same time |
|
|
225 |
server-owned-dir - Directory that contains file/dirs to be owned |
226 |
by the webserver user |
197 |
default-owned - we need a local copy, owned by root |
227 |
default-owned - we need a local copy, owned by root |
198 |
|
228 |
|
199 |
NOTE: |
229 |
NOTE: |
Lines 209-216
class FileType:
Link Here
|
209 |
|
239 |
|
210 |
# check the cache |
240 |
# check the cache |
211 |
if directory in self.__cache.keys(): |
241 |
if directory in self.__cache.keys(): |
|
|
242 |
# Check if parent type is recursive |
243 |
if parent_type == 'server-owned-dir': |
244 |
new_type = self.__cache[directory] |
245 |
if new_type == 'config-owned': |
246 |
OUT.die('This version does not support config dirs') |
247 |
if new_type == server-owned: |
248 |
OUT.warn('Configuration error: {} is marked server-owned two times'.format(filename)) |
249 |
return 'server-owned-dir' |
212 |
return self.__cache[directory] |
250 |
return self.__cache[directory] |
213 |
|
251 |
|
|
|
252 |
# Check if parent type is recursive |
253 |
if parent_type == 'server-owned-dir': |
254 |
return 'server-owned-dir' |
214 |
# unspecified directories are default-owned |
255 |
# unspecified directories are default-owned |
215 |
return self.__default_dirs |
256 |
return self.__default_dirs |
216 |
|
257 |
|
217 |
-- a/WebappConfig/server.py |
258 |
++ b/WebappConfig/server.py |
Lines 79-84
class Basic:
Link Here
|
79 |
permissions['file']['config-server-owned'][1] = self.vhost_server_gid |
79 |
permissions['file']['config-server-owned'][1] = self.vhost_server_gid |
80 |
permissions['dir']['config-server-owned'][1] = self.vhost_server_gid |
80 |
permissions['dir']['config-server-owned'][1] = self.vhost_server_gid |
81 |
|
81 |
|
|
|
82 |
permissions['dir']['server-owned-dir'] = permissions['dir']['server-owned'] |
83 |
|
82 |
self.__perm = permissions |
84 |
self.__perm = permissions |
83 |
self.__handler = handler |
85 |
self.__handler = handler |
84 |
self.__flags = flags |
86 |
self.__flags = flags |
85 |
-- a/WebappConfig/worker.py |
87 |
++ b/WebappConfig/worker.py |
Lines 290-296
class WebappAdd:
Link Here
|
290 |
|
290 |
|
291 |
os.umask(0) |
291 |
os.umask(0) |
292 |
|
292 |
|
293 |
def mkdirs(self, directory = ''): |
293 |
def mkdirs(self, directory = '', current_type = ''): |
294 |
''' |
294 |
''' |
295 |
Create a set of directories |
295 |
Create a set of directories |
296 |
|
296 |
|
Lines 321-340
class WebappAdd:
Link Here
|
321 |
OUT.debug('Handling directory', 7) |
321 |
OUT.debug('Handling directory', 7) |
322 |
|
322 |
|
323 |
# create directory first |
323 |
# create directory first |
324 |
self.mkdir(directory + '/' + i) |
324 |
next_type = self.mkdir(directory + '/' + i, current_type) |
325 |
|
325 |
|
326 |
# then recurse into the directory |
326 |
# then recurse into the directory |
327 |
self.mkdirs(directory + '/' + i) |
327 |
self.mkdirs(directory + '/' + i, next_type) |
328 |
|
328 |
|
329 |
for i in self.__ws.get_source_files(sd): |
329 |
for i in self.__ws.get_source_files(sd): |
330 |
|
330 |
|
331 |
OUT.debug('Handling file', 7) |
331 |
OUT.debug('Handling file', 7) |
332 |
|
332 |
|
333 |
# handle the file |
333 |
# handle the file |
334 |
self.mkfile(directory + '/' + i) |
334 |
self.mkfile(directory + '/' + i, current_type) |
335 |
|
335 |
|
336 |
|
336 |
|
337 |
def mkdir(self, directory): |
337 |
def mkdir(self, directory, current_type): |
338 |
''' |
338 |
''' |
339 |
Create a directory with the correct ownership and permissions. |
339 |
Create a directory with the correct ownership and permissions. |
340 |
|
340 |
|
Lines 362-368
class WebappAdd:
Link Here
|
362 |
if not self.__p: |
362 |
if not self.__p: |
363 |
os.unlink(dst_dir) |
363 |
os.unlink(dst_dir) |
364 |
|
364 |
|
365 |
dirtype = self.__ws.dirtype(src_dir) |
365 |
dirtype = self.__ws.dirtype(src_dir, current_type) |
366 |
|
366 |
|
367 |
OUT.debug('Checked directory type', 8) |
367 |
OUT.debug('Checked directory type', 8) |
368 |
|
368 |
|
Lines 388-394
class WebappAdd:
Link Here
|
388 |
directory, |
388 |
directory, |
389 |
self.__relative) |
389 |
self.__relative) |
390 |
|
390 |
|
391 |
def mkfile(self, filename): |
391 |
return dirtype |
|
|
392 |
|
393 |
def mkfile(self, filename, current_type): |
392 |
''' |
394 |
''' |
393 |
This is what we are all about. No more games - lets take a file |
395 |
This is what we are all about. No more games - lets take a file |
394 |
from the master image of the web-based app, and make it available |
396 |
from the master image of the web-based app, and make it available |
Lines 401-407
class WebappAdd:
Link Here
|
401 |
OUT.debug('Creating file', 6) |
403 |
OUT.debug('Creating file', 6) |
402 |
|
404 |
|
403 |
dst_name = self.__destd + '/' + filename |
405 |
dst_name = self.__destd + '/' + filename |
404 |
file_type = self.__ws.filetype(self.__sourced + '/' + filename) |
406 |
file_type = self.__ws.filetype(self.__sourced + '/' + filename, current_type) |
405 |
|
407 |
|
406 |
OUT.debug('File type determined', 7) |
408 |
OUT.debug('File type determined', 7) |
407 |
|
409 |
|
Lines 558-563
class WebappAdd:
Link Here
|
558 |
dst_name, |
560 |
dst_name, |
559 |
self.__relative) |
561 |
self.__relative) |
560 |
|
562 |
|
|
|
563 |
return file_type |
561 |
|
564 |
|
562 |
if __name__ == '__main__': |
565 |
if __name__ == '__main__': |
563 |
import doctest, sys |
566 |
import doctest, sys |