From 953d5e1531c8df726ccffff61b2486fbbdd6a9ac Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Wed, 31 Jul 2019 12:44:27 +0200 Subject: [PATCH] src/tools.rs - file_set_contents_full: only call fchmod when we pass permissions So that we can use it to write into /etc/pve/ (which does not support chmod). --- src/tools.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/tools.rs b/src/tools.rs index 3c1c711d..0efe5bd7 100644 --- a/src/tools.rs +++ b/src/tools.rs @@ -197,9 +197,11 @@ pub fn file_set_contents_full>( stat::Mode::S_IRGRP | stat::Mode::S_IROTH )); - if let Err(err) = stat::fchmod(fd, mode) { - let _ = unistd::unlink(tmp_path); - bail!("fchmod {:?} failed: {}", tmp_path, err); + if perm != None { + if let Err(err) = stat::fchmod(fd, mode) { + let _ = unistd::unlink(tmp_path); + bail!("fchmod {:?} failed: {}", tmp_path, err); + } } if owner != None || group != None {