r23691: fix for bug on touching files as described here:
authorSimo Sorce <idra@samba.org>
Tue, 3 Jul 2007 23:34:01 +0000 (23:34 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:23:46 +0000 (12:23 -0500)
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=243897
(This used to be commit 6b68c006f8ecba8ed3a4d87950691cb1e5c46386)

source3/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
  **/
 /**
  * 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];
 {
        SMB_STRUCT_STAT st;
        struct timespec ts[2];
-       
+       int status, err;
+
        if (SMB_VFS_NEXT_STAT(handle, fname, &st) != 0) {
        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 */
 
                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)));
        }
 }
 
        }
 }