Package: fusedav
Version: 0.2-3
Severity: normal

Attached is an additional patch which preserves the executable property
when updating the file.  Some web servers (tested on
apache2=2.2.16-6+squeeze8) do not preserve this for us.
>From 3bc06e82bbdf6abeb5ded303a61c486343e84180 Mon Sep 17 00:00:00 2001
From: Eric Wong <normalper...@yhbt.net>
Date: Fri, 2 Nov 2012 21:37:46 +0000
Subject: [PATCH 05/13] preserve executable attr on PUT when replacing

Servers may not preserve the executable property if a PUT
request overwrites an existing file.  Since dav_mknod creates an
empty file, the resulting file will often be overwritten in a
subsequent PUT.
---
 src/fusedav.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/fusedav.c b/src/fusedav.c
index 5935a3b..defae8c 100644
--- a/src/fusedav.c
+++ b/src/fusedav.c
@@ -553,6 +553,8 @@ static int dav_fsync(const char *path, __unused int 
isdatasync, __unused struct
     void *f = NULL;
     int r = 0;
     ne_session *session;
+    struct stat st;
+    int stat_rc;
 
     path = path_cvt(path);
     if (debug)
@@ -569,11 +571,17 @@ static int dav_fsync(const char *path, __unused int 
isdatasync, __unused struct
         goto finish;
     }
 
+    stat_rc = get_stat(path, &st);
+
     if (file_cache_sync(f) < 0) {
         r = -errno;
         goto finish;
     }
 
+    /* ensure we keep the executable bit if the file existed */
+    if (stat_rc == 0 && (st.st_mode & 0111))
+        r = chmod_internal(session, path, st.st_mode);
+
 finish:
     
     if (f)
-- 
1.8.0.3.gdd57fab.dirty

Reply via email to