Two more replication fixes
Jim Meyering
jim at meyering.net
Thu Oct 21 06:37:30 UTC 2010
Jeff Darcy wrote:
> [PATCH 2/3] Add X-redhat-role header when replicating to ourselves.
> [PATCH 3/3] Add O_TRUNC in case new file is shorter than what's there.
Thanks!
What problem does 2/3 correct?
I see that without it validate_put
I suppose you have new tests (or at least outlines)
for these?
> Subject: [PATCH 2/3] Add X-redhat-role header when replicating to ourselves.
...
>
> Subject: [PATCH 3/3] Add O_TRUNC in case new file is shorter than what's there.
>
> ---
> backend.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/backend.c b/backend.c
> index d6b4503..0e90df4 100644
> --- a/backend.c
> +++ b/backend.c
> @@ -1190,7 +1190,7 @@ fs_put_child (void * ctx)
> char fixed[1024];
>
> sprintf(fixed,"%s/%s",ms->bucket,ms->key);
> - fd = open(fixed,O_WRONLY|O_CREAT,0666);
> + fd = open(fixed,O_WRONLY|O_CREAT|O_TRUNC,0666);
> if (fd < 0) {
> pipe_cons_siginit(ps, errno);
> free(pp);
The above will always fail if an existing file is somehow unwritable.
To that end, I think we should be unlinking the file first,
and then creating with the addition of O_EXCL.
Mostly unrelated, shouldn't we prefer 0660 or 0600, just in case
this is ever run with a permissive umask? There is rarely any
reason to make such files world-accessible.
More information about the iwhd-devel
mailing list