fix for bug on touching files as described here:
authoridra <idra@0c0555d6-39d7-0310-84fc-f1cc0bd64818>
Tue, 3 Jul 2007 23:34:01 +0000 (23:34 +0000)
committeridra <idra@0c0555d6-39d7-0310-84fc-f1cc0bd64818>
Tue, 3 Jul 2007 23:34:01 +0000 (23:34 +0000)
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=243897

git-svn-id: svn+ssh://svn.samba.org/data/svn/samba/branches/SAMBA_3_0@23691 0c0555d6-39d7-0310-84fc-f1cc0bd64818

source/modules/vfs_recycle.c

index a20e09f0108d65dffcb69e5029d441c697e181df..4360775284f6424bbe78f67860d78835fe9f155f 100644 (file)
@@ -386,20 +386,28 @@ static BOOL matchparam(const char **haystack_list, const char *needle)
 /**
  * Touch access or modify date
  **/
-static void recycle_do_touch(vfs_handle_struct *handle, const char *fname, BOOL touch_mtime)
+static void recycle_do_touch(vfs_handle_struct *handle, const char *fname,
+                            BOOL touch_mtime)
 {
        SMB_STRUCT_STAT st;
        struct timespec ts[2];
-       
+       int status, err;
+
        if (SMB_VFS_NEXT_STAT(handle, fname, &st) != 0) {
-               DEBUG(0,("recycle: stat for %s returned %s\n", fname, strerror(errno)));
+               DEBUG(0,("recycle: stat for %s returned %s\n",
+                        fname, strerror(errno)));
                return;
        }
        ts[0] = timespec_current(); /* atime */
        ts[1] = touch_mtime ? ts[0] : get_mtimespec(&st); /* mtime */
 
-       if (SMB_VFS_NEXT_NTIMES(handle, fname, ts) == -1 ) {
-               DEBUG(0, ("recycle: touching %s failed, reason = %s\n", fname, strerror(errno)));
+       become_root();
+       status = SMB_VFS_NEXT_NTIMES(handle, fname, ts);
+       err = errno;
+       unbecome_root();
+       if (status == -1 ) {
+               DEBUG(0, ("recycle: touching %s failed, reason = %s\n",
+                         fname, strerror(err)));
        }
 }