[systemd-devel] [PATCH] tmpfiles: copy - stop if chown/chmod fails

2014-06-19 Thread Thomas H.P. Andersen
From: Thomas Hindoe Paaboel Andersen pho...@gmail.com

after 19f3934057d20c63f4c95791312038a41b4666d0 the errors from chown/chmod
will be cleared before being read. Presumably to clear the possible EEXIST
from copying to an existing directory.
Note: with this patch we stop immediately on error in chown/chmod while before
we would attempt to copy anyway.
---
 src/shared/copy.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/shared/copy.c b/src/shared/copy.c
index 867e49b..5434e7b 100644
--- a/src/shared/copy.c
+++ b/src/shared/copy.c
@@ -181,10 +181,10 @@ static int fd_copy_directory(int df, const char *from, 
const struct stat *st, in
 
 if (created) {
 if (fchown(fdt, st-st_uid, st-st_gid)  0)
-r = -errno;
+return -errno;
 
 if (fchmod(fdt, st-st_mode  0)  0)
-r = -errno;
+return -errno;
 }
 
 r = 0;
-- 
1.9.3

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] tmpfiles: copy - stop if chown/chmod fails

2014-06-19 Thread Lennart Poettering
On Thu, 19.06.14 22:48, Thomas H.P. Andersen (pho...@gmail.com) wrote:

 From: Thomas Hindoe Paaboel Andersen pho...@gmail.com
 
 after 19f3934057d20c63f4c95791312038a41b4666d0 the errors from chown/chmod
 will be cleared before being read. Presumably to clear the possible EEXIST
 from copying to an existing directory.
 Note: with this patch we stop immediately on error in chown/chmod while before
 we would attempt to copy anyway.

Ah, this was actually intended to follow a scheme where we neither abort
on failure, not ignore the error completely, but simply do things as
good as we can and return the most recent error. After all this is a
file copy operation, and hence trying to copy things as possible, even
if caps for chmod/chown are missing might be OK.

I fixed that now with a different patch!

Thanks a lot for the pointer!

Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel