[v2,12/16] libasm/debuginfod: fchmod doesn't present on win32
Commit Message
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
debuginfod/debuginfod-client.c | 4 +++-
libasm/asm_end.c | 2 ++
2 files changed, 5 insertions(+), 1 deletion(-)
Comments
Hi,
On Sun, 2022-12-18 at 00:52 +0800, Yonggang Luo via Elfutils-devel
wrote:
> index 8873fcc8..7a67a440 100644
> --- a/debuginfod/debuginfod-client.c
> +++ b/debuginfod/debuginfod-client.c
> @@ -1708,9 +1708,11 @@ debuginfod_query_server (debuginfod_client *c,
> tvs[0].tv_usec = tvs[1].tv_usec = 0;
> (void) futimes (fd, tvs); /* best effort */
>
> +#if !defined(_WIN32)
> /* PR27571: make cache files casually unwriteable; dirs are
> already 0700 */
> (void) fchmod(fd, 0400);
> -
> +#endif
> +
> /* rename tmp->real */
> rc = rename (target_cache_tmppath, target_cache_path);
> if (rc < 0)
> diff --git a/libasm/asm_end.c b/libasm/asm_end.c
> index c06d2366..54540bc1 100644
> --- a/libasm/asm_end.c
> +++ b/libasm/asm_end.c
> @@ -512,12 +512,14 @@ asm_end (AsmCtx_t *ctx)
> if (result != 0)
> return result;
>
> +#if !defined(_WIN32)
> /* Make the new file globally readable and user/group-
> writable. */
> if (fchmod (ctx->fd, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP |
> S_IROTH) != 0)
> {
> __libasm_seterrno (ASM_E_CANNOT_CHMOD);
> return -1;
> }
> +#endif
I don't like the __WIN32 define checks. Is fchmod really not
available?? It seems it is a standard Posix function. Can we have a
configure check for it then?
Thanks,
Mark
@@ -1708,9 +1708,11 @@ debuginfod_query_server (debuginfod_client *c,
tvs[0].tv_usec = tvs[1].tv_usec = 0;
(void) futimes (fd, tvs); /* best effort */
+#if !defined(_WIN32)
/* PR27571: make cache files casually unwriteable; dirs are already 0700 */
(void) fchmod(fd, 0400);
-
+#endif
+
/* rename tmp->real */
rc = rename (target_cache_tmppath, target_cache_path);
if (rc < 0)
@@ -512,12 +512,14 @@ asm_end (AsmCtx_t *ctx)
if (result != 0)
return result;
+#if !defined(_WIN32)
/* Make the new file globally readable and user/group-writable. */
if (fchmod (ctx->fd, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH) != 0)
{
__libasm_seterrno (ASM_E_CANNOT_CHMOD);
return -1;
}
+#endif
/* Rename output file. */
if (rename (ctx->tmp_fname, ctx->fname) != 0)