Hi,

per discussion on users list, attached is the patch which will
keep permission after saving of the file.
By default creating temps is subject to rw+ for user only
and after moving temp to original location the perms were destroyed.

Will commit soon if nobody objects.
Pavel
diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index 41a86ba1a9..1f6436662d 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -1443,6 +1443,9 @@ bool Buffer::save() const
 
        FileName savefile(tempfile->name());
        LYXERR(Debug::FILES, "Saving to " << savefile.absFileName());
+       if (!savefile.clonePermissions(fileName()))
+               LYXERR0("Failed to clone the permission from " << 
fileName().absFileName() << " to " << savefile.absFileName());
+
        if (!writeFile(savefile))
                return false;
 
diff --git a/src/support/FileName.cpp b/src/support/FileName.cpp
index 3d22acbe70..b485ae9395 100644
--- a/src/support/FileName.cpp
+++ b/src/support/FileName.cpp
@@ -288,6 +288,13 @@ bool FileName::changePermission(unsigned long int mode) 
const
        return true;
 }
 
+bool FileName::clonePermissions(FileName const & source)
+{
+       QFile fin(toqstr(source.absFileName()));
+       QFile f(toqstr(absFileName()));
+
+       return f.setPermissions(fin.permissions());
+}
 
 string FileName::toFilesystemEncoding() const
 {
diff --git a/src/support/FileName.h b/src/support/FileName.h
index 8264d8087b..fad5077bdf 100644
--- a/src/support/FileName.h
+++ b/src/support/FileName.h
@@ -150,6 +150,8 @@ public:
        /// support this.
        /// \return true on success.
        bool changePermission(unsigned long int mode) const;
+       // sets permission based on the file given as an argument
+       bool clonePermissions(FileName const & target);
 
        /// remove pointed directory and all contents.
        /// \return true on success.

Reply via email to