From bc6e06a3aedc3108eed6763ea1624c791e981e08 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Wed, 30 Mar 2016 03:44:36 +0000 Subject: Still more UID-swapped file I/O, and general cleanup of UI file I/O. GUI no longer uses (an additional layer of) temporary files between itself and zookeeper. Zookeeper file read methods now take file-like objects. rpkic now opens input files as the real UID, then reverts back to the effective UID before handing the resulting file off to the zookeeper. This caught several more instances of rpkic file I/O that were not doing the real/effective UID swap properly while loading CSV and VCard files. As far as I can tell from testing, this didn't break anything that worked before. Whether it fixed all the file I/O problems remains to be seen. svn path=/branches/tk705/; revision=6339 --- rpki/csv_utils.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'rpki/csv_utils.py') diff --git a/rpki/csv_utils.py b/rpki/csv_utils.py index 2864693c..5fa498a1 100644 --- a/rpki/csv_utils.py +++ b/rpki/csv_utils.py @@ -46,12 +46,18 @@ class csv_reader(object): assert min_columns is None or isinstance(min_columns, int) if columns is not None and min_columns is None: min_columns = columns - self.filename = filename self.columns = columns self.min_columns = min_columns self.comment_characters = comment_characters - self.file = open(filename, "r") - + if isinstance(filename, (str, unicode)): + # Name of a file to open + self.filename = filename + self.file = open(filename, "r") + else: + # File-like object, already opened + self.filename = None + self.file = filename + def __iter__(self): line_number = 0 for line in self.file: -- cgit v1.2.3