From 7f457a1d313c8b76aba8980ad49b15ffba1013d7 Mon Sep 17 00:00:00 2001 From: Michal Marek Date: Thu, 28 Aug 2008 09:41:42 +0000 Subject: [PATCH] mmap the file readonly, it is safer and fixes uploading of readonly files in osc ftp --- osc/core.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/osc/core.py b/osc/core.py index 8e676b57..56e0aa61 100755 --- a/osc/core.py +++ b/osc/core.py @@ -1456,9 +1456,10 @@ def http_request(method, url, headers={}, data=None, file=None): data = open(file).read() else: import mmap - filefd = open(file, 'r+') + filefd = open(file, 'r') try: - data = mmap.mmap(filefd.fileno(), os.path.getsize(file)) + data = mmap.mmap(filefd.fileno(), os.path.getsize(file), + mmap.MAP_SHARED, mmap.PROT_READ) except EnvironmentError, e: if e.errno == 19: sys.exit('\n\n%s\nThe file \'%s\' could not be memory mapped. It is ' \