summaryrefslogtreecommitdiff
path: root/source3/modules/vfs_recycle.c
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2007-07-03 23:34:01 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:23:46 -0500
commit38c84fe163e8c30d599f7cf872d04142757ceeb1 (patch)
treeb222c093a8114d83d5dfee6924b8cf1c8b6d3823 /source3/modules/vfs_recycle.c
parent3a246ac46b9ae2bbc62498092a616b87732ab818 (diff)
downloadsamba-38c84fe163e8c30d599f7cf872d04142757ceeb1.tar.gz
samba-38c84fe163e8c30d599f7cf872d04142757ceeb1.tar.bz2
samba-38c84fe163e8c30d599f7cf872d04142757ceeb1.zip
r23691: fix for bug on touching files as described here:
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=243897 (This used to be commit 6b68c006f8ecba8ed3a4d87950691cb1e5c46386)
Diffstat (limited to 'source3/modules/vfs_recycle.c')
-rw-r--r--source3/modules/vfs_recycle.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/source3/modules/vfs_recycle.c b/source3/modules/vfs_recycle.c
index a20e09f010..4360775284 100644
--- a/source3/modules/vfs_recycle.c
+++ b/source3/modules/vfs_recycle.c
@@ -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)));
}
}