PR/58270: RVP: tic does not honor the user's umask, output files are 0666.

This commit is contained in:
christos 2024-05-20 14:41:37 +00:00
parent 67daa9c8c8
commit 98b3419359
1 changed files with 6 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: tic.c,v 1.41 2024/05/11 22:06:57 christos Exp $ */
/* $NetBSD: tic.c,v 1.42 2024/05/20 14:41:37 christos Exp $ */
/*
* Copyright (c) 2009, 2010, 2020 The NetBSD Foundation, Inc.
@ -32,7 +32,7 @@
#endif
#include <sys/cdefs.h>
__RCSID("$NetBSD: tic.c,v 1.41 2024/05/11 22:06:57 christos Exp $");
__RCSID("$NetBSD: tic.c,v 1.42 2024/05/20 14:41:37 christos Exp $");
#include <sys/types.h>
#include <sys/queue.h>
@ -573,6 +573,7 @@ write_database(const char *dbname)
char *tmp_dbname;
TERM *term;
int fd;
mode_t m;
db = cdbw_open();
if (db == NULL)
@ -589,7 +590,9 @@ write_database(const char *dbname)
if (cdbw_output(db, fd, "NetBSD terminfo", cdbw_stable_seeder))
err(EXIT_FAILURE,
"writing temporary database %s failed", tmp_dbname);
if (fchmod(fd, DEFFILEMODE))
m = umask(0);
(void)umask(m);
if (fchmod(fd, DEFFILEMODE & ~m))
err(EXIT_FAILURE, "fchmod failed");
if (close(fd))
err(EXIT_FAILURE,