[PATCH 7/7] vcview: Make temporary version control files un-writable



A version control diff is a diff of a local file vs the contents
of a repository.  A user can't edit the repository directly, so they
shouldn't be able to edit the temporary file representing the repository
either.  This also prevents a user from accidentally modifying a
temporary version control file in /tmp, saving it (thinking they were
saving the "real", working copy), then having it be automatically
removed when closing meld.

Signed-off-by: Peter Tyser <ptyser gmail com>
---
I wasn't sure if there would be a race condition with the emit() vs chmod().
Is there a chance the emit() call would return prior to the diff being
created?  If so, I'd need to rework this a bit.

 meld/vcview.py |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/meld/vcview.py b/meld/vcview.py
index 4d1b184..c58acb0 100644
--- a/meld/vcview.py
+++ b/meld/vcview.py
@@ -527,6 +527,7 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
         if misc.write_pipe(patchcmd, patch) == 0:
             for d in diffs:
                 self.emit("create-diff", d)
+                os.chmod(d[0], 0444)
         else:
             import meldapp
             msg = _("""
-- 
1.7.1.13.gcfb88



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]